create-nx-workspace
Advanced tools
Comparing version 0.0.0-pr-29122-4727ac1 to 0.0.0-pr-29156-41ae81c
@@ -24,5 +24,2 @@ import * as yargs from 'yargs'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
linter?: 'none' | 'eslint'; | ||
formatter?: 'none' | 'prettier'; | ||
workspaces?: boolean; | ||
} | ||
@@ -29,0 +26,0 @@ interface AngularArguments extends BaseArguments { |
@@ -11,2 +11,3 @@ "use strict"; | ||
const nx_version_1 = require("../src/utils/nx/nx-version"); | ||
const point_to_tutorial_and_course_1 = require("../src/utils/preset/point-to-tutorial-and-course"); | ||
const decorator_1 = require("./decorator"); | ||
@@ -20,3 +21,2 @@ const get_third_party_preset_1 = require("../src/utils/preset/get-third-party-preset"); | ||
const is_ci_1 = require("../src/utils/ci/is-ci"); | ||
const social_information_1 = require("../src/utils/social-information"); | ||
exports.commandsObject = yargs | ||
@@ -75,11 +75,2 @@ .wrap(yargs.terminalWidth()) | ||
}) | ||
.option('workspaces', { | ||
describe: chalk.dim `Use package manager workspaces.`, | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
.option('formatter', { | ||
describe: chalk.dim `Code formatter to use.`, | ||
type: 'string', | ||
}) | ||
.option('framework', { | ||
@@ -141,6 +132,6 @@ describe: chalk.dim `Framework option to be used with certain stacks.`, | ||
if (parsedArgs.nxCloud && workspaceInfo.nxCloudInfo) { | ||
process.stdout.write(workspaceInfo.nxCloudInfo); | ||
console.log(workspaceInfo.nxCloudInfo); | ||
} | ||
if ((0, preset_1.isKnownPreset)(parsedArgs.preset)) { | ||
(0, social_information_1.printSocialInformation)(); | ||
(0, point_to_tutorial_and_course_1.pointToTutorialAndCourse)(parsedArgs.preset); | ||
} | ||
@@ -323,44 +314,2 @@ else { | ||
} | ||
async function determineFormatterOptions(args) { | ||
if (args.formatter) | ||
return args.formatter; | ||
const reply = await enquirer.prompt([ | ||
{ | ||
name: 'prettier', | ||
message: `Would you like to use Prettier for code formatting?`, | ||
type: 'autocomplete', | ||
choices: [ | ||
{ | ||
name: 'Yes', | ||
}, | ||
{ | ||
name: 'No', | ||
}, | ||
], | ||
initial: 1, | ||
skip: !args.interactive || (0, is_ci_1.isCI)(), | ||
}, | ||
]); | ||
return reply.prettier === 'Yes' ? 'prettier' : 'none'; | ||
} | ||
async function determineLinterOptions(args) { | ||
const reply = await enquirer.prompt([ | ||
{ | ||
name: 'eslint', | ||
message: `Would you like to use ESLint?`, | ||
type: 'autocomplete', | ||
choices: [ | ||
{ | ||
name: 'Yes', | ||
}, | ||
{ | ||
name: 'No', | ||
}, | ||
], | ||
initial: 1, | ||
skip: !args.interactive || (0, is_ci_1.isCI)(), | ||
}, | ||
]); | ||
return reply.eslint === 'Yes' ? 'eslint' : 'none'; | ||
} | ||
async function determineNoneOptions(parsedArgs) { | ||
@@ -370,5 +319,22 @@ if ((!parsedArgs.preset || parsedArgs.preset === preset_1.Preset.TS) && | ||
process.env.NX_ADD_TS_PLUGIN !== 'false') { | ||
const reply = await enquirer.prompt([ | ||
{ | ||
name: 'prettier', | ||
message: `Would you like to use Prettier for code formatting?`, | ||
type: 'autocomplete', | ||
choices: [ | ||
{ | ||
name: 'Yes', | ||
}, | ||
{ | ||
name: 'No', | ||
}, | ||
], | ||
initial: 1, | ||
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(), | ||
}, | ||
]); | ||
return { | ||
preset: preset_1.Preset.TS, | ||
formatter: await determineFormatterOptions(parsedArgs), | ||
formatter: reply.prettier === 'Yes' ? 'prettier' : 'none', | ||
}; | ||
@@ -435,5 +401,2 @@ } | ||
let nextSrcDir = false; | ||
let linter; | ||
let formatter; | ||
const workspaces = parsedArgs.workspaces ?? false; | ||
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.React) { | ||
@@ -452,6 +415,8 @@ preset = parsedArgs.preset; | ||
const framework = await determineReactFramework(parsedArgs); | ||
const isStandalone = workspaces || framework === 'react-native' || framework === 'expo' | ||
? false | ||
: (await determineStandaloneOrMonorepo()) === 'standalone'; | ||
if (isStandalone) { | ||
// React Native and Expo only support integrated monorepos for now. | ||
// TODO(jack): Add standalone support for React Native and Expo. | ||
const workspaceType = framework === 'react-native' || framework === 'expo' | ||
? 'integrated' | ||
: await determineStandaloneOrMonorepo(); | ||
if (workspaceType === 'standalone') { | ||
appName = parsedArgs.name; | ||
@@ -463,3 +428,3 @@ } | ||
if (framework === 'nextjs') { | ||
if (isStandalone) { | ||
if (workspaceType === 'standalone') { | ||
preset = preset_1.Preset.NextJsStandalone; | ||
@@ -472,3 +437,3 @@ } | ||
else if (framework === 'remix') { | ||
if (isStandalone) { | ||
if (workspaceType === 'standalone') { | ||
preset = preset_1.Preset.RemixStandalone; | ||
@@ -487,3 +452,3 @@ } | ||
else { | ||
if (isStandalone) { | ||
if (workspaceType === 'standalone') { | ||
preset = preset_1.Preset.ReactStandalone; | ||
@@ -559,10 +524,2 @@ } | ||
} | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
} | ||
else { | ||
linter = 'eslint'; | ||
formatter = 'prettier'; | ||
} | ||
return { | ||
@@ -576,5 +533,2 @@ preset, | ||
e2eTestRunner, | ||
linter, | ||
formatter, | ||
workspaces, | ||
}; | ||
@@ -581,0 +535,0 @@ } |
{ | ||
"name": "create-nx-workspace", | ||
"version": "0.0.0-pr-29122-4727ac1", | ||
"version": "0.0.0-pr-29156-41ae81c", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
@@ -14,3 +14,2 @@ "use strict"; | ||
const error_utils_1 = require("./utils/error-utils"); | ||
const preset_1 = require("./utils/preset/preset"); | ||
async function createWorkspace(preset, options) { | ||
@@ -22,5 +21,4 @@ const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, useGitHub, } = options; | ||
const tmpDir = await (0, create_sandbox_1.createSandbox)(packageManager); | ||
const workspaceGlobs = getWorkspaceGlobsFromPreset(preset); | ||
// nx new requires a preset currently. We should probably make it optional. | ||
const directory = await (0, create_empty_workspace_1.createEmptyWorkspace)(tmpDir, name, packageManager, { ...options, preset, workspaceGlobs }); | ||
const directory = await (0, create_empty_workspace_1.createEmptyWorkspace)(tmpDir, name, packageManager, { ...options, preset }); | ||
// If the preset is a third-party preset, we need to call createPreset to install it | ||
@@ -70,21 +68,1 @@ // For first-party presets, it will be created by createEmptyWorkspace instead. | ||
} | ||
function getWorkspaceGlobsFromPreset(preset) { | ||
// Should match how apps are created in `packages/workspace/src/generators/preset/preset.ts`. | ||
switch (preset) { | ||
case preset_1.Preset.AngularMonorepo: | ||
case preset_1.Preset.Expo: | ||
case preset_1.Preset.Express: | ||
case preset_1.Preset.Nest: | ||
case preset_1.Preset.NextJs: | ||
case preset_1.Preset.NodeMonorepo: | ||
case preset_1.Preset.Nuxt: | ||
case preset_1.Preset.ReactNative: | ||
case preset_1.Preset.ReactMonorepo: | ||
case preset_1.Preset.RemixMonorepo: | ||
case preset_1.Preset.VueMonorepo: | ||
case preset_1.Preset.WebComponents: | ||
return ['apps/**', 'packages/**']; | ||
default: | ||
return ['packages/**']; | ||
} | ||
} |
@@ -120,2 +120,3 @@ "use strict"; | ||
this.writeOptionalOutputBody(bodyLines); | ||
this.addNewline(); | ||
} | ||
@@ -122,0 +123,0 @@ logSingleLine(message) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111459
67
3018