create-nx-plugin 16.8.0-beta.3 → 16.8.0-beta.5

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.
@@ -2,7 +2,6 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.commandsObject = exports.yargsDecorator = void 0;
5
- const tslib_1 = require("tslib");
6
5
  const chalk = require("chalk");
7
6
  const enquirer = require("enquirer");
8
7
  const yargs = require("yargs");
@@ -26,36 +25,32 @@ exports.yargsDecorator = {
26
25
  'aliases:': `${chalk.blue `aliases`}:`,
27
26
  };
28
27
  const nxVersion = require('../package.json').version;
29
- function determinePluginName(parsedArgs) {
30
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
- if (parsedArgs.pluginName) {
32
- return parsedArgs.pluginName;
33
- }
34
- const results = yield enquirer.prompt([
35
- {
36
- name: 'pluginName',
37
- message: `Plugin name `,
38
- type: 'input',
39
- validate: (s_1) => (s_1.length ? true : 'Plugin name cannot be empty'),
40
- },
41
- ]);
42
- return results.pluginName;
43
- });
28
+ async function determinePluginName(parsedArgs) {
29
+ if (parsedArgs.pluginName) {
30
+ return parsedArgs.pluginName;
31
+ }
32
+ const results = await enquirer.prompt([
33
+ {
34
+ name: 'pluginName',
35
+ message: `Plugin name `,
36
+ type: 'input',
37
+ validate: (s_1) => (s_1.length ? true : 'Plugin name cannot be empty'),
38
+ },
39
+ ]);
40
+ return results.pluginName;
44
41
  }
45
- function determineCreatePackageName(parsedArgs) {
46
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
- if (parsedArgs.createPackageName) {
48
- return parsedArgs.createPackageName;
49
- }
50
- const results = yield enquirer.prompt([
51
- {
52
- name: 'createPackageName',
53
- message: `Create a package which can be used by npx to create a new workspace (Leave blank to not create this package)`,
54
- type: 'input',
55
- },
56
- ]);
57
- return results.createPackageName;
58
- });
42
+ async function determineCreatePackageName(parsedArgs) {
43
+ if (parsedArgs.createPackageName) {
44
+ return parsedArgs.createPackageName;
45
+ }
46
+ const results = await enquirer.prompt([
47
+ {
48
+ name: 'createPackageName',
49
+ message: `Create a package which can be used by npx to create a new workspace (Leave blank to not create this package)`,
50
+ type: 'input',
51
+ },
52
+ ]);
53
+ return results.createPackageName;
59
54
  }
60
55
  exports.commandsObject = yargs
61
56
  .wrap(yargs.terminalWidth())
@@ -74,42 +69,43 @@ exports.commandsObject = yargs
74
69
  .option('createPackageName', {
75
70
  describe: 'Name of the CLI package to create workspace with plugin',
76
71
  type: 'string',
77
- }), yargs_options_1.withNxCloud, yargs_options_1.withCI, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions), (argv) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
78
- yield main(argv).catch((error) => {
72
+ }), yargs_options_1.withNxCloud, yargs_options_1.withCI, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions), async (argv) => {
73
+ await main(argv).catch((error) => {
79
74
  const { version } = require('../package.json');
80
75
  output_1.output.error({
81
76
  title: `Something went wrong! v${version}`,
82
77
  });
83
78
  throw error;
84
79
  });
85
- }), [normalizeArgsMiddleware])
80
+ }, [normalizeArgsMiddleware])
86
81
  .help('help', chalk.dim `Show help`)
87
82
  .updateLocale(exports.yargsDecorator)
88
83
  .version('version', chalk.dim `Show version`, nxVersion);
