create-nx-workspace
Advanced tools
Comparing version
@@ -67,1 +67,2 @@ import * as yargs from 'yargs'; | ||
export {}; | ||
//# sourceMappingURL=create-nx-workspace.d.ts.map |
@@ -135,2 +135,3 @@ "use strict"; | ||
.version('version', chalk.dim `Show version`, nx_version_1.nxVersion); | ||
let rawArgs; | ||
async function main(parsedArgs) { | ||
@@ -140,3 +141,3 @@ output_1.output.log({ | ||
}); | ||
const workspaceInfo = await (0, create_workspace_1.createWorkspace)(parsedArgs.preset, parsedArgs); | ||
const workspaceInfo = await (0, create_workspace_1.createWorkspace)(parsedArgs.preset, parsedArgs, rawArgs); | ||
await (0, ab_testing_1.recordStat)({ | ||
@@ -150,2 +151,4 @@ nxVersion: nx_version_1.nxVersion, | ||
parsedArgs.nxCloud, | ||
rawArgs.nxCloud, | ||
workspaceInfo.pushedToVcs, | ||
], | ||
@@ -172,2 +175,3 @@ }); | ||
async function normalizeArgsMiddleware(argv) { | ||
rawArgs = { ...argv }; | ||
output_1.output.log({ | ||
@@ -174,0 +178,0 @@ title: "Let's create a new workspace [https://nx.dev/getting-started/intro]", |
@@ -13,1 +13,2 @@ export declare const yargsDecorator: { | ||
}; | ||
//# sourceMappingURL=decorator.d.ts.map |
#!/usr/bin/env node | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
export declare const bundlerList: string[]; | ||
export type Bundler = (typeof bundlerList)[number]; | ||
//# sourceMappingURL=bundler-list.d.ts.map |
export declare const frameworkList: string[]; | ||
export type Framework = (typeof frameworkList)[number]; | ||
//# sourceMappingURL=framework-list.d.ts.map |
export * from './src/create-workspace'; | ||
export type { CreateWorkspaceOptions } from './src/create-workspace-options'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "create-nx-workspace", | ||
"version": "0.0.0-pr-31634-cb74636", | ||
"version": "0.0.0-pr-31634-e4ae5d9", | ||
"private": false, | ||
@@ -45,5 +45,5 @@ "description": "Smart Repos · Fast Builds", | ||
}, | ||
"types": "./index.d.ts", | ||
"main": "./index.js", | ||
"main": "index.js", | ||
"types": "./src/index.d.ts", | ||
"type": "commonjs" | ||
} |
@@ -12,1 +12,2 @@ import { CreateWorkspaceOptions } from './create-workspace-options'; | ||
export declare function createEmptyWorkspace<T extends CreateWorkspaceOptions>(tmpDir: string, name: string, packageManager: PackageManager, options: T): Promise<string>; | ||
//# sourceMappingURL=create-empty-workspace.d.ts.map |
@@ -47,3 +47,3 @@ "use strict"; | ||
await (0, child_process_utils_1.execAndWait)(fullCommand, tmpDir); | ||
workspaceSetupSpinner.succeed(`Successfully created the workspace: ${directory}.`); | ||
workspaceSetupSpinner.succeed(`Successfully created the workspace: ${directory}`); | ||
} | ||
@@ -50,0 +50,0 @@ catch (e) { |
import { CreateWorkspaceOptions } from './create-workspace-options'; | ||
import { PackageManager } from './utils/package-manager'; | ||
export declare function createPreset<T extends CreateWorkspaceOptions>(preset: string, parsedArgs: T, packageManager: PackageManager, directory: string): Promise<void>; | ||
//# sourceMappingURL=create-preset.d.ts.map |
@@ -10,2 +10,6 @@ "use strict"; | ||
const { skipGit, commit, nxCloud, ...restArgs } = parsedArgs; | ||
// Delete verbose because it will conflict with the --quiet flag | ||
if (!restArgs.verbose) { | ||
delete restArgs.verbose; | ||
} | ||
let args = (0, unparse_1.unparse)({ | ||
@@ -12,0 +16,0 @@ interactive: true, |
@@ -8,1 +8,2 @@ import { PackageManager } from './utils/package-manager'; | ||
export declare function createSandbox(packageManager: PackageManager): Promise<string>; | ||
//# sourceMappingURL=create-sandbox.d.ts.map |
@@ -23,2 +23,12 @@ import { NxCloud } from './utils/nx/nx-cloud'; | ||
skipGit?: boolean; | ||
/** | ||
* @description Skip pushing to GitHub via gh CLI | ||
* @default false | ||
*/ | ||
skipGitHubPush?: boolean; | ||
/** | ||
* @description Enable verbose logging | ||
* @default false | ||
*/ | ||
verbose?: boolean; | ||
commit?: { | ||
@@ -31,1 +41,2 @@ name: string; | ||
} | ||
//# sourceMappingURL=create-workspace-options.d.ts.map |
import { CreateWorkspaceOptions } from './create-workspace-options'; | ||
export declare function createWorkspace<T extends CreateWorkspaceOptions>(preset: string, options: T): Promise<{ | ||
nxCloudInfo: string | undefined; | ||
import { VcsPushStatus } from './utils/git/git'; | ||
export declare function createWorkspace<T extends CreateWorkspaceOptions>(preset: string, options: T, rawArgs?: T): Promise<{ | ||
nxCloudInfo: string; | ||
directory: string; | ||
pushedToVcs: VcsPushStatus; | ||
}>; | ||
export declare function extractConnectUrl(text: string): string | null; | ||
//# sourceMappingURL=create-workspace.d.ts.map |
@@ -15,4 +15,4 @@ "use strict"; | ||
const preset_1 = require("./utils/preset/preset"); | ||
async function createWorkspace(preset, options) { | ||
const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, useGitHub, } = options; | ||
async function createWorkspace(preset, options, rawArgs) { | ||
const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, useGitHub, skipGitHubPush = false, verbose = false, } = options; | ||
if (cliName) { | ||
@@ -39,9 +39,17 @@ output_1.output.setCliName(cliName ?? 'NX'); | ||
} | ||
const { connectCloudUrl, output } = await (0, nx_cloud_1.getOnboardingInfo)(nxCloud, token, directory, useGitHub); | ||
connectUrl = connectCloudUrl; | ||
nxCloudInfo = output; | ||
connectUrl = await (0, nx_cloud_1.createNxCloudOnboardingUrl)(nxCloud, token, directory, useGitHub); | ||
} | ||
let pushedToVcs = git_1.VcsPushStatus.SkippedGit; | ||
if (!skipGit) { | ||
try { | ||
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit, connectUrl }); | ||
// Push to GitHub if commit was made, GitHub push is not skipped, and CI provider is GitHub | ||
if (commit && !skipGitHubPush && nxCloud === 'github') { | ||
pushedToVcs = await (0, git_1.pushToGitHub)(directory, { | ||
skipGitHubPush, | ||
name, | ||
defaultBase, | ||
verbose, | ||
}); | ||
} | ||
} | ||
@@ -60,5 +68,9 @@ catch (e) { | ||
} | ||
if (connectUrl) { | ||
nxCloudInfo = await (0, nx_cloud_1.getNxCloudInfo)(nxCloud, connectUrl, pushedToVcs, rawArgs?.nxCloud); | ||
} | ||
return { | ||
nxCloudInfo, | ||
directory, | ||
pushedToVcs, | ||
}; | ||
@@ -65,0 +77,0 @@ } |
@@ -17,1 +17,2 @@ import * as yargs from 'yargs'; | ||
}>): Promise<PackageManager>; | ||
//# sourceMappingURL=prompts.d.ts.map |
import yargs = require('yargs'); | ||
export declare function withNxCloud<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & { | ||
nxCloud: string | undefined; | ||
nxCloud: string; | ||
}>; | ||
@@ -12,15 +12,20 @@ export declare function withUseGitHub<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & { | ||
export declare function withPackageManager<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & { | ||
packageManager: string | undefined; | ||
packageManager: string; | ||
}>; | ||
export declare function withGitOptions<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & { | ||
defaultBase: string | undefined; | ||
defaultBase: string; | ||
} & { | ||
skipGit: boolean; | ||
} & { | ||
"commit.name": string | undefined; | ||
skipGitHubPush: boolean; | ||
} & { | ||
"commit.email": string | undefined; | ||
verbose: boolean; | ||
} & { | ||
"commit.name": string; | ||
} & { | ||
"commit.email": string; | ||
} & { | ||
"commit.message": string; | ||
}>; | ||
export declare function withOptions<T>(argv: yargs.Argv<T>, ...options: ((argv: yargs.Argv<T>) => yargs.Argv<T>)[]): any; | ||
//# sourceMappingURL=yargs-options.d.ts.map |
@@ -59,2 +59,13 @@ "use strict"; | ||
}) | ||
.option('skipGitHubPush', { | ||
describe: chalk.dim `Skip pushing to GitHub via gh CLI.`, | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
.option('verbose', { | ||
describe: chalk.dim `Enable verbose logging.`, | ||
type: 'boolean', | ||
default: false, | ||
alias: 'v', | ||
}) | ||
.option('commit.name', { | ||
@@ -61,0 +72,0 @@ describe: chalk.dim `Name of the committer.`, |
@@ -9,1 +9,2 @@ /** | ||
}>; | ||
//# sourceMappingURL=child-process-utils.d.ts.map |
export declare function isCI(): boolean; | ||
//# sourceMappingURL=is-ci.d.ts.map |
@@ -6,1 +6,2 @@ import { PackageManager } from '../package-manager'; | ||
}>; | ||
//# sourceMappingURL=setup-ci.d.ts.map |
@@ -8,1 +8,2 @@ export declare class CreateNxWorkspaceError extends Error { | ||
export declare function mapErrorToBodyLines(error: Error): string[]; | ||
//# sourceMappingURL=error-utils.d.ts.map |
export declare function deduceDefaultBase(): string; | ||
//# sourceMappingURL=default-base.d.ts.map |
@@ -1,2 +0,12 @@ | ||
export declare function checkGitVersion(): string | null | undefined; | ||
export declare enum VcsPushStatus { | ||
PushedToVcs = "PushedToVcs", | ||
OptedOutOfPushingToVcs = "OptedOutOfPushingToVcs", | ||
FailedToPushToVcs = "FailedToPushToVcs", | ||
SkippedGit = "SkippedGit" | ||
} | ||
export declare class GitHubPushSkippedError extends Error { | ||
readonly title = "Push your workspace"; | ||
constructor(message: string); | ||
} | ||
export declare function checkGitVersion(): Promise<string | null | undefined>; | ||
export declare function initializeGitRepo(directory: string, options: { | ||
@@ -11,1 +21,8 @@ defaultBase: string; | ||
}): Promise<void>; | ||
export declare function pushToGitHub(directory: string, options: { | ||
skipGitHubPush?: boolean; | ||
name: string; | ||
defaultBase: string; | ||
verbose?: boolean; | ||
}): Promise<VcsPushStatus>; | ||
//# sourceMappingURL=git.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GitHubPushSkippedError = exports.VcsPushStatus = void 0; | ||
exports.checkGitVersion = checkGitVersion; | ||
exports.initializeGitRepo = initializeGitRepo; | ||
const child_process_1 = require("child_process"); | ||
exports.pushToGitHub = pushToGitHub; | ||
const default_base_1 = require("./default-base"); | ||
const output_1 = require("../output"); | ||
function checkGitVersion() { | ||
const child_process_utils_1 = require("../child-process-utils"); | ||
const enquirer = require("enquirer"); | ||
var VcsPushStatus; | ||
(function (VcsPushStatus) { | ||
VcsPushStatus["PushedToVcs"] = "PushedToVcs"; | ||
VcsPushStatus["OptedOutOfPushingToVcs"] = "OptedOutOfPushingToVcs"; | ||
VcsPushStatus["FailedToPushToVcs"] = "FailedToPushToVcs"; | ||
VcsPushStatus["SkippedGit"] = "SkippedGit"; | ||
})(VcsPushStatus || (exports.VcsPushStatus = VcsPushStatus = {})); | ||
class GitHubPushSkippedError extends Error { | ||
constructor(message) { | ||
super(message); | ||
this.title = 'Push your workspace'; | ||
this.name = 'GitHubPushSkippedError'; | ||
} | ||
} | ||
exports.GitHubPushSkippedError = GitHubPushSkippedError; | ||
async function checkGitVersion() { | ||
try { | ||
let gitVersionOutput = (0, child_process_1.execSync)('git --version', { windowsHide: false }) | ||
.toString() | ||
.trim(); | ||
const result = await (0, child_process_utils_1.execAndWait)('git --version', process.cwd()); | ||
const gitVersionOutput = result.stdout.trim(); | ||
return gitVersionOutput.match(/[0-9]+\.[0-9]+\.+[0-9]+/)?.[0]; | ||
@@ -19,43 +36,68 @@ } | ||
} | ||
async function getGitHubUsername(directory) { | ||
const result = await (0, child_process_utils_1.execAndWait)('gh api user --jq .login', directory); | ||
const username = result.stdout.trim(); | ||
if (!username) { | ||
throw new GitHubPushSkippedError('GitHub CLI is not authenticated'); | ||
} | ||
return username; | ||
} | ||
async function getUserRepositories(directory) { | ||
try { | ||
const allRepos = new Set(); | ||
// Get user's personal repos and organizations concurrently | ||
const [userRepos, orgsResult] = await Promise.all([ | ||
(0, child_process_utils_1.execAndWait)('gh repo list --limit 1000 --json nameWithOwner --jq ".[].nameWithOwner"', directory), | ||
(0, child_process_utils_1.execAndWait)('gh api user/orgs --jq ".[].login"', directory), | ||
]); | ||
// Add user's personal repos | ||
userRepos.stdout | ||
.trim() | ||
.split('\n') | ||
.filter((repo) => repo.length > 0) | ||
.forEach((repo) => allRepos.add(repo)); | ||
// Parse organizations | ||
const orgs = orgsResult.stdout | ||
.trim() | ||
.split('\n') | ||
.filter((org) => org.length > 0); | ||
// Get repos from all organizations concurrently | ||
const orgRepoPromises = orgs.map(async (org) => { | ||
try { | ||
const orgRepos = await (0, child_process_utils_1.execAndWait)(`gh repo list ${org} --limit 1000 --json nameWithOwner --jq ".[].nameWithOwner"`, directory); | ||
return orgRepos.stdout | ||
.trim() | ||
.split('\n') | ||
.filter((repo) => repo.length > 0); | ||
} | ||
catch { | ||
// Return empty array if we can't access org repos | ||
return []; | ||
} | ||
}); | ||
const orgRepoResults = await Promise.all(orgRepoPromises); | ||
// Add all org repos to the set | ||
orgRepoResults.flat().forEach((repo) => allRepos.add(repo)); | ||
return allRepos; | ||
} | ||
catch { | ||
// If we can't fetch repos, return empty set to skip validation | ||
return new Set(); | ||
} | ||
} | ||
async function initializeGitRepo(directory, options) { | ||
const execute = (args, ignoreErrorStream = false) => { | ||
const outputStream = 'ignore'; | ||
const errorStream = ignoreErrorStream ? 'ignore' : process.stderr; | ||
const spawnOptions = { | ||
stdio: [process.stdin, outputStream, errorStream], | ||
shell: true, | ||
cwd: directory, | ||
env: { | ||
...process.env, | ||
...(options.commit?.name | ||
? { | ||
GIT_AUTHOR_NAME: options.commit.name, | ||
GIT_COMMITTER_NAME: options.commit.name, | ||
} | ||
: {}), | ||
...(options.commit?.email | ||
? { | ||
GIT_AUTHOR_EMAIL: options.commit.email, | ||
GIT_COMMITTER_EMAIL: options.commit.email, | ||
} | ||
: {}), | ||
}, | ||
windowsHide: false, | ||
}; | ||
return new Promise((resolve, reject) => { | ||
(0, child_process_1.spawn)('git', args, spawnOptions).on('close', (code) => { | ||
if (code === 0) { | ||
resolve(); | ||
} | ||
else { | ||
reject(code); | ||
} | ||
}); | ||
}); | ||
}; | ||
const gitVersion = checkGitVersion(); | ||
// Set git commit environment variables if provided | ||
if (options.commit?.name) { | ||
process.env.GIT_AUTHOR_NAME = options.commit.name; | ||
process.env.GIT_COMMITTER_NAME = options.commit.name; | ||
} | ||
if (options.commit?.email) { | ||
process.env.GIT_AUTHOR_EMAIL = options.commit.email; | ||
process.env.GIT_COMMITTER_EMAIL = options.commit.email; | ||
} | ||
const gitVersion = await checkGitVersion(); | ||
if (!gitVersion) { | ||
return; | ||
} | ||
const insideRepo = await execute(['rev-parse', '--is-inside-work-tree'], true).then(() => true, () => false); | ||
const insideRepo = await (0, child_process_utils_1.execAndWait)('git rev-parse --is-inside-work-tree', directory).then(() => true, () => false); | ||
if (insideRepo) { | ||
@@ -70,9 +112,9 @@ output_1.output.log({ | ||
if (+gitMajor > 2 || (+gitMajor === 2 && +gitMinor >= 28)) { | ||
await execute(['init', '-b', defaultBase]); | ||
await (0, child_process_utils_1.execAndWait)(`git init -b ${defaultBase}`, directory); | ||
} | ||
else { | ||
await execute(['init']); | ||
await execute(['checkout', '-b', defaultBase]); // Git < 2.28 doesn't support -b on git init. | ||
await (0, child_process_utils_1.execAndWait)('git init', directory); | ||
await (0, child_process_utils_1.execAndWait)(`git checkout -b ${defaultBase}`, directory); // Git < 2.28 doesn't support -b on git init. | ||
} | ||
await execute(['add', '.']); | ||
await (0, child_process_utils_1.execAndWait)('git add .', directory); | ||
if (options.commit) { | ||
@@ -89,4 +131,85 @@ let message = `${options.commit.message}` || 'initial commit'; | ||
} | ||
await execute(['commit', `-m "${message}"`]); | ||
await (0, child_process_utils_1.execAndWait)(`git commit -m "${message}"`, directory); | ||
} | ||
} | ||
async function pushToGitHub(directory, options) { | ||
try { | ||
if (process.env['NX_SKIP_GH_PUSH'] === 'true') { | ||
throw new GitHubPushSkippedError('NX_SKIP_GH_PUSH is true so skipping GitHub push.'); | ||
} | ||
const username = await getGitHubUsername(directory); | ||
// First prompt: Ask if they want to push to GitHub | ||
const { push } = await enquirer.prompt([ | ||
{ | ||
name: 'push', | ||
message: 'Would you like to push this workspace to Github?', | ||
type: 'autocomplete', | ||
choices: [{ name: 'Yes' }, { name: 'No' }], | ||
initial: 0, | ||
}, | ||
]); | ||
if (push !== 'Yes') { | ||
return VcsPushStatus.OptedOutOfPushingToVcs; | ||
} | ||
// Preload existing repositories for validation | ||
const existingRepos = await getUserRepositories(directory); | ||
// Create default repository name using the username we already have | ||
const defaultRepo = `${username}/${options.name}`; | ||
// Second prompt: Ask where to create the repository with validation | ||
const { repoName } = await enquirer.prompt([ | ||
{ | ||
name: 'repoName', | ||
message: 'Repository name (format: username/repo-name):', | ||
type: 'input', | ||
initial: defaultRepo, | ||
validate: async (value) => { | ||
if (!value.includes('/')) { | ||
return 'Repository name must be in format: username/repo-name'; | ||
} | ||
if (existingRepos.has(value)) { | ||
return `Repository '${value}' already exists. Please choose a different name.`; | ||
} | ||
return true; | ||
}, | ||
}, | ||
]); | ||
// Create GitHub repository using gh CLI from the workspace directory | ||
// This will automatically add remote origin and push the current branch | ||
await (0, child_process_utils_1.spawnAndWait)('gh', [ | ||
'repo', | ||
'create', | ||
repoName, | ||
'--private', | ||
'--push', | ||
'--source', | ||
directory, | ||
], directory); | ||
// Get the actual repository URL from GitHub CLI (it could be different from github.com) | ||
const repoResult = await (0, child_process_utils_1.execAndWait)('gh repo view --json url -q .url', directory); | ||
const repoUrl = repoResult.stdout.trim(); | ||
output_1.output.success({ | ||
title: `Successfully pushed to GitHub repository: ${repoUrl}`, | ||
}); | ||
return VcsPushStatus.PushedToVcs; | ||
} | ||
catch (e) { | ||
const isVerbose = options.verbose || process.env.NX_VERBOSE_LOGGING === 'true'; | ||
const errorMessage = e instanceof Error ? e.message : String(e); | ||
// Error code 127 means gh wasn't installed | ||
const title = e instanceof GitHubPushSkippedError || e?.code === 127 | ||
? 'Push your workspace to GitHub' | ||
: 'Failed to push workspace to GitHub'; | ||
const createRepoUrl = `https://github.com/new?name=${encodeURIComponent(options.name)}`; | ||
output_1.output.log({ | ||
title, | ||
bodyLines: isVerbose | ||
? [ | ||
`Please create a repo at ${createRepoUrl} and push this workspace`, | ||
'Error details:', | ||
errorMessage, | ||
] | ||
: [`Please create a repo at ${createRepoUrl} and push this workspace`], | ||
}); | ||
return VcsPushStatus.FailedToPushToVcs; | ||
} | ||
} |
@@ -36,1 +36,2 @@ export declare const NxCloudChoices: string[]; | ||
export {}; | ||
//# sourceMappingURL=ab-testing.d.ts.map |
@@ -34,3 +34,3 @@ "use strict"; | ||
], | ||
footer: '\nRemote caching, task distribution and test splitting are provided by Nx Cloud. Read more at https://nx.dev/ci', | ||
footer: '\nSelf-healing CI, remote caching, and task distribution are provided by Nx Cloud: https://nx.dev/nx-cloud', | ||
fallback: { value: 'skip', key: 'setupNxCloud' }, | ||
@@ -37,0 +37,0 @@ }, |
@@ -0,5 +1,6 @@ | ||
import { VcsPushStatus } from '../git/git'; | ||
declare const outputMessages: { | ||
readonly 'create-nx-workspace-success-ci-setup': readonly [{ | ||
readonly code: "ci-setup-visit"; | ||
readonly createMessage: (url: string) => { | ||
readonly createMessage: (url: string | null, pushedToVcs: VcsPushStatus) => { | ||
title: string; | ||
@@ -12,3 +13,3 @@ type: string; | ||
readonly code: "remote-cache-visit"; | ||
readonly createMessage: (url: string) => { | ||
readonly createMessage: (url: string | null, pushedToVcs: VcsPushStatus) => { | ||
title: string; | ||
@@ -23,3 +24,3 @@ type: string; | ||
readonly code: "ci-setup-visit"; | ||
readonly createMessage: (url: string) => { | ||
readonly createMessage: (url: string | null, pushedToVcs: VcsPushStatus) => { | ||
title: string; | ||
@@ -31,3 +32,3 @@ type: string; | ||
readonly code: "remote-cache-visit"; | ||
readonly createMessage: (url: string) => { | ||
readonly createMessage: (url: string | null, pushedToVcs: VcsPushStatus) => { | ||
title: string; | ||
@@ -39,1 +40,2 @@ type: string; | ||
export {}; | ||
//# sourceMappingURL=messages.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getMessageFactory = getMessageFactory; | ||
const git_1 = require("../git/git"); | ||
function getSetupMessage(url, pushedToVcs) { | ||
if (pushedToVcs === git_1.VcsPushStatus.PushedToVcs) { | ||
return url | ||
? `Go to Nx Cloud and finish the setup: ${url}` | ||
: 'Return to Nx Cloud and finish the setup'; | ||
} | ||
// Default case: FailedToPushToVcs | ||
const action = url ? 'go' : 'return'; | ||
const urlSuffix = url ? `: ${url}` : ''; | ||
return `Push your repo, then ${action} to Nx Cloud and finish the setup${urlSuffix}`; | ||
} | ||
const outputMessages = { | ||
@@ -8,7 +20,9 @@ 'create-nx-workspace-success-ci-setup': [ | ||
code: 'ci-setup-visit', | ||
createMessage: (url) => ({ | ||
title: `Your CI setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Finish it by visiting: ${url}`], | ||
}), | ||
createMessage: (url, pushedToVcs) => { | ||
return { | ||
title: `Your CI setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [getSetupMessage(url, pushedToVcs)], | ||
}; | ||
}, | ||
}, | ||
@@ -19,7 +33,12 @@ ], | ||
code: 'remote-cache-visit', | ||
createMessage: (url) => ({ | ||
title: `Your remote cache setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Finish it by visiting: ${url}`], | ||
}), | ||
createMessage: (url, pushedToVcs) => { | ||
return { | ||
title: `Your remote cache is almost complete.`, | ||
type: 'success', | ||
bodyLines: [ | ||
getSetupMessage(url, pushedToVcs), | ||
`You can also set up a remote cache later by running \`nx g @nx/nx-cloud:init\``, | ||
], | ||
}; | ||
}, | ||
}, | ||
@@ -26,0 +45,0 @@ ], |
@@ -0,6 +1,6 @@ | ||
import { VcsPushStatus } from '../git/git'; | ||
export type NxCloud = 'yes' | 'github' | 'gitlab' | 'azure' | 'bitbucket-pipelines' | 'circleci' | 'skip'; | ||
export declare function readNxCloudToken(directory: string): string | undefined; | ||
export declare function getOnboardingInfo(nxCloud: NxCloud, token: string, directory: string, useGitHub?: boolean): Promise<{ | ||
output: string; | ||
connectCloudUrl: string; | ||
}>; | ||
export declare function readNxCloudToken(directory: string): string; | ||
export declare function createNxCloudOnboardingUrl(nxCloud: NxCloud, token: string, directory: string, useGitHub?: boolean): Promise<string>; | ||
export declare function getNxCloudInfo(nxCloud: NxCloud, connectCloudUrl: string, pushedToVcs: VcsPushStatus, rawNxCloud?: NxCloud): Promise<string>; | ||
//# sourceMappingURL=nx-cloud.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readNxCloudToken = readNxCloudToken; | ||
exports.getOnboardingInfo = getOnboardingInfo; | ||
exports.createNxCloudOnboardingUrl = createNxCloudOnboardingUrl; | ||
exports.getNxCloudInfo = getNxCloudInfo; | ||
const output_1 = require("../output"); | ||
@@ -20,3 +21,3 @@ const messages_1 = require("./messages"); | ||
} | ||
async function getOnboardingInfo(nxCloud, token, directory, useGitHub) { | ||
async function createNxCloudOnboardingUrl(nxCloud, token, directory, useGitHub) { | ||
// nx-ignore-next-line | ||
@@ -31,7 +32,13 @@ const { createNxCloudOnboardingURL } = require(require.resolve('nx/src/nx-cloud/utilities/url-shorten', { | ||
: 'create-nx-workspace-success-ci-setup'; | ||
const { code, createMessage } = (0, messages_1.getMessageFactory)(source); | ||
const connectCloudUrl = await createNxCloudOnboardingURL(source, token, useGitHub ?? | ||
const { code } = (0, messages_1.getMessageFactory)(source); | ||
return await createNxCloudOnboardingURL(source, token, useGitHub ?? | ||
(nxCloud === 'yes' || nxCloud === 'github' || nxCloud === 'circleci'), code); | ||
} | ||
async function getNxCloudInfo(nxCloud, connectCloudUrl, pushedToVcs, rawNxCloud) { | ||
const source = nxCloud === 'yes' | ||
? 'create-nx-workspace-success-cache-setup' | ||
: 'create-nx-workspace-success-ci-setup'; | ||
const { createMessage } = (0, messages_1.getMessageFactory)(source); | ||
const out = new output_1.CLIOutput(false); | ||
const message = createMessage(connectCloudUrl); | ||
const message = createMessage(typeof rawNxCloud === 'string' ? null : connectCloudUrl, pushedToVcs); | ||
if (message.type === 'success') { | ||
@@ -43,3 +50,3 @@ out.success(message); | ||
} | ||
return { output: out.getOutput(), connectCloudUrl }; | ||
return out.getOutput(); | ||
} |
export declare const nxVersion: any; | ||
//# sourceMappingURL=nx-version.d.ts.map |
@@ -47,3 +47,3 @@ import * as chalk from 'chalk'; | ||
setCliName(name: string): void; | ||
applyCLIPrefix(color: string | undefined, text: string): string; | ||
applyCLIPrefix(color: string, text: string): string; | ||
addNewline(): void; | ||
@@ -63,1 +63,2 @@ addVerticalSeparator(color?: string): void; | ||
export declare const output: CLIOutput; | ||
//# sourceMappingURL=output.d.ts.map |
@@ -36,1 +36,2 @@ export declare const packageManagerList: readonly ["pnpm", "yarn", "npm", "bun"]; | ||
export declare function detectInvokedPackageManager(): PackageManager; | ||
//# sourceMappingURL=package-manager.d.ts.map |
@@ -10,1 +10,2 @@ /** | ||
export declare function getPackageNameFromThirdPartyPreset(preset?: string): string | undefined; | ||
//# sourceMappingURL=get-third-party-preset.d.ts.map |
@@ -33,1 +33,2 @@ export declare enum Preset { | ||
export declare function isKnownPreset(preset: string): preset is Preset; | ||
//# sourceMappingURL=preset.d.ts.map |
export declare function printSocialInformation(): void; | ||
//# sourceMappingURL=social-information.d.ts.map |
export declare function stringifyCollection(items: string[]): string; | ||
//# sourceMappingURL=string-utils.d.ts.map |
export declare function unparse(options: Object): string[]; | ||
//# sourceMappingURL=unparse.d.ts.map |
@@ -12,1 +12,2 @@ /** | ||
export declare function validateNpmPackage(name: string): ValidateNpmResult; | ||
//# sourceMappingURL=validate-npm-package.d.ts.map |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
144038
25.59%97
49.23%3430
9.34%2
-33.33%25
31.58%