@common-stack/generate-plugin 7.0.4-alpha.2 → 7.0.4-alpha.21

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 (46) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/lib/common/package-releases/package.json +1 -0
  3. package/lib/common/package-releases/package.json.cjs +1 -0
  4. package/lib/common/package-releases/package.json.cjs.map +1 -1
  5. package/lib/common/package-releases/package.json.mjs +1 -0
  6. package/lib/common/package-releases/package.json.mjs.map +1 -1
  7. package/lib/generators/add-backend/files/package.json +1 -1
  8. package/lib/generators/add-frontend/frameworks/antui/src/entry.client.tsx.template +7 -2
  9. package/lib/generators/add-frontend/frameworks/antui/src/root.tsx.template +2 -1
  10. package/lib/generators/add-frontend/generator.cjs +1 -1
  11. package/lib/generators/add-frontend/generator.cjs.map +1 -1
  12. package/lib/generators/add-frontend/generator.mjs +1 -1
  13. package/lib/generators/add-frontend/generator.mjs.map +1 -1
  14. package/lib/generators/add-frontend/templates/package.json +2 -2
  15. package/lib/generators/add-fullstack/files/_gitignore +3 -0
  16. package/lib/generators/add-fullstack/files/package.json +4 -8
  17. package/lib/generators/add-fullstack/files/rollup.config.base.mjs +3 -4
  18. package/lib/generators/add-fullstack/generator.cjs +7 -1
  19. package/lib/generators/add-fullstack/generator.cjs.map +1 -1
  20. package/lib/generators/add-fullstack/generator.mjs +7 -1
  21. package/lib/generators/add-fullstack/generator.mjs.map +1 -1
  22. package/lib/generators/add-fullstack/schema.d.ts +10 -0
  23. package/lib/generators/add-fullstack/updates/nxSetup.cjs +114 -58
  24. package/lib/generators/add-fullstack/updates/nxSetup.cjs.map +1 -1
  25. package/lib/generators/add-fullstack/updates/nxSetup.d.ts +1 -1
  26. package/lib/generators/add-fullstack/updates/nxSetup.mjs +114 -58
  27. package/lib/generators/add-fullstack/updates/nxSetup.mjs.map +1 -1
  28. package/lib/generators/add-moleculer/files/package.json +5 -5
  29. package/lib/generators/add-package/files/browser/package.json +1 -1
  30. package/lib/generators/add-package/files/server/package.json +3 -3
  31. package/package.json +3 -3
  32. package/src/common/package-releases/package.json +1 -0
  33. package/src/generators/add-backend/files/package.json +1 -1
  34. package/src/generators/add-frontend/frameworks/antui/src/entry.client.tsx.template +7 -2
  35. package/src/generators/add-frontend/frameworks/antui/src/root.tsx.template +2 -1
  36. package/src/generators/add-frontend/generator.ts +1 -1
  37. package/src/generators/add-frontend/templates/package.json +2 -2
  38. package/src/generators/add-fullstack/files/_gitignore +3 -0
  39. package/src/generators/add-fullstack/files/package.json +4 -8
  40. package/src/generators/add-fullstack/files/rollup.config.base.mjs +3 -4
  41. package/src/generators/add-fullstack/generator.ts +8 -2
  42. package/src/generators/add-fullstack/schema.ts +10 -0
  43. package/src/generators/add-fullstack/updates/nxSetup.ts +123 -73
  44. package/src/generators/add-moleculer/files/package.json +5 -5
  45. package/src/generators/add-package/files/browser/package.json +1 -1
  46. package/src/generators/add-package/files/server/package.json +3 -3
@@ -52,7 +52,6 @@
52
52
  "devpublish:push": "yarn predevpublish && git push origin $PUBLISH_BRANCH && yarn postdevpublish",
53
53
  "format": "yarn lint --fix",
54
54
  "format:md": "yarn lint:md --fix",
55
- "pregenerateGraphql": " node --experimental-modules tools/codegenGenerator.mjs",
56
55
  "generateGraphql": "graphql-codegen-esm",
57
56
  "postgenerateGraphql": "lerna run watch --scope=common",
