@aws/create-nx-workspace 0.118.0 → 0.120.0
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/bin/index.cjs +40 -11
- package/package.json +1 -1
package/bin/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
let child_process = require("child_process");
|
|
3
|
+
let path = require("path");
|
|
3
4
|
//#endregion
|
|
4
5
|
//#region src/create-nx-workspace.ts
|
|
5
6
|
/**
|
|
@@ -55,8 +56,6 @@ const NX_VERSION = {
|
|
|
55
56
|
"@trpc/tanstack-react-query": "11.17.0",
|
|
56
57
|
"@trpc/client": "11.17.0",
|
|
57
58
|
"@trpc/server": "11.17.0",
|
|
58
|
-
dockerode: "5.0.0",
|
|
59
|
-
"@types/dockerode": "4.0.1",
|
|
60
59
|
"@types/node": "25.9.1",
|
|
61
60
|
"@types/aws-lambda": "8.10.161",
|
|
62
61
|
"@types/cors": "2.8.19",
|
|
@@ -94,6 +93,7 @@ const NX_VERSION = {
|
|
|
94
93
|
"eslint-plugin-prettier": "5.5.5",
|
|
95
94
|
express: "5.2.1",
|
|
96
95
|
"fast-glob": "3.3.3",
|
|
96
|
+
husky: "9.1.7",
|
|
97
97
|
"fs-extra": "11.3.5",
|
|
98
98
|
"@types/fs-extra": "11.0.4",
|
|
99
99
|
"jsonc-eslint-parser": "3.1.0",
|
|
@@ -142,26 +142,48 @@ const detectPackageManager = () => {
|
|
|
142
142
|
if (userAgent.startsWith("bun/")) return "bun";
|
|
143
143
|
if (userAgent.startsWith("npm/")) return "npm";
|
|
144
144
|
};
|
|
145
|
-
const
|
|
146
|
-
const hasSkipGitFlag = (flagArgs) => flagArgs.some((a) => a === "--skipGit" || a.startsWith("--skipGit="));
|
|
147
|
-
const hasCiOverride = (flagArgs) => flagArgs.some((a) => a.startsWith("--ci") || a.startsWith("--nxCloud"));
|
|
145
|
+
const shouldSkipGit = (flagArgs) => flagArgs.some((a) => a === "--skipGit" || a === "--skipGit=true");
|
|
148
146
|
const buildArgs = (args) => {
|
|
149
147
|
const positionalArgs = args.filter((a) => !a.startsWith("-"));
|
|
150
148
|
const flagArgs = args.filter((a) => a.startsWith("-"));
|
|
151
|
-
const defaultFlags = [...DEFAULT_FLAGS];
|
|
149
|
+
const defaultFlags = [...DEFAULT_FLAGS, "--skipGit"];
|
|
152
150
|
if (!flagArgs.some((a) => a.startsWith("--pm"))) {
|
|
153
151
|
const pm = detectPackageManager();
|
|
154
152
|
if (pm) defaultFlags.push(`--pm=${pm}`);
|
|
155
153
|
}
|
|
156
|
-
|
|
157
|
-
const flagsToAdd = defaultFlags.filter((flag) => !
|
|
154
|
+
const userFlagsWithoutSkipGit = flagArgs.filter((a) => !a.startsWith("--skipGit"));
|
|
155
|
+
const flagsToAdd = defaultFlags.filter((flag) => !userFlagsWithoutSkipGit.some((a) => a.startsWith(flag.split("=")[0])));
|
|
158
156
|
return [
|
|
159
157
|
...positionalArgs,
|
|
160
158
|
`--preset=${PRESET}`,
|
|
161
159
|
...flagsToAdd,
|
|
162
|
-
...
|
|
160
|
+
...userFlagsWithoutSkipGit
|
|
163
161
|
];
|
|
164
162
|
};
|
|
163
|
+
const initGitRepo = (dir) => {
|
|
164
|
+
const shell = process.platform === "win32";
|
|
165
|
+
(0, child_process.spawnSync)("git", ["init"], {
|
|
166
|
+
cwd: dir,
|
|
167
|
+
stdio: "pipe"
|
|
168
|
+
});
|
|
169
|
+
(0, child_process.spawnSync)(detectPackageManager() ?? "npm", ["run", "prepare"], {
|
|
170
|
+
cwd: dir,
|
|
171
|
+
stdio: "pipe",
|
|
172
|
+
shell
|
|
173
|
+
});
|
|
174
|
+
(0, child_process.spawnSync)("git", ["add", "."], {
|
|
175
|
+
cwd: dir,
|
|
176
|
+
stdio: "pipe"
|
|
177
|
+
});
|
|
178
|
+
(0, child_process.spawnSync)("git", [
|
|
179
|
+
"commit",
|
|
180
|
+
"-m",
|
|
181
|
+
"Initial commit"
|
|
182
|
+
], {
|
|
183
|
+
cwd: dir,
|
|
184
|
+
stdio: "pipe"
|
|
185
|
+
});
|
|
186
|
+
};
|
|
165
187
|
/**
|
|
166
188
|
* Create a new Nx workspace with the @aws/nx-plugin preset.
|
|
167
189
|
* All arguments are forwarded to create-nx-workspace.
|
|
@@ -171,8 +193,9 @@ const createNxWorkspace = (args) => {
|
|
|
171
193
|
console.error(`Error: --preset cannot be used with @aws/create-nx-workspace.\nThis package always creates a workspace with the ${PRESET} preset.\nTo use a different preset, run create-nx-workspace directly:\n\n npx create-nx-workspace <name> --preset=<your-preset>\n`);
|
|
172
194
|
return 1;
|
|
173
195
|
}
|
|
196
|
+
const skipGit = shouldSkipGit(args.filter((a) => a.startsWith("-")));
|
|
174
197
|
const allArgs = buildArgs(args);
|
|
175
|
-
|
|
198
|
+
const result = (0, child_process.spawnSync)("npx", [
|
|
176
199
|
"-y",
|
|
177
200
|
`create-nx-workspace@${NX_VERSION}`,
|
|
178
201
|
...allArgs
|
|
@@ -183,7 +206,13 @@ const createNxWorkspace = (args) => {
|
|
|
183
206
|
pnpm_config_strict_dep_builds: "false"
|
|
184
207
|
},
|
|
185
208
|
shell: process.platform === "win32"
|
|
186
|
-
})
|
|
209
|
+
});
|
|
210
|
+
if (result.status !== 0) return result.status ?? 1;
|
|
211
|
+
if (!skipGit) {
|
|
212
|
+
const workspaceName = args.filter((a) => !a.startsWith("-"))[0];
|
|
213
|
+
if (workspaceName) initGitRepo((0, path.resolve)(workspaceName));
|
|
214
|
+
}
|
|
215
|
+
return 0;
|
|
187
216
|
};
|
|
188
217
|
//#endregion
|
|
189
218
|
//#region bin/index.ts
|