fix(core): nextjs-standalone generates package scripts consistent with create-next-app (#21996)
This commit is contained in:
parent
42ad573405
commit
58cfaae951
@ -1706,6 +1706,62 @@ It will show tasks that you can run with Nx.
|
|||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for angular-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"start": "nx serve",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for nextjs-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"dev": "nx dev",
|
||||||
|
"start": "nx start",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for node-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"start": "nx serve",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for nuxt-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"start": "nx serve",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for react-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"start": "nx serve",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for ts-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`@nx/workspace:generateWorkspaceFiles should create package scripts for vue-standalone preset 1`] = `
|
||||||
|
{
|
||||||
|
"build": "nx build",
|
||||||
|
"start": "nx serve",
|
||||||
|
"test": "nx test",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`@nx/workspace:generateWorkspaceFiles should recommend vscode extensions (angular) 1`] = `
|
exports[`@nx/workspace:generateWorkspaceFiles should recommend vscode extensions (angular) 1`] = `
|
||||||
[
|
[
|
||||||
"nrwl.angular-console",
|
"nrwl.angular-console",
|
||||||
|
|||||||
@ -230,4 +230,25 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
|
|||||||
const pnpm = tree.read('/proj/pnpm-workspace.yaml').toString();
|
const pnpm = tree.read('/proj/pnpm-workspace.yaml').toString();
|
||||||
expect(pnpm).toContain('packages/*');
|
expect(pnpm).toContain('packages/*');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
Preset.ReactStandalone,
|
||||||
|
Preset.VueStandalone,
|
||||||
|
Preset.NuxtStandalone,
|
||||||
|
Preset.AngularStandalone,
|
||||||
|
Preset.NodeStandalone,
|
||||||
|
Preset.NextJsStandalone,
|
||||||
|
Preset.TsStandalone,
|
||||||
|
])('should create package scripts for %s preset', async (preset) => {
|
||||||
|
await generateWorkspaceFiles(tree, {
|
||||||
|
name: 'proj',
|
||||||
|
directory: 'proj',
|
||||||
|
preset,
|
||||||
|
defaultBase: 'main',
|
||||||
|
appName: 'demo',
|
||||||
|
isCustomPreset: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(readJson(tree, 'proj/package.json').scripts).toMatchSnapshot();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -58,6 +58,7 @@ function setPresetProperty(tree: Tree, options: NormalizedSchema) {
|
|||||||
return json;
|
return json;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNxJson(
|
function createNxJson(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
{ directory, defaultBase, preset }: NormalizedSchema
|
{ directory, defaultBase, preset }: NormalizedSchema
|
||||||
@ -163,8 +164,7 @@ function addNpmScripts(tree: Tree, options: NormalizedSchema) {
|
|||||||
options.preset === Preset.ReactStandalone ||
|
options.preset === Preset.ReactStandalone ||
|
||||||
options.preset === Preset.VueStandalone ||
|
options.preset === Preset.VueStandalone ||
|
||||||
options.preset === Preset.NuxtStandalone ||
|
options.preset === Preset.NuxtStandalone ||
|
||||||
options.preset === Preset.NodeStandalone ||
|
options.preset === Preset.NodeStandalone
|
||||||
options.preset === Preset.NextJsStandalone
|
|
||||||
) {
|
) {
|
||||||
updateJson(tree, join(options.directory, 'package.json'), (json) => {
|
updateJson(tree, join(options.directory, 'package.json'), (json) => {
|
||||||
Object.assign(json.scripts, {
|
Object.assign(json.scripts, {
|
||||||
@ -175,6 +175,17 @@ function addNpmScripts(tree: Tree, options: NormalizedSchema) {
|
|||||||
return json;
|
return json;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (options.preset === Preset.NextJsStandalone) {
|
||||||
|
updateJson(tree, join(options.directory, 'package.json'), (json) => {
|
||||||
|
Object.assign(json.scripts, {
|
||||||
|
dev: 'nx dev',
|
||||||
|
build: 'nx build',
|
||||||
|
start: 'nx start',
|
||||||
|
test: 'nx test',
|
||||||
|
});
|
||||||
|
return json;
|
||||||
|
});
|
||||||
|
}
|
||||||
if (options.preset === Preset.TsStandalone) {
|
if (options.preset === Preset.TsStandalone) {
|
||||||
updateJson(tree, join(options.directory, 'package.json'), (json) => {
|
updateJson(tree, join(options.directory, 'package.json'), (json) => {
|
||||||
Object.assign(json.scripts, {
|
Object.assign(json.scripts, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user