create-nx-workspace 22.7.0-beta.16 → 22.7.0-beta.17
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.
|
@@ -80,5 +80,11 @@ export declare function resolveSpecialFolderName(folderName: string): {
|
|
|
80
80
|
name: string;
|
|
81
81
|
workingDir: string;
|
|
82
82
|
} | null;
|
|
83
|
+
/**
|
|
84
|
+
* Determines the folder name for the new workspace.
|
|
85
|
+
*
|
|
86
|
+
* @visibleForTesting
|
|
87
|
+
*/
|
|
88
|
+
export declare function determineFolder(parsedArgs: yargs.Arguments<Arguments>): Promise<string>;
|
|
83
89
|
export {};
|
|
84
90
|
//# 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;AAyEnE,KAAK,qBAAqB,GACtB,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,eAAe,CAAC;AAEpB,UAAU,aAAc,SAAQ,sBAAsB;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;IAC9D,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,OAAO,CAAC,EAA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QAAQ,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC;CAClD;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,YAAY,GAAG,YAAY,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,UAAU,qBAAsB,SAAQ,aAAa;IACnD,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,KAAK,SAAS,GACV,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,YAAY,GACZ,aAAa,GACb,qBAAqB,CAAC;AAE1B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAiJrB,CAAC;AAigB7B,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQxD;
|
|
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;AAyEnE,KAAK,qBAAqB,GACtB,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,eAAe,CAAC;AAEpB,UAAU,aAAc,SAAQ,sBAAsB;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,O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ject = void 0;
|
|
4
4
|
exports.validateWorkspaceName = validateWorkspaceName;
|
|
5
5
|
exports.resolveSpecialFolderName = resolveSpecialFolderName;
|
|
6
|
+
exports.determineFolder = determineFolder;
|
|
6
7
|
const tslib_1 = require("tslib");
|
|
7
8
|
const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
|
|
8
9
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
@@ -59,7 +60,6 @@ exports.commandsObject = yargs_1.default
|
|
|
59
60
|
})
|
|
60
61
|
.option('preset', {
|
|
61
62
|
// This describe is hard to auto-fix because of the loop in the code.
|
|
62
|
-
// eslint-disable-next-line @nx/workspace/valid-command-object
|
|
63
63
|
describe: chalk_1.default.dim `Customizes the initial content of your workspace. Default presets include: [${Object.values(preset_1.Preset)
|
|
64
64
|
.map((p) => `"${p}"`)
|
|
65
65
|
.join(', ')}]. To build your own see https://nx.dev/extending-nx/recipes/create-preset.`,
|
|
@@ -620,6 +620,10 @@ function validateWorkspaceName(name) {
|
|
|
620
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`);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
+
/** Returns `true` when the folder name refers to the current directory. */
|
|
624
|
+
function isCurrentDirReference(folderName) {
|
|
625
|
+
return folderName === '.' || folderName === './';
|
|
626
|
+
}
|
|
623
627
|
/**
|
|
624
628
|
* Resolves special folder name patterns (`.`, `./`, absolute paths) into a
|
|
625
629
|
* workspace name and a `workingDir` override so that downstream functions
|
|
@@ -631,8 +635,8 @@ function validateWorkspaceName(name) {
|
|
|
631
635
|
* input is a regular name that needs no special handling.
|
|
632
636
|
*/
|
|
633
637
|
function resolveSpecialFolderName(folderName) {
|
|
634
|
-
//
|
|
635
|
-
if (folderName
|
|
638
|
+
// User wants to init in the current directory
|
|
639
|
+
if (isCurrentDirReference(folderName)) {
|
|
636
640
|
const cwd = (0, path_1.resolve)(process.cwd());
|
|
637
641
|
if ((0, fs_1.readdirSync)(cwd).length > 0) {
|
|
638
642
|
throw new error_utils_1.CnwError('DIRECTORY_EXISTS', `The current directory is not empty. Use "nx init" to add Nx to an existing project.`);
|
|
@@ -650,6 +654,11 @@ function resolveSpecialFolderName(folderName) {
|
|
|
650
654
|
}
|
|
651
655
|
return null;
|
|
652
656
|
}
|
|
657
|
+
/**
|
|
658
|
+
* Determines the folder name for the new workspace.
|
|
659
|
+
*
|
|
660
|
+
* @visibleForTesting
|
|
661
|
+
*/
|
|
653
662
|
async function determineFolder(parsedArgs) {
|
|
654
663
|
const rawFolderName = parsedArgs._[0]
|
|
655
664
|
? parsedArgs._[0].toString()
|
|
@@ -662,8 +671,14 @@ async function determineFolder(parsedArgs) {
|
|
|
662
671
|
parsedArgs.workingDir = resolved.workingDir;
|
|
663
672
|
}
|
|
664
673
|
validateWorkspaceName(folderName);
|
|
674
|
+
// When input is "." or "./", resolveSpecialFolderName already validated
|
|
675
|
+
// the directory is empty. The target always "exists" because it IS the
|
|
676
|
+
// current working directory, so skip the existsSync check and default
|
|
677
|
+
// the workspace name to the directory name.
|
|
678
|
+
if (isCurrentDirReference(rawFolderName)) {
|
|
679
|
+
return folderName;
|
|
680
|
+
}
|
|
665
681
|
// If directory exists, either re-prompt (interactive) or error (non-interactive)
|
|
666
|
-
// Check relative to workingDir when set (e.g. absolute path resolved to a different parent)
|
|
667
682
|
const targetDir = resolved?.workingDir
|
|
668
683
|
? (0, path_1.join)(resolved.workingDir, folderName)
|
|
669
684
|
: folderName;
|
|
@@ -679,6 +694,14 @@ async function determineFolder(parsedArgs) {
|
|
|
679
694
|
}
|
|
680
695
|
return folderName;
|
|
681
696
|
}
|
|
697
|
+
// When non-interactive and no name is provided, default to the current
|
|
698
|
+
// directory name instead of prompting.
|
|
699
|
+
if (!parsedArgs.interactive || (0, is_ci_1.isCI)()) {
|
|
700
|
+
const cwd = (0, path_1.resolve)(process.cwd());
|
|
701
|
+
const folderName = (0, path_1.basename)(cwd);
|
|
702
|
+
validateWorkspaceName(folderName);
|
|
703
|
+
return folderName;
|
|
704
|
+
}
|
|
682
705
|
return promptForFolder(parsedArgs);
|
|
683
706
|
}
|
|
684
707
|
async function promptForFolder(parsedArgs) {
|