create-nx-workspace 18.1.0-beta.2 → 18.1.0-beta.3
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.
|
@@ -92,6 +92,10 @@ exports.commandsObject = yargs
|
|
|
92
92
|
.option('ssr', {
|
|
93
93
|
describe: chalk.dim `Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application`,
|
|
94
94
|
type: 'boolean',
|
|
95
|
+
})
|
|
96
|
+
.option('prefix', {
|
|
97
|
+
describe: chalk.dim `Prefix to use for Angular component and directive selectors.`,
|
|
98
|
+
type: 'string',
|
|
95
99
|
}), yargs_options_1.withNxCloud, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions), async function handler(argv) {
|
|
96
100
|
await main(argv).catch((error) => {
|
|
97
101
|
const { version } = require('../package.json');
|
|
@@ -563,6 +567,21 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
563
567
|
let ssr = undefined;
|
|
564
568
|
const standaloneApi = parsedArgs.standaloneApi;
|
|
565
569
|
const routing = parsedArgs.routing;
|
|
570
|
+
const prefix = parsedArgs.prefix;
|
|
571
|
+
if (prefix) {
|
|
572
|
+
// https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/utility/validation.ts#L11-L14
|
|
573
|
+
const htmlSelectorRegex = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
|
|
574
|
+
// validate whether component/directive selectors will be valid with the provided prefix
|
|
575
|
+
if (!htmlSelectorRegex.test(`${prefix}-placeholder`)) {
|
|
576
|
+
output_1.output.error({
|
|
577
|
+
title: `Failed to create a workspace.`,
|
|
578
|
+
bodyLines: [
|
|
579
|
+
`The provided "${prefix}" prefix is invalid. It must be a valid HTML selector.`,
|
|
580
|
+
],
|
|
581
|
+
});
|
|
582
|
+
process.exit(1);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
566
585
|
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.Angular) {
|
|
567
586
|
preset = parsedArgs.preset;
|
|
568
587
|
if (preset === preset_1.Preset.AngularStandalone) {
|
|
@@ -660,6 +679,7 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
660
679
|
e2eTestRunner,
|
|
661
680
|
bundler,
|
|
662
681
|
ssr,
|
|
682
|
+
prefix,
|
|
663
683
|
};
|
|
664
684
|
}
|
|
665
685
|
async function determineNodeOptions(parsedArgs) {
|