create-nx-workspace 19.4.0-beta.1 → 19.4.0-beta.2

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.
@@ -172,27 +172,16 @@ async function normalizeArgsMiddleware(argv) {
172
172
  }
173
173
  const packageManager = await (0, prompts_1.determinePackageManager)(argv);
174
174
  const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
175
- if (process.env.NX_NEW_CLOUD_ONBOARDING === 'true') {
176
- const nxCloud = argv.skipGit === true ? 'skip' : await (0, prompts_1.determineNxCloud)(argv);
177
- const useGitHub = nxCloud === 'skip'
178
- ? undefined
179
- : nxCloud === 'github' ||
180
- (await (0, prompts_1.determineIfGitHubWillBeUsed)(nxCloud));
181
- Object.assign(argv, {
182
- nxCloud,
183
- useGitHub,
184
- packageManager,
185
- defaultBase,
186
- });
187
- }
188
- else {
189
- const nxCloud = await (0, prompts_1.determineNxCloud)(argv);
190
- Object.assign(argv, {
191
- nxCloud,
192
- packageManager,
193
- defaultBase,
194
- });
195
- }
175
+ const nxCloud = argv.skipGit === true ? 'skip' : await (0, prompts_1.determineNxCloud)(argv);
176
+ const useGitHub = nxCloud === 'skip'
177
+ ? undefined
178
+ : nxCloud === 'github' || (await (0, prompts_1.determineIfGitHubWillBeUsed)(nxCloud));
179
+ Object.assign(argv, {
180
+ nxCloud,
181
+ useGitHub,
182
+ packageManager,
183
+ defaultBase,
184
+ });
196
185
  }
197
186
  catch (e) {
198
187
  console.error(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-workspace",
3
- "version": "19.4.0-beta.1",
3
+ "version": "19.4.0-beta.2",
4
4
  "private": false,
5
5
  "description": "Smart Monorepos · Fast CI",
6
6
  "repository": {
@@ -25,16 +25,11 @@ async function createWorkspace(preset, options) {
25
25
  if (thirdPartyPackageName) {
26
26
  await (0, create_preset_1.createPreset)(thirdPartyPackageName, options, packageManager, directory);
27
27
  }
28
- let nxCloudInstallRes;
29
- if (nxCloud !== 'skip') {
30
- nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
31
- if (nxCloud !== 'yes') {
32
- await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
33
- }
34
- }
28
+ let gitSuccess = false;
35
29
  if (!skipGit && commit) {
36
30
  try {
37
31
  await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit });
32
+ gitSuccess = true;
38
33
  }
39
34
  catch (e) {
40
35
  if (e instanceof Error) {
@@ -48,6 +43,16 @@ async function createWorkspace(preset, options) {
48
43
  }
49
44
  }
50
45
  }
46
+ let nxCloudInstallRes;
47
+ if (nxCloud !== 'skip') {
48
+ nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
49
+ if (nxCloud !== 'yes') {
50
+ const nxCIsetupRes = await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
51
+ if (nxCIsetupRes?.code === 0) {
52
+ (0, git_1.commitChanges)(directory, `feat(nx): Generated CI workflow`);
53
+ }
54
+ }
55
+ }
51
56
  return {
52
57
  nxCloudInfo: nxCloudInstallRes?.stdout,
53
58
  directory,
@@ -7,3 +7,4 @@ export declare function initializeGitRepo(directory: string, options: {
7
7
  email: string;
8
8
  };
9
9
  }): Promise<void>;
10
+ export declare function commitChanges(directory: string, message: string): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initializeGitRepo = exports.checkGitVersion = void 0;
3
+ exports.commitChanges = exports.initializeGitRepo = exports.checkGitVersion = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const default_base_1 = require("./default-base");
6
6
  const output_1 = require("../output");
@@ -76,3 +76,20 @@ async function initializeGitRepo(directory, options) {
76
76
  }
77
77
  }
78
78
  exports.initializeGitRepo = initializeGitRepo;
79
+ function commitChanges(directory, message) {
80
+ try {
81
+ (0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe', cwd: directory });
82
+ (0, child_process_1.execSync)('git commit --no-verify -F -', {
83
+ encoding: 'utf8',
84
+ stdio: 'pipe',
85
+ input: message,
86
+ cwd: directory,
87
+ });
88
+ }
89
+ catch (e) {
90
+ console.error(`There was an error committing your Nx Cloud token.\n
91
+ Please commit the changes manually and push to your new repository.\n
92
+ \n${e}`);
93
+ }
94
+ }
95
+ exports.commitChanges = commitChanges;
@@ -10,9 +10,7 @@ async function setupNxCloud(directory, packageManager, nxCloud, useGitHub) {
10
10
  const nxCloudSpinner = ora(`Setting up Nx Cloud`).start();
11
11
  try {
12
12
  const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
13
- const res = await (0, child_process_utils_1.execAndWait)(process.env.NX_NEW_CLOUD_ONBOARDING === 'true'
14
- ? `${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace ${useGitHub ? '--github' : ''} --no-interactive`
15
- : `${pmc.exec} nx g nx:connect-to-nx-cloud --no-interactive --quiet`, directory);
13
+ const res = await (0, child_process_utils_1.execAndWait)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace --directory=${directory} ${useGitHub ? '--github' : ''} --no-interactive`, directory);
16
14
  if (nxCloud !== 'yes') {
17
15
  nxCloudSpinner.succeed('CI workflow with Nx Cloud has been generated successfully');
18
16
  }