58
57
  "generateGraphql:watch": "yarn generateGraphql -- --watch",
@@ -77,6 +76,7 @@
77
76
  "publish:forceManual": "yarn lernapublish --force-publish=*",
78
77
  "publish:push": "yarn prelernapublish && git push origin publish && yarn postlernapublish",
79
78
  "push-develop": "git push origin develop",
79
+ "regenerateGraphql": " node --experimental-modules tools/codegenGenerator.mjs",
80
80
  "setBranchEnv": "cross-env REPOSITORY_BRANCH=${1:-$REPOSITORY_BRANCH} PUBLISH_BRANCH=${2:-$PUBLISH_BRANCH}",
81
81
  "sort-packages": "node tools/sortPackageJson.mjs && prettier --write package.json **/**/*/package.json **/*/package.json",
82
82
  "start": "cross-env NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb",
@@ -92,11 +92,7 @@
92
92
  "posttravis": "yarn lint",
93
93
  "update-lerna-on-develop": "git checkout publish && git pull origin publish && cp lerna.json ../lerna-temp.json && git checkout develop && mv ../lerna-temp.json lerna.json && git commit -am 'Update lerna.json' && yarn push-develop",
94
94
  "watch": "lerna exec --no-sort --ignore *server --ignore *device --ignore *browser-extension --stream --parallel -- webpack --watch",
95
- "watch-packages": "lerna exec --no-sort --scope @sample-stack/platform* --scope @sample-stack/react-shared-components --scope @sample-stack/core --stream --parallel 'webpack --watch'",
96
- "zen:build": "cross-env NODE_ENV=production zen build",
97
- "zen:exp": "zen exp",
98
- "zen:watch": "zen watch -x",
99
- "zen:watch:debug": "yarn zen:watch -- -v"
95
+ "watch-packages": "lerna exec --no-sort --scope @sample-stack/platform* --scope @sample-stack/react-shared-components --scope @sample-stack/core --stream --parallel 'webpack --watch'"
100
96
  },
101
97
  "resolutions": {
102
98
  "@apollo/client": "^3.9.0",
@@ -145,8 +141,8 @@
145
141
  "@babel/register": "^7.18.9",
146
142
  "@babel/runtime": "^7.20.1",
147
143
  "@common-stack/env-list-loader": "7.0.4-alpha.0",
148
- "@common-stack/generate-plugin": "7.0.4-alpha.1",
149
- "@common-stack/rollup-vite-utils": "7.0.4-alpha.0",
144
+ "@common-stack/generate-plugin": "7.0.4-alpha.20",
145
+ "@common-stack/rollup-vite-utils": "7.0.4-alpha.20",
150
146
  "@emotion/babel-plugin": "^11.11.0",
151
147
  "@graphql-codegen/add": "^5.0.3",
152
148
  "@graphql-codegen/cli": "^5.0.4",
@@ -41,10 +41,9 @@ const baseConfig = {
41
41
  include: ['**/*.ejs', '**/*.graphql'],
42
42
  }),
43
43
  addJsExtensionToImportsPlugin({
44
- packages: '*',
45
- needToAddIndexJs: [],
46
- // exclude fs/promises from modifying
47
- excludeImports: ['@emotion/react/jsx-runtime', 'fs/promises', '@apollo/server*'],
44
+ packages: ['@react-icons/all-files', '@apollo/client', '@vscode-alt/monaco-editor'],
45
+ needToAddIndexJs: ['@apollo/client'],
46
+ excludeImports: ['@emotion/react/jsx-runtime'],
48
47
  }),
49
48
  typescript(), // Initially include the TypeScript plugin
50
49
  ignoreCssUrlPlugin(),
@@ -24,13 +24,15 @@ import {
24
24
  setupNpmAuth,
25
25
  setupNxConfig,
26
26
  } from './updates';
27
- // import { generateBackend, generateFrontend } from '../../index';
28
27
  import { addBackendGenerator as generateBackend } from '../add-backend/generator';
29
28
  import { addFrontendGenerator as generateFrontend } from '../add-frontend/generator';
30
29
  import { addMoleculerGenerator as generateMoleculer } from '../add-moleculer/generator';