89
- function main(parsedArgs) {
90
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
91
- const populatedArguments = Object.assign(Object.assign({}, parsedArgs), { name: parsedArgs.pluginName.includes('/')
92
- ? parsedArgs.pluginName.split('/')[1]
93
- : parsedArgs.pluginName });
94
- output_1.output.log({
95
- title: `Creating an Nx v${nxVersion} plugin.`,
96
- bodyLines: [
97
- 'To make sure the command works reliably in all environments, and that the preset is applied correctly,',
98
- `Nx will run "${parsedArgs.packageManager} install" several times. Please wait.`,
99
- ],
100
- });
101
- const workspaceInfo = yield (0, create_nx_workspace_1.createWorkspace)(`@nx/plugin@${nxVersion}`, populatedArguments);
102
- (0, show_nx_warning_1.showNxWarning)(parsedArgs.pluginName);
103
- yield (0, ab_testing_1.recordStat)({
104
- nxVersion,
105
- command: 'create-nx-workspace',
106
- useCloud: parsedArgs.nxCloud,
107
- meta: ab_testing_1.messages.codeOfSelectedPromptMessage('nxCloudCreation'),
108
- });
109
- if (parsedArgs.nxCloud && workspaceInfo.nxCloudInfo) {
110
- (0, nx_cloud_1.printNxCloudSuccessMessage)(workspaceInfo.nxCloudInfo);
111
- }
84
+ async function main(parsedArgs) {
85
+ const populatedArguments = {
86
+ ...parsedArgs,
87
+ name: parsedArgs.pluginName.includes('/')
88
+ ? parsedArgs.pluginName.split('/')[1]
89
+ : parsedArgs.pluginName,
90
+ };
91
+ output_1.output.log({
92
+ title: `Creating an Nx v${nxVersion} plugin.`,
93
+ bodyLines: [
94
+ 'To make sure the command works reliably in all environments, and that the preset is applied correctly,',
95
+ `Nx will run "${parsedArgs.packageManager} install" several times. Please wait.`,
96
+ ],
112
97
  });
98
+ const workspaceInfo = await (0, create_nx_workspace_1.createWorkspace)(`@nx/plugin@${nxVersion}`, populatedArguments);
99
+ (0, show_nx_warning_1.showNxWarning)(parsedArgs.pluginName);
100
+ await (0, ab_testing_1.recordStat)({
101
+ nxVersion,
102
+ command: 'create-nx-workspace',
103
+ useCloud: parsedArgs.nxCloud,
104
+ meta: ab_testing_1.messages.codeOfSelectedPromptMessage('nxCloudCreation'),
105
+ });
106
+ if (parsedArgs.nxCloud && workspaceInfo.nxCloudInfo) {
107
+ (0, nx_cloud_1.printNxCloudSuccessMessage)(workspaceInfo.nxCloudInfo);
108
+ }
113
109
  }
114
110
  /**
115
111
  * This function is used to normalize the arguments passed to the command.
@@ -117,29 +113,27 @@ function main(parsedArgs) {
117
113
  * - normalize the preset.
118
114
  * @param argv user arguments
119
115
  */
120
- function normalizeArgsMiddleware(argv) {
121
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
122
- try {
123
- const pluginName = yield determinePluginName(argv);
124
- const createPackageName = yield determineCreatePackageName(argv);
125
- const packageManager = yield (0, prompts_1.determinePackageManager)(argv);
126
- const defaultBase = yield (0, prompts_1.determineDefaultBase)(argv);
127
- const nxCloud = yield (0, prompts_1.determineNxCloud)(argv);
128
- const ci = yield (0, prompts_1.determineCI)(argv, nxCloud);
129
- Object.assign(argv, {
130
- pluginName,
131
- createPackageName,
132
- nxCloud,
133
- packageManager,
134
- defaultBase,
135
- ci,
136
- });
137
- }
138
- catch (e) {
139
- console.error(e);
140
- process.exit(1);
141
- }
142
- });
116
+ async function normalizeArgsMiddleware(argv) {
117
+ try {
118
+ const pluginName = await determinePluginName(argv);
119
+ const createPackageName = await determineCreatePackageName(argv);
120
+ const packageManager = await (0, prompts_1.determinePackageManager)(argv);
121
+ const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
122
+ const nxCloud = await (0, prompts_1.determineNxCloud)(argv);
123
+ const ci = await (0, prompts_1.determineCI)(argv, nxCloud);
124
+ Object.assign(argv, {
125
+ pluginName,
126
+ createPackageName,
127
+ nxCloud,
128
+ packageManager,
129
+ defaultBase,
130
+ ci,
131
+ });
132
+ }
133
+ catch (e) {
134
+ console.error(e);
135
+ process.exit(1);
136
+ }
143
137
  }
144
138
  // Trigger Yargs
145
139
  exports.commandsObject.argv;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-plugin",
3
- "version": "16.8.0-beta.3",
3
+ "version": "16.8.0-beta.5",
4
4
  "private": false,
5
5
  "description": "This package is used to scaffold a brand-new workspace used to develop an Nx plugin, and sets up a pre-configured plugin with the specified name. The new plugin is created with a default generator, executor, and e2e app.",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "homepage": "https://nx.dev",
31
31
  "dependencies": {
32
32
  "chalk": "^4.1.0",
33
- "create-nx-workspace": "16.8.0-beta.3",
33
+ "create-nx-workspace": "16.8.0-beta.5",
34
34
  "enquirer": "~2.3.6",
35
35
  "tslib": "^2.3.0",
36
36
  "yargs": "^17.6.2"
@@ -40,5 +40,5 @@
40
40
  },
41
41
  "main": "./bin/create-nx-plugin.js",
42
42
  "type": "commonjs",
43
- "gitHead": "dcd48165a485bc8db57a1fb02b96a0772de3b7e9"
43
+ "gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
44
44
  }