create-nx-workspace 22.7.0-beta.7 → 22.7.0-beta.8
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/create-nx-workspace.d.ts +14 -0
- package/bin/create-nx-workspace.d.ts.map +1 -1
- package/bin/create-nx-workspace.js +49 -3
- package/package.json +2 -2
- package/src/create-empty-workspace.d.ts.map +1 -1
- package/src/create-empty-workspace.js +4 -2
- package/src/create-preset.d.ts.map +1 -1
- package/src/create-preset.js +2 -2
- package/src/create-workspace-options.d.ts +6 -0
- package/src/create-workspace-options.d.ts.map +1 -1
- package/src/create-workspace.d.ts.map +1 -1
- package/src/create-workspace.js +2 -2
- package/src/utils/error-utils.d.ts +1 -1
- package/src/utils/error-utils.d.ts.map +1 -1
- package/src/utils/template/clone-template.d.ts +1 -1
- package/src/utils/template/clone-template.d.ts.map +1 -1
- package/src/utils/template/clone-template.js +2 -2
|
@@ -66,5 +66,19 @@ interface UnknownStackArguments extends BaseArguments {
|
|
|
66
66
|
type Arguments = NoneArguments | ReactArguments | AngularArguments | VueArguments | NodeArguments | UnknownStackArguments;
|
|
67
67
|
export declare const commandsObject: yargs.Argv<Arguments>;
|
|
68
68
|
export declare function validateWorkspaceName(name: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves special folder name patterns (`.`, `./`, absolute paths) into a
|
|
71
|
+
* workspace name and a `workingDir` override so that downstream functions
|
|
72
|
+
* create the workspace at the intended location.
|
|
73
|
+
*
|
|
74
|
+
* @visibleForTesting
|
|
75
|
+
*
|
|
76
|
+
* Returns `{ name, workingDir }` for special inputs, or `null` if the
|
|
77
|
+
* input is a regular name that needs no special handling.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveSpecialFolderName(folderName: string): {
|
|
80
|
+
name: string;
|
|
81
|
+
workingDir: string;
|
|
82
|
+
} | null;
|
|
69
83
|
export {};
|
|
70
84
|
//# sourceMappingURL=create-nx-workspace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-nx-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/bin/create-nx-workspace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EACL,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAiB,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"create-nx-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/bin/create-nx-workspace.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.commandsObject = void 0;
|
|
4
4
|
exports.validateWorkspaceName = validateWorkspaceName;
|
|
5
|
+
exports.resolveSpecialFolderName = resolveSpecialFolderName;
|
|
5
6
|
const tslib_1 = require("tslib");
|
|
6
7
|
const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
|
|
7
8
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
@@ -19,6 +20,7 @@ const yargs_options_1 = require("../src/internal-utils/yargs-options");
|
|
|
19
20
|
const ab_testing_1 = require("../src/utils/nx/ab-testing");
|
|
20
21
|
const error_utils_1 = require("../src/utils/error-utils");
|
|
21
22
|
const fs_1 = require("fs");
|
|
23
|
+
const path_1 = require("path");
|
|
22
24
|
const is_ci_1 = require("../src/utils/ci/is-ci");
|
|
23
25
|
const git_1 = require("../src/utils/git/git");
|
|
24
26
|
const ai_output_1 = require("../src/utils/ai/ai-output");
|
|
@@ -618,14 +620,54 @@ function validateWorkspaceName(name) {
|
|
|
618
620
|
throw new error_utils_1.CnwError('INVALID_WORKSPACE_NAME', `The workspace name "${name}" is invalid. Workspace names must start with a letter. Examples of valid names: myapp, MyApp, my-app, my_app`);
|
|
619
621
|
}
|
|
620
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Resolves special folder name patterns (`.`, `./`, absolute paths) into a
|
|
625
|
+
* workspace name and a `workingDir` override so that downstream functions
|
|
626
|
+
* create the workspace at the intended location.
|
|
627
|
+
*
|
|
628
|
+
* @visibleForTesting
|
|
629
|
+
*
|
|
630
|
+
* Returns `{ name, workingDir }` for special inputs, or `null` if the
|
|
631
|
+
* input is a regular name that needs no special handling.
|
|
632
|
+
*/
|
|
633
|
+
function resolveSpecialFolderName(folderName) {
|
|
634
|
+
// Handle "." and "./" — user wants to init in the current directory
|
|
635
|
+
if (folderName === '.' || folderName === './') {
|
|
636
|
+
const cwd = (0, path_1.resolve)(process.cwd());
|
|
637
|
+
if ((0, fs_1.readdirSync)(cwd).length > 0) {
|
|
638
|
+
throw new error_utils_1.CnwError('DIRECTORY_EXISTS', `The current directory is not empty. Use "nx init" to add Nx to an existing project.`);
|
|
639
|
+
}
|
|
640
|
+
return { name: (0, path_1.basename)(cwd), workingDir: (0, path_1.dirname)(cwd) };
|
|
641
|
+
}
|
|
642
|
+
// Handle absolute paths like /tmp/acme
|
|
643
|
+
if ((0, path_1.isAbsolute)(folderName)) {
|
|
644
|
+
const parentDir = (0, path_1.dirname)(folderName);
|
|
645
|
+
const name = (0, path_1.basename)(folderName);
|
|
646
|
+
if (!(0, fs_1.existsSync)(parentDir)) {
|
|
647
|
+
throw new error_utils_1.CnwError('INVALID_PATH', `The parent directory "${parentDir}" does not exist.`);
|
|
648
|
+
}
|
|
649
|
+
return { name, workingDir: parentDir };
|
|
650
|
+
}
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
621
653
|
async function determineFolder(parsedArgs) {
|
|
622
|
-
const
|
|
654
|
+
const rawFolderName = parsedArgs._[0]
|
|
623
655
|
? parsedArgs._[0].toString()
|
|
624
656
|
: parsedArgs.name;
|
|
625
|
-
if (
|
|
657
|
+
if (rawFolderName) {
|
|
658
|
+
// Resolve ".", "./", and absolute paths before validation
|
|
659
|
+
const resolved = resolveSpecialFolderName(rawFolderName);
|
|
660
|
+
const folderName = resolved?.name ?? rawFolderName;
|
|
661
|
+
if (resolved?.workingDir) {
|
|
662
|
+
parsedArgs.workingDir = resolved.workingDir;
|
|
663
|
+
}
|
|
626
664
|
validateWorkspaceName(folderName);
|
|
627
665
|
// If directory exists, either re-prompt (interactive) or error (non-interactive)
|
|
628
|
-
|
|
666
|
+
// Check relative to workingDir when set (e.g. absolute path resolved to a different parent)
|
|
667
|
+
const targetDir = resolved?.workingDir
|
|
668
|
+
? (0, path_1.join)(resolved.workingDir, folderName)
|
|
669
|
+
: folderName;
|
|
670
|
+
if ((0, fs_1.existsSync)(targetDir)) {
|
|
629
671
|
if (parsedArgs.interactive && !(0, is_ci_1.isCI)()) {
|
|
630
672
|
output_1.output.warn({
|
|
631
673
|
title: `Directory ${folderName} already exists.`,
|
|
@@ -1152,7 +1194,11 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1152
1194
|
appName = await determineAppName(parsedArgs);
|
|
1153
1195
|
}
|
|
1154
1196
|
}
|
|
1197
|
+
const validAngularBundlers = ['esbuild', 'rspack', 'webpack'];
|
|
1155
1198
|
if (parsedArgs.bundler) {
|
|
1199
|
+
if (!validAngularBundlers.includes(parsedArgs.bundler)) {
|
|
1200
|
+
throw new error_utils_1.CnwError('INVALID_BUNDLER', `Invalid bundler "${parsedArgs.bundler}" for Angular. Valid options are: ${validAngularBundlers.join(', ')}`);
|
|
1201
|
+
}
|
|
1156
1202
|
bundler = parsedArgs.bundler;
|
|
1157
1203
|
}
|
|
1158
1204
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nx-workspace",
|
|
3
|
-
"version": "22.7.0-beta.
|
|
3
|
+
"version": "22.7.0-beta.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Smart Monorepos · Fast Builds",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://nx.dev",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"axios": "
|
|
33
|
+
"axios": "1.12.0",
|
|
34
34
|
"chalk": "^4.1.0",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
36
|
"flat": "^5.0.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-empty-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-empty-workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAGL,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,SAAS,sBAAsB,EACzE,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"create-empty-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-empty-workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAGL,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,SAAS,sBAAsB,EACzE,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,MAAM,CAAC,CAgEjB"}
|
|
@@ -27,12 +27,14 @@ async function createEmptyWorkspace(tmpDir, name, packageManager, options) {
|
|
|
27
27
|
// Even though --skipInstall is not an option to create-nx-workspace, we pass through extra options to presets.
|
|
28
28
|
// See: https://github.com/nrwl/nx/issues/31834
|
|
29
29
|
delete options.skipInstall;
|
|
30
|
+
// workingDir is consumed by CNW itself, not passed to `nx new`
|
|
31
|
+
const { workingDir: _workingDir, ...nxNewOptions } = options;
|
|
30
32
|
const args = (0, unparse_1.unparse)({
|
|
31
|
-
...
|
|
33
|
+
...nxNewOptions,
|
|
32
34
|
}).join(' ');
|
|
33
35
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
34
36
|
const command = `new ${args}`;
|
|
35
|
-
const workingDir = process.cwd().replace(/\\/g, '/');
|
|
37
|
+
const workingDir = (options.workingDir ?? process.cwd()).replace(/\\/g, '/');
|
|
36
38
|
let nxWorkspaceRoot = `"${workingDir}"`;
|
|
37
39
|
// If path contains spaces there is a problem in Windows for npm@6.
|
|
38
40
|
// In this case we have to escape the wrapping quotes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-preset.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAGL,cAAc,EACf,MAAM,yBAAyB,CAAC;AAIjC,wBAAsB,YAAY,CAAC,CAAC,SAAS,sBAAsB,EACjE,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,CAAC,EACb,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"create-preset.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAGL,cAAc,EACf,MAAM,yBAAyB,CAAC;AAIjC,wBAAsB,YAAY,CAAC,CAAC,SAAS,sBAAsB,EACjE,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,CAAC,EACb,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CA6Df"}
|
package/src/create-preset.js
CHANGED
|
@@ -6,7 +6,7 @@ const package_manager_1 = require("./utils/package-manager");
|
|
|
6
6
|
const child_process_utils_1 = require("./utils/child-process-utils");
|
|
7
7
|
const unparse_1 = require("./utils/unparse");
|
|
8
8
|
async function createPreset(preset, parsedArgs, packageManager, directory) {
|
|
9
|
-
const { skipGit, commit, nxCloud, ...restArgs } = parsedArgs;
|
|
9
|
+
const { skipGit, commit, nxCloud, workingDir: _workingDir, ...restArgs } = parsedArgs;
|
|
10
10
|
// Delete verbose because it will conflict with the --quiet flag
|
|
11
11
|
if (!restArgs.verbose) {
|
|
12
12
|
delete restArgs.verbose;
|
|
@@ -16,7 +16,7 @@ async function createPreset(preset, parsedArgs, packageManager, directory) {
|
|
|
16
16
|
...restArgs,
|
|
17
17
|
}).join(' ');
|
|
18
18
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
19
|
-
const workingDir = process.cwd().replace(/\\/g, '/');
|
|
19
|
+
const workingDir = (parsedArgs.workingDir ?? process.cwd()).replace(/\\/g, '/');
|
|
20
20
|
let nxWorkspaceRoot = `"${workingDir}"`;
|
|
21
21
|
// If path contains spaces there is a problem in Windows for npm@6.
|
|
22
22
|
// In this case we have to escape the wrapping quotes.
|
|
@@ -3,6 +3,12 @@ import type { CompletionMessageKey } from './utils/nx/messages';
|
|
|
3
3
|
import { PackageManager } from './utils/package-manager';
|
|
4
4
|
export interface CreateWorkspaceOptions {
|
|
5
5
|
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* @description Override the working directory for workspace creation.
|
|
8
|
+
* When set, the workspace is created under this directory instead of process.cwd().
|
|
9
|
+
* Used when the user provides "." or an absolute path as the workspace name.
|
|
10
|
+
*/
|
|
11
|
+
workingDir?: string;
|
|
6
12
|
packageManager: PackageManager;
|
|
7
13
|
nxCloud: NxCloud;
|
|
8
14
|
useGitHub?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace-options.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,yEAOlB,CAAC;AACX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAOjD,CAAC"}
|
|
1
|
+
{"version":3,"file":"create-workspace-options.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,yEAOlB,CAAC;AACX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAOjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAIL,aAAa,EACd,MAAM,iBAAiB,CAAC;AA6BzB,wBAAgB,4BAA4B,IAAI;IAC9C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAEA;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,sBAAsB,EACpE,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,CAAC;;;;;;
|
|
1
|
+
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAIL,aAAa,EACd,MAAM,iBAAiB,CAAC;AA6BzB,wBAAgB,4BAA4B,IAAI;IAC9C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAEA;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,sBAAsB,EACpE,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,CAAC;;;;;;GA+RZ;AAUD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI7D;AASD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
package/src/create-workspace.js
CHANGED
|
@@ -39,7 +39,7 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
39
39
|
if (!options.template.startsWith('nrwl/'))
|
|
40
40
|
throw new Error(`Invalid template. Only templates from the 'nrwl' GitHub org are supported.`);
|
|
41
41
|
const templateUrl = `https://github.com/${options.template}`;
|
|
42
|
-
const workingDir = process.cwd().replace(/\\/g, '/');
|
|
42
|
+
const workingDir = (options.workingDir ?? process.cwd()).replace(/\\/g, '/');
|
|
43
43
|
directory = (0, path_1.join)(workingDir, name);
|
|
44
44
|
const aiMode = (0, ai_output_1.isAiAgent)();
|
|
45
45
|
// Use spinner for human mode, progress logs for AI mode
|
|
@@ -52,7 +52,7 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
52
52
|
workspaceSetupSpinner = ora(`Creating workspace from template`).start();
|
|
53
53
|
}
|
|
54
54
|
try {
|
|
55
|
-
await (0, clone_template_1.cloneTemplate)(templateUrl, name);
|
|
55
|
+
await (0, clone_template_1.cloneTemplate)(templateUrl, name, workingDir);
|
|
56
56
|
// Remove npm lockfile from template since we'll generate the correct one
|
|
57
57
|
const npmLockPath = (0, path_1.join)(directory, 'package-lock.json');
|
|
58
58
|
if ((0, node_fs_1.existsSync)(npmLockPath)) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Error codes for CNW errors.
|
|
3
3
|
* These are used for telemetry and error tracking.
|
|
4
4
|
*/
|
|
5
|
-
export type CnwErrorCode = 'DIRECTORY_EXISTS' | 'INVALID_WORKSPACE_NAME' | 'INVALID_FOLDER_NAME' | 'INVALID_BRANCH_NAME' | 'INVALID_PACKAGE_MANAGER' | 'INVALID_PRESET' | 'INVALID_WORKSPACE_TYPE' | 'INVALID_APP_NAME' | 'PRESET_FAILED' | 'SANDBOX_FAILED' | 'TEMPLATE_CLONE_FAILED' | 'CI_WORKFLOW_FAILED' | 'WORKSPACE_CREATION_FAILED' | 'ANGULAR_PREFIX_INVALID' | 'NETWORK_ERROR' | 'PACKAGE_INSTALL_ERROR' | 'UNKNOWN';
|
|
5
|
+
export type CnwErrorCode = 'DIRECTORY_EXISTS' | 'INVALID_WORKSPACE_NAME' | 'INVALID_FOLDER_NAME' | 'INVALID_BRANCH_NAME' | 'INVALID_PACKAGE_MANAGER' | 'INVALID_PATH' | 'INVALID_PRESET' | 'INVALID_WORKSPACE_TYPE' | 'INVALID_APP_NAME' | 'PRESET_FAILED' | 'SANDBOX_FAILED' | 'TEMPLATE_CLONE_FAILED' | 'CI_WORKFLOW_FAILED' | 'WORKSPACE_CREATION_FAILED' | 'ANGULAR_PREFIX_INVALID' | 'INVALID_BUNDLER' | 'NETWORK_ERROR' | 'PACKAGE_INSTALL_ERROR' | 'UNKNOWN';
|
|
6
6
|
/**
|
|
7
7
|
* Custom error class for CNW errors.
|
|
8
8
|
* Used for structured error reporting and telemetry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/create-nx-workspace/src/utils/error-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,wBAAwB,GACxB,qBAAqB,GACrB,qBAAqB,GACrB,yBAAyB,GACzB,gBAAgB,GAChB,wBAAwB,GACxB,kBAAkB,GAClB,eAAe,GACf,gBAAgB,GAChB,uBAAuB,GACvB,oBAAoB,GACpB,2BAA2B,GAC3B,wBAAwB,GACxB,eAAe,GACf,uBAAuB,GACvB,SAAS,CAAC;AAEd;;;GAGG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,YAAY;aAElB,OAAO,CAAC,EAAE,MAAM;aAChB,QAAQ,CAAC,EAAE,MAAM;gBAHjB,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM;CAKpC;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAEtC,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAC/B,OAAO,EAAE,MAAM;gBAFf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM;CAKzB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CAsB1D"}
|
|
1
|
+
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/create-nx-workspace/src/utils/error-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,wBAAwB,GACxB,qBAAqB,GACrB,qBAAqB,GACrB,yBAAyB,GACzB,cAAc,GACd,gBAAgB,GAChB,wBAAwB,GACxB,kBAAkB,GAClB,eAAe,GACf,gBAAgB,GAChB,uBAAuB,GACvB,oBAAoB,GACpB,2BAA2B,GAC3B,wBAAwB,GACxB,iBAAiB,GACjB,eAAe,GACf,uBAAuB,GACvB,SAAS,CAAC;AAEd;;;GAGG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,YAAY;aAElB,OAAO,CAAC,EAAE,MAAM;aAChB,QAAQ,CAAC,EAAE,MAAM;gBAHjB,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM;CAKpC;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAEtC,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAC/B,OAAO,EAAE,MAAM;gBAFf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM;CAKzB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CAsB1D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function cloneTemplate(templateUrl: string, targetDirectory: string): Promise<void>;
|
|
1
|
+
export declare function cloneTemplate(templateUrl: string, targetDirectory: string, workingDir?: string): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=clone-template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone-template.d.ts","sourceRoot":"","sources":["../../../../../../packages/create-nx-workspace/src/utils/template/clone-template.ts"],"names":[],"mappings":"AAMA,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"clone-template.d.ts","sourceRoot":"","sources":["../../../../../../packages/create-nx-workspace/src/utils/template/clone-template.ts"],"names":[],"mappings":"AAMA,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -6,12 +6,12 @@ const fs_1 = require("fs");
|
|
|
6
6
|
const promises_1 = require("fs/promises");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const error_utils_1 = require("../error-utils");
|
|
9
|
-
async function cloneTemplate(templateUrl, targetDirectory) {
|
|
9
|
+
async function cloneTemplate(templateUrl, targetDirectory, workingDir) {
|
|
10
10
|
if ((0, fs_1.existsSync)(targetDirectory)) {
|
|
11
11
|
throw new error_utils_1.CnwError('DIRECTORY_EXISTS', `The directory '${targetDirectory}' already exists. Choose a different name or remove the existing directory.`);
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
|
-
await (0, child_process_utils_1.execAndWait)(`git clone --depth 1 "${templateUrl}" "${targetDirectory}"`, process.cwd());
|
|
14
|
+
await (0, child_process_utils_1.execAndWait)(`git clone --depth 1 "${templateUrl}" "${targetDirectory}"`, workingDir ?? process.cwd());
|
|
15
15
|
// Ensure clean history
|
|
16
16
|
const gitDir = (0, path_1.join)(targetDirectory, '.git');
|
|
17
17
|
if ((0, fs_1.existsSync)(gitDir)) {
|