nx-react-native-cli 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/index.js +78 -71
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-react-native-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A react native starter (with NX) cli script",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -16,6 +16,7 @@
16
16
  "start": "./src/index.js",
17
17
  "build": "esbuild src/index.js --platform=node --bundle --outdir=lib --minify --analyze",
18
18
  "prepublish": "npm run build",
19
+ "example": "npx nxrn create example",
19
20
  "relink": "npm unlink nxrn && npm run prepublish && npm link nxrn",
20
21
  "test": "echo \"Error: no test specified\" && exit 1"
21
22
  },
package/src/index.js CHANGED
@@ -19,85 +19,92 @@ program
19
19
  .version('1.0.0');
20
20
 
21
21
  program
22
- .command('create')
22
+ .command('create [workspace_name]')
23
23
  .description('create nx workspace with react-native')
24
- .action((options) => {
25
- const currentPwd = process.cwd();
26
-
27
- inquirer
28
- .prompt([
24
+ .action(async (workspace_name) => {
25
+ if (!workspace_name) {
26
+ const result = await inquirer.prompt([
29
27
  {
30
28
  type: 'input',
31
- name: 'directory',
32
- message: 'Enter the directory name to create the project',
29
+ name: 'workspace_name',
30
+ message: 'Enter the workspace name',
33
31
  },
34
- ])
35
- .then((answers) => {
36
- const { directory } = answers;
37
- const workspaceDirectory = `${currentPwd}/${directory}`;
32
+ ]);
33
+
34
+ workspace_name = result.workspace_name;
35
+ }
36
+
37
+ const currentPwd = process.cwd();
38
+ const workspaceDirectory = `${currentPwd}/${workspace_name}`;
39
+
40
+ console.log(chalk.green(`Creating Nx workspace in ./${workspace_name}!`));
41
+ const spinner1 = ora().start('Creating Nx workspace');
42
+ execSync(
43
+ `cd ${currentPwd} && npx create-nx-workspace@19.4.4 --preset apps --workspaceType integrated --name ${workspace_name} --nxCloud skip`,
44
+ {
45
+ stdio: 'inherit',
46
+ },
47
+ );
48
+ spinner1.succeed('Nx workspace created');
38
49
 
39
- console.log(chalk.green(`Creating Nx workspace in ./${directory}!`));
40
- const spinner1 = ora().start('Creating Nx workspace');
41
- execSync(`cd ${currentPwd} && npx create-nx-workspace@latest --name ${directory}`, {
42
- stdio: 'inherit',
43
- });
44
- spinner1.succeed('Nx workspace created');
50
+ const spinner2 = ora().start('Adding React Native');
45
51
 
46
- const spinner2 = ora().start('Adding React Native');
47
- executeCommand(workspaceDirectory, `npx nx reset`, {
48
- stdio: 'inherit',
49
- });
50
- executeCommand(workspaceDirectory, `npm i -D @nx/react-native@17.3.0`, {
51
- stdio: 'inherit',
52
- });
53
- executeCommand(workspaceDirectory, `npx nx g @nx/react-native:app apps/mobile --skip-nx-cache`, {
54
- stdio: 'inherit',
55
- });
56
- executeCommand(
57
- workspaceDirectory,
58
- `npm install --save-dev react-native-dotenv husky prettier@3.3.2 @typescript-eslint/parser@6.21.0 eslint-config-airbnb-typescript@17.1.0 eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-perf eslint-plugin-sonarjs@0.25.1 @tanstack/eslint-plugin-query eslint-plugin-tailwindcss eslint-config-prettier @typescript-eslint/eslint-plugin@6.13.2 eslint-plugin-import eslint-plugin-sort-destructure-keys eslint-plugin-sort-keys-fix eslint-plugin-prettier prettier-plugin-tailwindcss eslint-import-resolver-typescript @swc-node/register@~1.8.0`,
59
- { stdio: 'inherit' },
60
- );
61
- executeCommand(
62
- workspaceDirectory,
63
- `npm install tailwindcss twrnc react-native-keyboard-aware-scroll-view react-native-safe-area-context @react-navigation/core @react-navigation/native @react-navigation/native-stack @react-navigation/routers @react-navigation/stack react-native-gesture-handler react-native-screens react-native-reanimated dayjs zustand jotai @tanstack/query-core @tanstack/query-sync-storage-persister @tanstack/react-query @tanstack/react-query-persist-client axios jotai-optics lodash react-hook-form react-native-fast-image react-native-get-random-values react-native-simple-toast react-native-url-polyfill zod zod-validation-error @react-native-async-storage/async-storage @react-native-community/hooks @gorhom/bottom-sheet @hookform/resolvers @react-native-community/datetimepicker @react-navigation/material-top-tabs @tanstack/query-async-storage-persister babel-plugin-module-resolver react-native-dotenv react-native-mmkv react-native-modal-datetime-picker react-native-pager-view react-native-modal react-native-svg-transformer react-native-url-polyfill uuid`,
64
- { stdio: 'inherit' },
65
- );
66
- spinner2.succeed('React Native added');
52
+ executeCommand(workspaceDirectory, `npm i -D @nx/react-native@17.3.0 --ignore-scripts`, {
53
+ stdio: 'inherit',
54
+ });
55
+ executeCommand(
56
+ workspaceDirectory,
57
+ `npx nx g @nx/react-native:app apps/mobile --skip-nx-cache`,
58
+ {
59
+ stdio: 'inherit',
60
+ },
61
+ );
62
+ executeCommand(
63
+ workspaceDirectory,
64
+ `npm install --save-dev react-native-dotenv husky prettier@3.3.2 @typescript-eslint/parser@6.21.0 eslint-config-airbnb-typescript@17.1.0 eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-perf eslint-plugin-sonarjs@0.25.1 @tanstack/eslint-plugin-query eslint-plugin-tailwindcss eslint-config-prettier @typescript-eslint/eslint-plugin@6.13.2 eslint-plugin-import eslint-plugin-sort-destructure-keys eslint-plugin-sort-keys-fix eslint-plugin-prettier prettier-plugin-tailwindcss eslint-import-resolver-typescript @swc-node/register@~1.8.0`,
65
+ { stdio: 'inherit' },
66
+ );
67
+ executeCommand(
68
+ workspaceDirectory,
69
+ `npm install tailwindcss twrnc react-native-keyboard-aware-scroll-view react-native-safe-area-context @react-navigation/core @react-navigation/native @react-navigation/native-stack @react-navigation/routers @react-navigation/stack react-native-gesture-handler react-native-screens react-native-reanimated dayjs zustand jotai @tanstack/query-core @tanstack/query-sync-storage-persister @tanstack/react-query @tanstack/react-query-persist-client axios jotai-optics lodash react-hook-form react-native-fast-image react-native-get-random-values react-native-simple-toast react-native-url-polyfill zod zod-validation-error @react-native-async-storage/async-storage @react-native-community/hooks @gorhom/bottom-sheet @hookform/resolvers @react-native-community/datetimepicker @react-navigation/material-top-tabs @tanstack/query-async-storage-persister babel-plugin-module-resolver react-native-dotenv react-native-mmkv react-native-modal-datetime-picker react-native-pager-view react-native-modal react-native-svg-transformer react-native-url-polyfill uuid`,
70
+ { stdio: 'inherit' },
71
+ );
72
+ spinner2.succeed('React Native added');
67
73
 
68
- const spinner3 = ora().start('Adding files');
69
- copyDir(`${workspaceDirectory}/.vscode`, `.vscode`);
70
- copyDir(`${workspaceDirectory}/.husky`, `.husky`);
71
- copyFile(`${workspaceDirectory}/.prettierrc`, '.prettierrc');
72
- copyFile(`${workspaceDirectory}/.prettierignore`, '.prettierignore');
73
- copyFile(`${workspaceDirectory}/.eslintrc.json`, '.eslintrc.json');
74
- copyFile(`${workspaceDirectory}/.eslintrc.json`, '.eslintrc.json');
75
- copyFile(`${workspaceDirectory}/.gitignore`, '.gitignore');
76
- copyFile(`${workspaceDirectory}/.ruby-version`, '.ruby-version');
77
- copyFile(`${workspaceDirectory}/.nvmrc`, '.nvmrc');
78
- copyFile(`${workspaceDirectory}/check-env.sh`, `check-env.sh`);
79
- copyFile(`${workspaceDirectory}/clean-generated-outputs.sh`, `clean-generated-outputs.sh`);
80
- removeDir(`${workspaceDirectory}/apps/mobile/src`);
81
- copyDir(`${workspaceDirectory}/apps`, `apps`);
82
- executeCommand(workspaceDirectory, `keytool -genkey -keystore ${workspaceDirectory}/apps/mobile/android/app/dev.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias dev -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown" -storepass development -keypass development`, {
83
- stdio: 'inherit',
84
- });
85
- addScriptsInRootPackageJson(workspaceDirectory);
86
- spinner3.succeed('Files added');
74
+ const spinner3 = ora().start('Adding files');
75
+ copyDir(`${workspaceDirectory}/.vscode`, `.vscode`);
76
+ copyDir(`${workspaceDirectory}/.husky`, `.husky`);
77
+ copyFile(`${workspaceDirectory}/.prettierrc`, '.prettierrc');
78
+ copyFile(`${workspaceDirectory}/.prettierignore`, '.prettierignore');
79
+ copyFile(`${workspaceDirectory}/.eslintrc.json`, '.eslintrc.json');
80
+ copyFile(`${workspaceDirectory}/.eslintrc.json`, '.eslintrc.json');
81
+ copyFile(`${workspaceDirectory}/.gitignore`, '.gitignore');
82
+ copyFile(`${workspaceDirectory}/.ruby-version`, '.ruby-version');
83
+ copyFile(`${workspaceDirectory}/.nvmrc`, '.nvmrc');
84
+ copyFile(`${workspaceDirectory}/check-env.sh`, `check-env.sh`);
85
+ copyFile(`${workspaceDirectory}/clean-generated-outputs.sh`, `clean-generated-outputs.sh`);
86
+ removeDir(`${workspaceDirectory}/apps/mobile/src`);
87
+ copyDir(`${workspaceDirectory}/apps`, `apps`);
88
+ executeCommand(
89
+ workspaceDirectory,
90
+ `keytool -genkey -keystore ${workspaceDirectory}/apps/mobile/android/app/dev.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias dev -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown" -storepass development -keypass development`,
91
+ {
92
+ stdio: 'inherit',
93
+ },
94
+ );
95
+ addScriptsInRootPackageJson(workspaceDirectory);
96
+ spinner3.succeed('Files added');
87
97
 
88
- console.log(chalk.green('Project created successfully!'));
89
- console.log(
90
- chalk.blue(
91
- 'Next Steps? Rename your app using https://www.npmjs.com/package/react-native-rename',
92
- ),
93
- );
94
- console.log(
95
- chalk.blue(
96
- "Don't forget to wide search for 'AppsMobile' and replace it with your app name",
97
- ),
98
- );
99
- console.log(chalk.blue('Run `npm run serve:mobile` to start the project! Happy coding!'));
100
- });
98
+ console.log(chalk.green('Project created successfully!'));
99
+ console.log(
100
+ chalk.blue(
101
+ 'Next Steps? Rename your app using https://www.npmjs.com/package/react-native-rename',
102
+ ),
103
+ );
104
+ console.log(
105
+ chalk.blue("Don't forget to wide search for 'AppsMobile' and replace it with your app name"),
106
+ );
107
+ console.log(chalk.blue('Run `npm run serve:mobile` to start the project! Happy coding!'));
101
108
  });
102
109
 
103
110
  program.parse(process.argv);