31
30
  import { addPackageGenerator as generatePackage } from '../add-package/generator';
32
31
 
33
32
  export async function addFullstackGenerator(tree: Tree, options: AddFullstackGeneratorSchema) {
33
+ // Immediately set the environment variable to skip NX config
34
+ process.env.SKIP_NX_CONFIG = 'true';
35
+
34
36
  let projectPath = options.path || '';
35
37
  if (projectPath !== '') {
36
38
  const basePath = process.cwd();
@@ -90,7 +92,11 @@ export async function addFullstackGenerator(tree: Tree, options: AddFullstackGen
90
92
  }
91
93
  }
92
94
 
93
- // Add this before commitInitialFiles
95
+ // Setup Nx config with AWS credentials
96
+ // Allow skipping via environment variable
97
+ if (options.skipNxConfig) {
98
+ process.env.SKIP_NX_CONFIG = 'true';
99
+ }
94
100
  await setupNxConfig(tree, projectRoot);
95
101
 
96
102
  // Setup git and commit files
@@ -0,0 +1,10 @@
1
+ export interface AddFullstackGeneratorSchema {
2
+ name?: string;
3
+ path?: string;
4
+ skipGit?: boolean;
5
+ skipGitCrypt?: boolean;
6
+ skipHusky?: boolean;
7
+ skipNxConfig?: boolean;
8
+ template?: string;
9
+ config?: any;
10
+ }
@@ -3,93 +3,143 @@ import * as path from 'path';
3
3
  import * as readline from 'readline';
4
4
 
5
5
  /**
6
- * Prompts the user for AWS credentials and updates nx.json
6
+ * Sets up Nx configuration with optional AWS credentials
7
7
  */
8
8
  export async function setupNxConfig(tree: Tree, projectRoot: string) {
9
- try {
10
- // Create readline interface for user input
11
- const rl = readline.createInterface({
12
- input: process.stdin,
13
- output: process.stdout
14
- });
15
-
16
- console.log('\nAWS Configuration for Nx Cache');
17
- console.log('=============================');
18
- console.log('This project uses AWS S3 for remote caching with Nx.');
19
- console.log('Please provide your AWS credentials or press Enter to skip for now.');
20
-
21
- // Prompt for the AWS access key ID
22
- const awsAccessKeyId = await new Promise<string>((resolve) => {
23
- rl.question('AWS Access Key ID: ', (answer) => {
24
- resolve(answer.trim());
25
- });
26
- });
27
-
28
- // Prompt for the AWS secret access key if access key ID was provided
29
- let awsSecretAccessKey = '';
30
- if (awsAccessKeyId) {
31
- awsSecretAccessKey = await new Promise<string>((resolve) => {
32
- rl.question('AWS Secret Access Key: ', (answer) => {
33
- resolve(answer.trim());
34
- });
35
- });
36
- }
37
-
38
- // Prompt for the AWS region
39
- const awsRegion = await new Promise<string>((resolve) => {
40
- rl.question('AWS Region (default: us-east-1): ', (answer) => {
41
- resolve(answer.trim() || 'us-east-1');
9
+ console.log('\nAWS Configuration for Nx Cache');
10
+ console.log('=============================');
11
+ console.log('This project uses AWS S3 for remote caching with Nx.');
12
+ console.log('Please provide your AWS credentials or press Enter to skip for now.');
13
+
14
+ // Basic configuration without AWS credentials
15
+ const basicConfig = {
16
+ tasksRunnerOptions: {
17
+ default: {
18
+ runner: 'nx/tasks-runners/default',
19
+ options: {
20
+ cacheableOperations: ['build', 'test', 'lint'],
21
+ accessibleHosts: ['https://registry.npmjs.org'],
22
+ useDaemonProcess: false,
23
+ parallel: 3,
24
+ },
25
+ },
26
+ },
27
+ };
28
+
29
+ const nxJsonPath = path.join(projectRoot, 'nx.json');
30
+
31
+ // Safe prompt function with timeout that returns a string
32
+ const askWithTimeout = (rl: readline.Interface, question: string, timeoutMs = 10000): Promise<string> => {
33
+ return new Promise<string>((resolve) => {
34
+ let resolved = false;
35
+
36
+ const timeout = setTimeout(() => {
37
+ if (!resolved) {
38
+ resolved = true;
39
+ console.log(`\nTimeout waiting for input. Skipping.`);
40
+ resolve('');
41
+ }
42
+ }, timeoutMs);
43
+
44
+ rl.question(question, (answer: string) => {
45
+ if (!resolved) {
46
+ resolved = true;
47
+ clearTimeout(timeout);
48
+ resolve(answer);
49
+ }
42
50
  });
43
51
  });
44
-
45
- // Prompt for the S3 bucket name
46
- const awsBucket = await new Promise<string>((resolve) => {
47
- rl.question('AWS S3 Bucket Name: ', (answer) => {
48
- resolve(answer.trim());
49
- });
52
+ };
53
+
54
+ let rl: readline.Interface | undefined;
55
+ try {
56
+ rl = readline.createInterface({
57
+ input: process.stdin,
58
+ output: process.stdout,
50
59
  });
51
-
52
- rl.close();
53
-
54
- // Wait for the close event to ensure we don't proceed before input is complete
55
- await new Promise(resolve => rl.on('close', resolve));
56
-
57
- // Update nx.json if it exists and AWS credentials were provided
58
- if (awsAccessKeyId && awsSecretAccessKey && awsBucket) {
59
- const nxJsonPath = path.join(projectRoot, 'nx.json');
60
+
61
+ // Ask for AWS credentials with timeouts
62
+ const accessKeyId = await askWithTimeout(rl, 'AWS Access Key ID (press Enter to skip): ');
63
+
64
+ // If user skips, create basic config
65
+ if (!accessKeyId || accessKeyId === '') {
66
+ console.log('Skipping AWS configuration. Creating basic nx.json.');
67
+ // Check if nx.json exists and update or create
60
68
  if (tree.exists(nxJsonPath)) {
61
69
  updateJson(tree, nxJsonPath, (json) => {
62
- // Preserve the existing configuration, just update the AWS credentials
63
70
  if (!json.tasksRunnerOptions) {
64
- json.tasksRunnerOptions = {};
65
- }
66
-
67
- if (!json.tasksRunnerOptions.default) {
68
- json.tasksRunnerOptions.default = {
69
- runner: '@nx-aws-plugin/nx-aws-cache',
70
- options: {
71
- runtimeCacheInputs: ['node --version']
72
- }
73
- };
71
+ json.tasksRunnerOptions = basicConfig.tasksRunnerOptions;
74
72
  }
75
-
76
- // Update only the AWS credentials
77
- json.tasksRunnerOptions.default.options = {
78
- ...json.tasksRunnerOptions.default.options,
79
- awsAccessKeyId,
80
- awsSecretAccessKey,
81
- awsRegion,
82
- awsBucket
83
- };
84
-
85
- console.log('Updated nx.json with AWS configuration');
86
73
  return json;
87
74
  });
75
+ } else {
76
+ tree.write(nxJsonPath, JSON.stringify(basicConfig, null, 2));
88
77
  }
89
78
  } else {
90
- console.log('Skipped AWS configuration for nx.json');
79
+ // Get remaining AWS info
80
+ const secretAccessKey = await askWithTimeout(rl, 'AWS Secret Access Key: ');
81
+ const region = (await askWithTimeout(rl, 'AWS Region (default: us-east-1): ')) || 'us-east-1';
82
+ const bucketName = await askWithTimeout(rl, 'AWS S3 Bucket Name: ');
83
+
84
+ // Only add AWS config if all fields are provided
85
+ if (secretAccessKey && bucketName) {
86
+ // Use type assertion to avoid TypeScript errors
87
+ const awsConfig = { ...basicConfig };
88
+ // Use "as any" to bypass type checking
89
+ (awsConfig.tasksRunnerOptions.default.options as any) = {
90
+ ...awsConfig.tasksRunnerOptions.default.options,
91
+ cacheDirectory: '.nx/cache',
92
+ remoteCache: {
93
+ s3: {
94
+ accessKeyId,
95
+ secretAccessKey,
96
+ region,
97
+ bucketName,
98
+ },
99
+ },
100
+ };
101
+
102
+ // Update or create nx.json with AWS config
103
+ if (tree.exists(nxJsonPath)) {
104
+ updateJson(tree, nxJsonPath, () => awsConfig);
105
+ console.log('Updated nx.json with AWS configuration.');
106
+ } else {
107
+ tree.write(nxJsonPath, JSON.stringify(awsConfig, null, 2));
108
+ console.log('Created nx.json with AWS configuration.');
109
+ }
110
+ } else {
111
+ console.log('Incomplete AWS information. Creating basic nx.json.');
112
+ // Create basic config without AWS
113
+ if (tree.exists(nxJsonPath)) {
114
+ updateJson(tree, nxJsonPath, (json) => {
115
+ if (!json.tasksRunnerOptions) {
116
+ json.tasksRunnerOptions = basicConfig.tasksRunnerOptions;
117
+ }
118
+ return json;
119
+ });
120
+ } else {
121
+ tree.write(nxJsonPath, JSON.stringify(basicConfig, null, 2));
122
+ }
123
+ }
91
124
  }
92
125
  } catch (error) {
93
126
  console.error('Error setting up Nx configuration:', error);
127
+ // Fallback to basic config
128
+ if (tree.exists(nxJsonPath)) {
129
+ updateJson(tree, nxJsonPath, (json) => {
130
+ if (!json.tasksRunnerOptions) {
131
+ json.tasksRunnerOptions = basicConfig.tasksRunnerOptions;
132
+ }
133
+ return json;
134
+ });
135
+ } else {
136
+ tree.write(nxJsonPath, JSON.stringify(basicConfig, null, 2));
137
+ }
138
+ } finally {
139
+ // Ensure readline interface is closed
140
+ if (rl) {
141
+ rl.close();
142
+ }
143
+ console.log('Nx configuration setup complete.');
94
144
  }
95
- }
145
+ }
@@ -29,11 +29,11 @@
29
29
  "common": "link:./common"
30
30
  },
31
31
  "dependencies": {
32
- "@common-stack/client-core": "7.0.4-alpha.0",
33
- "@common-stack/core": "7.0.4-alpha.0",
34
- "@common-stack/server-core": "7.0.4-alpha.0",
35
- "@common-stack/server-stack": "7.0.4-alpha.0",
36
- "@common-stack/store-mongo": "7.0.4-alpha.0",
32
+ "@common-stack/client-core": "7.0.4-alpha.17",
33
+ "@common-stack/core": "7.0.4-alpha.17",
34
+ "@common-stack/server-core": "7.0.4-alpha.17",
35
+ "@common-stack/server-stack": "7.0.4-alpha.18",
36
+ "@common-stack/store-mongo": "7.0.4-alpha.17",
37
37
  "@container-stack/mailing-api": "5.2.1-alpha.1",
38
38
  "helmet": "^3.21.2",
39
39
  "react": "18.2.0",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@cdm-logger/client": "*",
32
- "@common-stack/client-react": "7.0.4-alpha.0",
32
+ "@common-stack/client-react": "7.0.4-alpha.17",
33
33
  "@remix-run/react": "*",
34
34
  "antd": ">=5.1.6",
35
35
  "lodash": "*",
@@ -62,9 +62,9 @@
62
62
  "peerDependencies": {
63
63
  "@apollo/client": ">=3.0.0",
64
64
  "@cdm-logger/server": ">=9.0.3",
65
- "@common-stack/core": "7.0.4-alpha.0",
66
- "@common-stack/server-core": "7.0.4-alpha.0",
67
- "@common-stack/store-mongo": "7.0.4-alpha.0",
65
+ "@common-stack/core": "7.0.4-alpha.17",
66
+ "@common-stack/server-core": "7.0.4-alpha.17",
67
+ "@common-stack/store-mongo": "7.0.4-alpha.17",
68
68
  "@container-stack/mailing-api": ">=0.0.35-alpha.1",
69
69
  "@vscode-alt/monaco-editor": "^0.21.4",
70
70
  "inversify": "^5.0.1",