@common-stack/generate-plugin 6.0.6-alpha.20 → 6.0.6-alpha.22
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.
- package/CHANGELOG.md +8 -0
- package/lib/generators/add-frontend/templates/package.json +3 -3
- package/lib/generators/add-fullstack/files/package.json +1 -1
- package/lib/generators/add-fullstack/files/tools/update-dependencies.mjs +95 -63
- package/package.json +2 -2
- package/src/generators/add-fullstack/files/package.json +1 -1
- package/src/generators/add-fullstack/files/tools/update-dependencies.mjs +95 -63
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.0.6-alpha.22](https://github.com/cdmbase/common-stack/compare/v6.0.6-alpha.21...v6.0.6-alpha.22) (2024-09-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
9
|
+
|
|
10
|
+
## [6.0.6-alpha.21](https://github.com/cdmbase/common-stack/compare/v6.0.6-alpha.20...v6.0.6-alpha.21) (2024-09-12)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
13
|
+
|
|
6
14
|
## [6.0.6-alpha.20](https://github.com/cdmbase/common-stack/compare/v6.0.6-alpha.19...v6.0.6-alpha.20) (2024-09-12)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"watch:test": "cross-env ENV_FILE=../../config/test/test.env node ./server.js"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@common-stack/frontend-stack-react": "6.0.6-alpha.
|
|
55
|
+
"@common-stack/frontend-stack-react": "6.0.6-alpha.20",
|
|
56
56
|
"@react-icons/all-files": "^4.1.0",
|
|
57
57
|
"classnames": "^2.2.6",
|
|
58
58
|
"compression": "^1.7.4",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@cdmbase/vite-plugin-i18next-loader": "^2.0.12",
|
|
83
|
-
"@common-stack/frontend-stack-react": "6.0.6-alpha.
|
|
84
|
-
"@common-stack/rollup-vite-utils": "6.0.6-alpha.
|
|
83
|
+
"@common-stack/frontend-stack-react": "6.0.6-alpha.20",
|
|
84
|
+
"@common-stack/rollup-vite-utils": "6.0.6-alpha.21",
|
|
85
85
|
"@remix-run/dev": "^2.8.1",
|
|
86
86
|
"@remix-run/serve": "^2.8.1",
|
|
87
87
|
"cross-env": "^7.0.3",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"@babel/register": "^7.18.9",
|
|
148
148
|
"@babel/runtime": "^7.20.1",
|
|
149
149
|
"@common-stack/env-list-loader": "6.0.6-alpha.5",
|
|
150
|
-
"@common-stack/generate-plugin": "6.0.6-alpha.
|
|
150
|
+
"@common-stack/generate-plugin": "6.0.6-alpha.21",
|
|
151
151
|
"@emotion/babel-plugin": "^11.11.0",
|
|
152
152
|
"@graphql-codegen/add": "^5.0.2",
|
|
153
153
|
"@graphql-codegen/cli": "^5.0.2",
|
|
@@ -10,86 +10,118 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
|
10
10
|
const JSON_SPACING = 4;
|
|
11
11
|
const ADD_END_NEWLINE = true; // Set to true to add a newline at the end of the file
|
|
12
12
|
|
|
13
|
-
// Paths to package.json files
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
// Paths to package.json files (now using arrays to handle multiple paths for backend, frontend, and mobile)
|
|
14
|
+
const packagePaths = {
|
|
15
|
+
backend: [
|
|
16
|
+
resolve(__dirname, '../servers/backend-server/package.json'),
|
|
17
|
+
],
|
|
18
|
+
frontend: [
|
|
19
|
+
resolve(__dirname, '../servers/frontend-server/package.json'),
|
|
20
|
+
],
|
|
21
|
+
mobile: [
|
|
22
|
+
resolve(__dirname, '../portable-devices/mobile/package.json'),
|
|
23
|
+
]
|
|
24
|
+
};
|
|
16
25
|
|
|
17
26
|
// Packages to check
|
|
18
27
|
const packagesToCheck = [
|
|
19
28
|
'@common-stack/server-stack',
|
|
20
|
-
'@common-stack/frontend-stack-react'
|
|
29
|
+
'@common-stack/frontend-stack-react',
|
|
30
|
+
'@common-stack/mobile-stack-react'
|
|
21
31
|
];
|
|
22
32
|
|
|
33
|
+
// Utility function to wrap `exec` in a promise for sequential execution
|
|
34
|
+
const execCommand = (command, cwd) => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
exec(command, { cwd }, (err, stdout, stderr) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
console.error(`Error executing command: ${command}\n${stderr}`);
|
|
39
|
+
return reject(err);
|
|
40
|
+
}
|
|
41
|
+
console.log(stdout);
|
|
42
|
+
resolve();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
23
47
|
// Function to update dependencies
|
|
24
48
|
const updateDependencies = async (targetPackagePath, sourcePackagePath) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Write the formatted JSON back to disk
|
|
48
|
-
await writeFile(targetPackagePath, jsonString, 'utf-8');
|
|
49
|
+
const targetPackageJson = JSON.parse(await readFile(targetPackagePath, 'utf-8'));
|
|
50
|
+
const sourcePackageJson = JSON.parse(await readFile(sourcePackagePath, 'utf-8'));
|
|
51
|
+
|
|
52
|
+
const mergeDependencies = (targetDeps = {}, sourceDeps = {}) => ({
|
|
53
|
+
...targetDeps,
|
|
54
|
+
...sourceDeps
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Merge dependencies only
|
|
58
|
+
targetPackageJson.dependencies = mergeDependencies(targetPackageJson.dependencies, sourcePackageJson.dependencies);
|
|
59
|
+
|
|
60
|
+
// Format the JSON string with the specified spacing
|
|
61
|
+
let jsonString = JSON.stringify(targetPackageJson, null, JSON_SPACING);
|
|
62
|
+
|
|
63
|
+
// Optionally add a newline at the end
|
|
64
|
+
if (ADD_END_NEWLINE) {
|
|
65
|
+
jsonString += '\n';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Write the formatted JSON back to disk
|
|
69
|
+
await writeFile(targetPackagePath, jsonString, 'utf-8');
|
|
49
70
|
};
|
|
50
71
|
|
|
51
|
-
// Function to run `ncu`, update dependencies, and then run linting
|
|
72
|
+
// Function to run `ncu`, `yarn` from the root, update dependencies, and then run linting
|
|
52
73
|
export const runUpdateDependencies = async () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
console.log(stdout);
|
|
61
|
-
resolve();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
74
|
+
// Step 1: Run `ncu` to update the dependencies from the root level
|
|
75
|
+
console.log('Updating dependencies using `ncu`...');
|
|
76
|
+
await execCommand(
|
|
77
|
+
'ncu -u -t minor "@common-stack*" && lerna exec "ncu -u -t minor /@common-stack*/"',
|
|
78
|
+
resolve(__dirname, '..')
|
|
79
|
+
);
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
packagePath
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
// Step 2: Run `yarn` to install updated packages from the root
|
|
82
|
+
console.log('Running yarn install...');
|
|
83
|
+
await execCommand('yarn', resolve(__dirname, '..'));
|
|
84
|
+
|
|
85
|
+
// Step 3: Update dependencies for each package
|
|
86
|
+
for (const packageName of packagesToCheck) {
|
|
87
|
+
const packagePath = resolve(__dirname, `../node_modules/${packageName}/package.json`);
|
|
88
|
+
let targetPaths;
|
|
89
|
+
|
|
90
|
+
// Determine the target package.json paths (array of paths)
|
|
91
|
+
if (packageName.includes('server-stack')) {
|
|
92
|
+
targetPaths = packagePaths.backend;
|
|
93
|
+
} else if (packageName.includes('mobile-stack-react')) {
|
|
94
|
+
targetPaths = packagePaths.mobile;
|
|
95
|
+
} else {
|
|
96
|
+
targetPaths = packagePaths.frontend;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Iterate over all target paths in the corresponding array
|
|
100
|
+
for (const targetPackagePath of targetPaths) {
|
|
101
|
+
try {
|
|
102
|
+
await updateDependencies(targetPackagePath, packagePath);
|
|
103
|
+
console.log(`Updated dependencies for ${packageName} in ${targetPackagePath}`);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.warn(`Package ${packageName} not found or failed to update in ${targetPackagePath}:`, error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
75
108
|
}
|
|
76
|
-
}
|
|
77
109
|
|
|
78
|
-
|
|
110
|
+
console.log('Dependencies from @common-stack packages have been updated.');
|
|
79
111
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
// Step 4: Run linting to apply Prettier
|
|
113
|
+
try {
|
|
114
|
+
await runLintStaged();
|
|
115
|
+
console.log('Prettier formatting applied.');
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.error('Failed to run Prettier:', err);
|
|
118
|
+
}
|
|
87
119
|
};
|
|
88
120
|
|
|
89
121
|
// Execute the function if this file is run directly
|
|
90
122
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
123
|
+
runUpdateDependencies().catch((err) => {
|
|
124
|
+
console.error('Failed to update dependencies:', err);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
});
|
|
95
127
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/generate-plugin",
|
|
3
|
-
"version": "6.0.6-alpha.
|
|
3
|
+
"version": "6.0.6-alpha.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
},
|
|
26
26
|
"executors": "./executors.json",
|
|
27
27
|
"generators": "./generators.json",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "f30c1a84478e52e724554437b85db2dd8bb15dfd"
|
|
29
29
|
}
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"@babel/register": "^7.18.9",
|
|
148
148
|
"@babel/runtime": "^7.20.1",
|
|
149
149
|
"@common-stack/env-list-loader": "6.0.6-alpha.5",
|
|
150
|
-
"@common-stack/generate-plugin": "6.0.6-alpha.
|
|
150
|
+
"@common-stack/generate-plugin": "6.0.6-alpha.21",
|
|
151
151
|
"@emotion/babel-plugin": "^11.11.0",
|
|
152
152
|
"@graphql-codegen/add": "^5.0.2",
|
|
153
153
|
"@graphql-codegen/cli": "^5.0.2",
|
|
@@ -10,86 +10,118 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
|
10
10
|
const JSON_SPACING = 4;
|
|
11
11
|
const ADD_END_NEWLINE = true; // Set to true to add a newline at the end of the file
|
|
12
12
|
|
|
13
|
-
// Paths to package.json files
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
// Paths to package.json files (now using arrays to handle multiple paths for backend, frontend, and mobile)
|
|
14
|
+
const packagePaths = {
|
|
15
|
+
backend: [
|
|
16
|
+
resolve(__dirname, '../servers/backend-server/package.json'),
|
|
17
|
+
],
|
|
18
|
+
frontend: [
|
|
19
|
+
resolve(__dirname, '../servers/frontend-server/package.json'),
|
|
20
|
+
],
|
|
21
|
+
mobile: [
|
|
22
|
+
resolve(__dirname, '../portable-devices/mobile/package.json'),
|
|
23
|
+
]
|
|
24
|
+
};
|
|
16
25
|
|
|
17
26
|
// Packages to check
|
|
18
27
|
const packagesToCheck = [
|
|
19
28
|
'@common-stack/server-stack',
|
|
20
|
-
'@common-stack/frontend-stack-react'
|
|
29
|
+
'@common-stack/frontend-stack-react',
|
|
30
|
+
'@common-stack/mobile-stack-react'
|
|
21
31
|
];
|
|
22
32
|
|
|
33
|
+
// Utility function to wrap `exec` in a promise for sequential execution
|
|
34
|
+
const execCommand = (command, cwd) => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
exec(command, { cwd }, (err, stdout, stderr) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
console.error(`Error executing command: ${command}\n${stderr}`);
|
|
39
|
+
return reject(err);
|
|
40
|
+
}
|
|
41
|
+
console.log(stdout);
|
|
42
|
+
resolve();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
23
47
|
// Function to update dependencies
|
|
24
48
|
const updateDependencies = async (targetPackagePath, sourcePackagePath) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Write the formatted JSON back to disk
|
|
48
|
-
await writeFile(targetPackagePath, jsonString, 'utf-8');
|
|
49
|
+
const targetPackageJson = JSON.parse(await readFile(targetPackagePath, 'utf-8'));
|
|
50
|
+
const sourcePackageJson = JSON.parse(await readFile(sourcePackagePath, 'utf-8'));
|
|
51
|
+
|
|
52
|
+
const mergeDependencies = (targetDeps = {}, sourceDeps = {}) => ({
|
|
53
|
+
...targetDeps,
|
|
54
|
+
...sourceDeps
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Merge dependencies only
|
|
58
|
+
targetPackageJson.dependencies = mergeDependencies(targetPackageJson.dependencies, sourcePackageJson.dependencies);
|
|
59
|
+
|
|
60
|
+
// Format the JSON string with the specified spacing
|
|
61
|
+
let jsonString = JSON.stringify(targetPackageJson, null, JSON_SPACING);
|
|
62
|
+
|
|
63
|
+
// Optionally add a newline at the end
|
|
64
|
+
if (ADD_END_NEWLINE) {
|
|
65
|
+
jsonString += '\n';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Write the formatted JSON back to disk
|
|
69
|
+
await writeFile(targetPackagePath, jsonString, 'utf-8');
|
|
49
70
|
};
|
|
50
71
|
|
|
51
|
-
// Function to run `ncu`, update dependencies, and then run linting
|
|
72
|
+
// Function to run `ncu`, `yarn` from the root, update dependencies, and then run linting
|
|
52
73
|
export const runUpdateDependencies = async () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
console.log(stdout);
|
|
61
|
-
resolve();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
74
|
+
// Step 1: Run `ncu` to update the dependencies from the root level
|
|
75
|
+
console.log('Updating dependencies using `ncu`...');
|
|
76
|
+
await execCommand(
|
|
77
|
+
'ncu -u -t minor "@common-stack*" && lerna exec "ncu -u -t minor /@common-stack*/"',
|
|
78
|
+
resolve(__dirname, '..')
|
|
79
|
+
);
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
packagePath
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
// Step 2: Run `yarn` to install updated packages from the root
|
|
82
|
+
console.log('Running yarn install...');
|
|
83
|
+
await execCommand('yarn', resolve(__dirname, '..'));
|
|
84
|
+
|
|
85
|
+
// Step 3: Update dependencies for each package
|
|
86
|
+
for (const packageName of packagesToCheck) {
|
|
87
|
+
const packagePath = resolve(__dirname, `../node_modules/${packageName}/package.json`);
|
|
88
|
+
let targetPaths;
|
|
89
|
+
|
|
90
|
+
// Determine the target package.json paths (array of paths)
|
|
91
|
+
if (packageName.includes('server-stack')) {
|
|
92
|
+
targetPaths = packagePaths.backend;
|
|
93
|
+
} else if (packageName.includes('mobile-stack-react')) {
|
|
94
|
+
targetPaths = packagePaths.mobile;
|
|
95
|
+
} else {
|
|
96
|
+
targetPaths = packagePaths.frontend;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Iterate over all target paths in the corresponding array
|
|
100
|
+
for (const targetPackagePath of targetPaths) {
|
|
101
|
+
try {
|
|
102
|
+
await updateDependencies(targetPackagePath, packagePath);
|
|
103
|
+
console.log(`Updated dependencies for ${packageName} in ${targetPackagePath}`);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.warn(`Package ${packageName} not found or failed to update in ${targetPackagePath}:`, error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
75
108
|
}
|
|
76
|
-
}
|
|
77
109
|
|
|
78
|
-
|
|
110
|
+
console.log('Dependencies from @common-stack packages have been updated.');
|
|
79
111
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
// Step 4: Run linting to apply Prettier
|
|
113
|
+
try {
|
|
114
|
+
await runLintStaged();
|
|
115
|
+
console.log('Prettier formatting applied.');
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.error('Failed to run Prettier:', err);
|
|
118
|
+
}
|
|
87
119
|
};
|
|
88
120
|
|
|
89
121
|
// Execute the function if this file is run directly
|
|
90
122
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
123
|
+
runUpdateDependencies().catch((err) => {
|
|
124
|
+
console.error('Failed to update dependencies:', err);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
});
|
|
95
127
|
}
|