Skip to content

Commit

Permalink
feat: Create a component type file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 24, 2019
1 parent 76514dd commit f29a667
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions package/react-native-uiw/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ lib
src
node_modules
package-lock.json
tsconfig.json
yarn.lock

# OSX
Expand Down
8 changes: 5 additions & 3 deletions package/react-native-uiw/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@uiw/react-native",
"version": "1.0.6",
"version": "1.0.8",
"description": "UIW for React Native",
"main": "lib/index.js",
"scripts": {
"start": "node script/build.js"
"start": "node script/build.js",
"type": "tsbb types"
},
"keywords": [],
"author": "",
Expand Down Expand Up @@ -34,7 +35,8 @@
"@babel/preset-typescript": "^7.6.0",
"babel-preset-react-native": "^4.0.1",
"fs-extra": "^8.1.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-native": "^0.60.0",
"metro-react-native-babel-preset": "^0.56.0"
"tsbb": "^1.1.3"
}
}
36 changes: 34 additions & 2 deletions package/react-native-uiw/script/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,33 @@ function getPath(rootPath, result = []) {
return result;
}

const tsc = {
compilerOptions: {
// allowJs: true,
allowSyntheticDefaultImports: true,
esModuleInterop: true,
outDir: 'lib',
// isolatedModules: true,
declaration: true,
jsx: 'react',
lib: ['es6'],
resolveJsonModule: true,
moduleResolution: 'node',
strict: true,
target: 'esnext',
baseUrl: '.',
},
exclude: ['node_modules'],
include: ['src/**/*'],
};

(async () => {
const root = path.join(process.cwd(), 'src');
const output = path.join(process.cwd(), 'lib');
await fs.emptyDir(root);
const tscPath = path.join(process.cwd(), 'tsconfig.json');
await fs.remove(output);
await fs.writeJSON(tscPath, tsc);
await fs.remove(root);
await fs.copy(path.join(process.cwd(), '../../components'), root);
const files = await getPath(root);
files.forEach(itemPath => {
Expand All @@ -36,12 +59,21 @@ function getPath(rootPath, result = []) {
const outputFile = itemPath.replace(root, output);
fs.outputFileSync(outputFile.replace(/.(tsx|ts)$/, '.js'), code);
// eslint-disable-next-line prettier/prettier
console.log(`♻️: ${itemPath.replace(process.cwd(), '').replace(/^\//, '')} -> ${outputFile.replace(process.cwd(), '').replace(/^\//, '')}`);
console.log(`♻️: ${itemPath.replace(process.cwd(), '').replace(/^\//, '')} -> ${outputFile.replace(process.cwd(), '').replace(/^\//, '').replace(/\.tsx$/, '.js')}`);
}
if (/.(md)$/.test(itemPath)) {
const outputMd = itemPath.replace(root, output);
fs.ensureFileSync(outputMd);
fs.copyFileSync(itemPath, outputMd);
// eslint-disable-next-line prettier/prettier
console.log(`📋: ${itemPath.replace(process.cwd(), '').replace(/^\//, '')} -> ${outputMd.replace(process.cwd(), '').replace(/^\//, '')}`);
}
});
await execute('npm run type');
await execute('npm publish');
await fs.remove(root);
await fs.remove(output);
await fs.remove(tscPath);
await fs.remove(path.join(process.cwd(), 'package-lock.json'));
await fs.remove(path.join(process.cwd(), 'node_modules'));
})();
Expand Down

0 comments on commit f29a667

Please sign in to comment.