create-nx-workspace
Advanced tools
Comparing version 0.0.0-pr-29114-41d0324 to 0.0.0-pr-29122-4727ac1
@@ -24,2 +24,5 @@ import * as yargs from 'yargs'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
linter?: 'none' | 'eslint'; | ||
formatter?: 'none' | 'prettier'; | ||
workspaces?: boolean; | ||
} | ||
@@ -26,0 +29,0 @@ interface AngularArguments extends BaseArguments { |
@@ -73,2 +73,11 @@ "use strict"; | ||
}) | ||
.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', { | ||
@@ -311,2 +320,44 @@ describe: chalk.dim `Framework option to be used with certain stacks.`, | ||
} | ||
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) { | ||
@@ -316,22 +367,5 @@ 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: reply.prettier === 'Yes' ? 'prettier' : 'none', | ||
formatter: await determineFormatterOptions(parsedArgs), | ||
}; | ||
@@ -398,2 +432,5 @@ } | ||
let nextSrcDir = false; | ||
let linter; | ||
let formatter; | ||
const workspaces = parsedArgs.workspaces ?? false; | ||
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.React) { | ||
@@ -412,8 +449,6 @@ preset = parsedArgs.preset; | ||
const framework = await determineReactFramework(parsedArgs); | ||
// 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') { | ||
const isStandalone = workspaces || framework === 'react-native' || framework === 'expo' | ||
? false | ||
: (await determineStandaloneOrMonorepo()) === 'standalone'; | ||
if (isStandalone) { | ||
appName = parsedArgs.name; | ||
@@ -425,3 +460,3 @@ } | ||
if (framework === 'nextjs') { | ||
if (workspaceType === 'standalone') { | ||
if (isStandalone) { | ||
preset = preset_1.Preset.NextJsStandalone; | ||
@@ -434,3 +469,3 @@ } | ||
else if (framework === 'remix') { | ||
if (workspaceType === 'standalone') { | ||
if (isStandalone) { | ||
preset = preset_1.Preset.RemixStandalone; | ||
@@ -449,3 +484,3 @@ } | ||
else { | ||
if (workspaceType === 'standalone') { | ||
if (isStandalone) { | ||
preset = preset_1.Preset.ReactStandalone; | ||
@@ -521,2 +556,10 @@ } | ||
} | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
} | ||
else { | ||
linter = 'eslint'; | ||
formatter = 'prettier'; | ||
} | ||
return { | ||
@@ -530,2 +573,5 @@ preset, | ||
e2eTestRunner, | ||
linter, | ||
formatter, | ||
workspaces, | ||
}; | ||
@@ -532,0 +578,0 @@ } |
{ | ||
"name": "create-nx-workspace", | ||
"version": "0.0.0-pr-29114-41d0324", | ||
"version": "0.0.0-pr-29122-4727ac1", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
@@ -14,2 +14,3 @@ "use strict"; | ||
const error_utils_1 = require("./utils/error-utils"); | ||
const preset_1 = require("./utils/preset/preset"); | ||
async function createWorkspace(preset, options) { | ||
@@ -21,4 +22,5 @@ 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 }); | ||
const directory = await (0, create_empty_workspace_1.createEmptyWorkspace)(tmpDir, name, packageManager, { ...options, preset, workspaceGlobs }); | ||
// If the preset is a third-party preset, we need to call createPreset to install it | ||
@@ -68,1 +70,21 @@ // 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/**']; | ||
} | ||
} |
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
109647
2981