Unverified Commit a72a9f22 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Prompt for custom import alias and store preferences in CNA (#44872)

parent 37587162
......@@ -484,7 +484,6 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN || secrets.GITHUB_TOKEN }}
NEXT_TEST_CNA: 1
steps:
- run: echo "${{needs.build.outputs.docsChange}}"
......@@ -509,7 +508,7 @@ jobs:
- run: echo "CNA_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --type cna --always-canary --exec echo 'yup')" >> $GITHUB_OUTPUT; echo "EOF" >> $GITHUB_OUTPUT
id: cna-change
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && ls && curl https://install-node.vercel.app/v16 | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} && xvfb-run node run-tests.js test/integration/create-next-app/index.test.ts test/integration/create-next-app/templates.test.ts >> /proc/1/fd/1"
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && ls && curl https://install-node.vercel.app/v16 | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} && NEXT_TEST_CNA=1 xvfb-run node run-tests.js test/integration/create-next-app/index.test.ts test/integration/create-next-app/templates.test.ts >> /proc/1/fd/1"
if: ${{ needs.build.outputs.docsChange == 'nope' && steps.cna-change.outputs.CNA_CHANGE == 'yup' }}
- name: Upload test trace
......
......@@ -36,7 +36,7 @@ non-interactively. See `create-next-app --help`:
Usage: create-next-app <project-directory> [options]
Options:
-V, --version output the version number
-V, --version output the version number
--ts, --typescript
Initialize as a TypeScript project. (default)
......@@ -57,6 +57,10 @@ Options:
Initialize inside a `src/` directory.
--import-alias <alias-to-configure>
Specify import alias to use (default "@/*").
--use-npm
Explicitly tell the CLI to bootstrap the app using npm
......@@ -78,7 +82,11 @@ Options:
In this case, you must specify the path to the example separately:
--example-path foo/bar
-h, --help output usage information
--reset-preferences
Explicitly tell the CLI to reset any stored preferences
-h, --help output usage information
```
### Why use Create Next App?
......
......@@ -37,6 +37,7 @@ export async function createApp({
eslint,
experimentalApp,
srcDir,
importAlias,
}: {
appPath: string
packageManager: PackageManager
......@@ -46,6 +47,7 @@ export async function createApp({
eslint: boolean
experimentalApp: boolean
srcDir: boolean
importAlias: string
}): Promise<void> {
let repoInfo: RepoInfo | undefined
const mode: TemplateMode = typescript ? 'ts' : 'js'
......@@ -222,6 +224,7 @@ export async function createApp({
isOnline,
eslint,
srcDir,
importAlias,
})
}
......
......@@ -2,6 +2,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import chalk from 'chalk'
import Commander from 'commander'
import Conf from 'conf'
import path from 'path'
import prompts from 'prompts'
import checkForUpdate from 'update-check'
......@@ -53,6 +54,13 @@ const program = new Commander.Command(packageJson.name)
`
Initialize inside a \`src/\` directory.
`
)
.option(
'--import-alias <alias-to-configure>',
`
Specify import alias to use (default "@/*").
`
)
.option(
......@@ -86,6 +94,13 @@ const program = new Commander.Command(packageJson.name)
a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).
In this case, you must specify the path to the example separately:
--example-path foo/bar
`
)
.option(
'--reset-preferences',
`
Explicitly tell the CLI to reset any stored preferences
`
)
.allowUnknownOption()
......@@ -98,6 +113,14 @@ const packageManager = !!program.useNpm
: getPkgManager()
async function run(): Promise<void> {
const conf = new Conf({ projectName: 'create-next-app' })
if (program.resetPreferences) {
conf.clear()
console.log(`Preferences reset successfully`)
return
}
if (typeof projectPath === 'string') {
projectPath = projectPath.trim()
}
......@@ -158,12 +181,27 @@ async function run(): Promise<void> {
}
const example = typeof program.example === 'string' && program.example.trim()
const preferences = (conf.get('preferences') || {}) as Record<
string,
boolean | string
>
/**
* If the user does not provide the necessary flags, prompt them for whether
* to use TS or JS.
*/
if (!example) {
const defaults: typeof preferences = {
typescript: true,
eslint: true,
srcDir: false,
importAlias: '@/*',
}
const getPrefOrDefault = (field: string) => {
return typeof preferences[field] === 'undefined'
? defaults[field]
: preferences[field]
}
if (!program.typescript && !program.javascript) {
if (ciInfo.isCI) {
// default to JavaScript in CI as we can't prompt to
......@@ -177,7 +215,7 @@ async function run(): Promise<void> {
type: 'toggle',
name: 'typescript',
message: `Would you like to use ${styledTypeScript} with this project?`,
initial: true,
initial: getPrefOrDefault('typescript'),
active: 'Yes',
inactive: 'No',
},
......@@ -197,6 +235,7 @@ async function run(): Promise<void> {
*/
program.typescript = Boolean(typescript)
program.javascript = !Boolean(typescript)
preferences.typescript = Boolean(typescript)
}
}
......@@ -212,11 +251,12 @@ async function run(): Promise<void> {
type: 'toggle',
name: 'eslint',
message: `Would you like to use ${styledEslint} with this project?`,
initial: true,
initial: getPrefOrDefault('eslint'),
active: 'Yes',
inactive: 'No',
})
program.eslint = Boolean(eslint)
preferences.eslint = Boolean(eslint)
}
}
......@@ -232,11 +272,12 @@ async function run(): Promise<void> {
type: 'toggle',
name: 'srcDir',
message: `Would you like to use ${styledSrcDir} with this project?`,
initial: false,
initial: getPrefOrDefault('srcDir'),
active: 'Yes',
inactive: 'No',
})
program.srcDir = Boolean(srcDir)
preferences.srcDir = Boolean(srcDir)
}
}
......@@ -245,7 +286,7 @@ async function run(): Promise<void> {
!process.argv.includes('--no-experimental-app')
) {
if (ciInfo.isCI) {
program.experimentalAll = false
program.experimentalApp = false
} else {
const styledAppDir = chalk.hex('#007acc')(
'experimental `app/` directory'
......@@ -261,6 +302,36 @@ async function run(): Promise<void> {
program.experimentalApp = Boolean(appDir)
}
}
if (
typeof program.importAlias !== 'string' ||
!program.importAlias.length
) {
console.log({ idk: program.importAlias })
if (ciInfo.isCI) {
program.importAlias = '@/*'
} else {
const styledImportAlias = chalk.hex('#007acc')('import alias')
const { importAlias } = await prompts({
type: 'text',
name: 'importAlias',
message: `What ${styledImportAlias} would you like configured?`,
initial: getPrefOrDefault('importAlias'),
})
if (!/.+\/\*/.test(importAlias)) {
console.error(
`${chalk.red(
'Error:'
)} invalid import alias (${importAlias}), it must follow the pattern <prefix>/*`
)
process.exit(1)
}
program.importAlias = importAlias
preferences.importAlias = importAlias
}
}
}
try {
......@@ -273,6 +344,7 @@ async function run(): Promise<void> {
eslint: program.eslint,
experimentalApp: program.experimentalApp,
srcDir: program.srcDir,
importAlias: program.importAlias,
})
} catch (reason) {
if (!(reason instanceof DownloadError)) {
......@@ -298,8 +370,10 @@ async function run(): Promise<void> {
eslint: program.eslint,
experimentalApp: program.experimentalApp,
srcDir: program.srcDir,
importAlias: program.importAlias,
})
}
conf.set('preferences', preferences)
}
const update = checkForUpdate(packageJson).catch(() => null)
......
......@@ -31,6 +31,7 @@
"@types/async-retry": "1.4.2",
"@types/ci-info": "2.0.0",
"@types/cross-spawn": "6.0.0",
"@types/glob": "7.1.1",
"@types/node": "^12.6.8",
"@types/prompts": "2.0.1",
"@types/rimraf": "3.0.0",
......@@ -41,8 +42,10 @@
"chalk": "2.4.2",
"ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
"commander": "2.20.0",
"conf": "10.2.0",
"cpy": "7.3.0",
"cross-spawn": "6.0.5",
"glob": "8.0.3",
"got": "10.7.0",
"prompts": "2.1.0",
"tar": "4.4.10",
......
import { install } from '../helpers/install'
import cpy from 'cpy'
import globOrig from 'glob'
import os from 'os'
import fs from 'fs'
import path from 'path'
import chalk from 'chalk'
import util from 'util'
import { GetTemplateFileArgs, InstallTemplateArgs } from './types'
const glob = util.promisify(globOrig)
/**
* Get the file path for a given file in a template, e.g. "next.config.js".
*/
......@@ -33,6 +37,7 @@ export const installTemplate = async ({
mode,
eslint,
srcDir,
importAlias,
}: InstallTemplateArgs) => {
console.log(chalk.bold(`Using ${packageManager}.`))
......@@ -97,6 +102,7 @@ export const installTemplate = async ({
await install(root, dependencies, installFlags)
}
/**
* Copy the template files to the target directory.
*/
......@@ -123,6 +129,38 @@ export const installTemplate = async ({
},
})
const tsconfigFile = path.join(
root,
mode === 'js' ? 'jsconfig.json' : 'tsconfig.json'
)
await fs.promises.writeFile(
tsconfigFile,
(await fs.promises.readFile(tsconfigFile, 'utf8'))
.replace(
`"@/*": ["./*"]`,
srcDir ? `"@/*": ["./src/*"]` : `"@/*": ["./*"]`
)
.replace(`"@/*":`, `"${importAlias}":`)
)
// update import alias in any files if not using the default
if (importAlias !== '@/*') {
const files = await glob('**/*', { cwd: root, dot: true })
await Promise.all(
files.map(async (file) => {
const filePath = path.join(root, file)
if ((await fs.promises.stat(filePath)).isFile()) {
await fs.promises.writeFile(
filePath,
(
await fs.promises.readFile(filePath, 'utf8')
).replace(`@/`, `${importAlias.replace(/\*/g, '')}`)
)
}
})
)
}
if (srcDir) {
await fs.promises.mkdir(path.join(root, 'src'), { recursive: true })
await Promise.all(
......@@ -136,16 +174,6 @@ export const installTemplate = async ({
})
})
)
const tsconfigFile = path.join(
root,
mode === 'js' ? 'jsconfig.json' : 'tsconfig.json'
)
await fs.promises.writeFile(
tsconfigFile,
(
await fs.promises.readFile(tsconfigFile, 'utf8')
).replace(`"@/*": ["./*"]`, `"@/*": ["./src/*"]`)
)
}
if (!eslint) {
......
......@@ -19,4 +19,5 @@ export interface InstallTemplateArgs {
mode: TemplateMode
eslint: boolean
srcDir: boolean
importAlias: string
}
......@@ -393,6 +393,7 @@ importers:
'@types/async-retry': 1.4.2
'@types/ci-info': 2.0.0
'@types/cross-spawn': 6.0.0
'@types/glob': 7.1.1
'@types/node': ^12.6.8
'@types/prompts': 2.0.1
'@types/rimraf': 3.0.0
......@@ -403,8 +404,10 @@ importers:
chalk: 2.4.2
ci-info: watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540
commander: 2.20.0
conf: 10.2.0
cpy: 7.3.0
cross-spawn: 6.0.5
glob: 8.0.3
got: 10.7.0
prompts: 2.1.0
tar: 4.4.10
......@@ -414,6 +417,7 @@ importers:
'@types/async-retry': 1.4.2
'@types/ci-info': 2.0.0
'@types/cross-spawn': 6.0.0
'@types/glob': 7.1.1
'@types/node': 12.12.24
'@types/prompts': 2.0.1
'@types/rimraf': 3.0.0
......@@ -424,8 +428,10 @@ importers:
chalk: 2.4.2
ci-info: github.com/watson/ci-info/f43f6a1cefff47fb361c88cf4b943fdbcaafe540
commander: 2.20.0
conf: 10.2.0
cpy: 7.3.0
cross-spawn: 6.0.5
glob: 8.0.3
got: 10.7.0
prompts: 2.1.0
tar: 4.4.10
......@@ -7149,7 +7155,7 @@ packages:
dependencies:
'@types/events': 3.0.0
'@types/minimatch': 3.0.3
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
/@types/graceful-fs/4.1.3:
......@@ -8047,6 +8053,17 @@ packages:
clean-stack: 2.2.0
indent-string: 4.0.0
/ajv-formats/2.1.1_ajv@8.11.0:
resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==}
peerDependencies:
ajv: ^8.0.0
peerDependenciesMeta:
ajv:
optional: true
dependencies:
ajv: 8.11.0
dev: true
/ajv-keywords/3.5.2_ajv@6.12.6:
resolution: {integrity: sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==}
peerDependencies:
......@@ -8513,6 +8530,11 @@ packages:
engines: {node: '>= 4.5.0'}
hasBin: true
/atomically/1.7.0:
resolution: {integrity: sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==}
engines: {node: '>=10.12.0'}
dev: true
/autoprefixer/10.4.4_postcss@8.4.14:
resolution: {integrity: sha512-Tm8JxsB286VweiZ5F0anmbyGiNI3v3wGv3mz9W+cxEDYB/6jbnj6GM9H9mK3wIL8ftgl+C07Lcwb8PG5PCCPzA==}
engines: {node: ^10 || ^12 || >=14}
......@@ -9954,6 +9976,22 @@ packages:
source-map: 0.6.1
dev: true
/conf/10.2.0:
resolution: {integrity: sha512-8fLl9F04EJqjSqH+QjITQfJF8BrOVaYr1jewVgSRAEWePfxT0sku4w2hrGQ60BC/TNLGQ2pgxNlTbWQmMPFvXg==}
engines: {node: '>=12'}
dependencies:
ajv: 8.11.0
ajv-formats: 2.1.1_ajv@8.11.0
atomically: 1.7.0
debounce-fn: 4.0.0
dot-prop: 6.0.1
env-paths: 2.2.1
json-schema-typed: 7.0.3
onetime: 5.1.2
pkg-up: 3.1.0
semver: 7.3.8
dev: true
/conf/5.0.0:
resolution: {integrity: sha512-lRNyt+iRD4plYaOSVTxu1zPWpaH0EOxgFIR1l3mpC/DGZ7XzhoGFMKmbl54LAgXcSu6knqWgOwdINkqm58N85A==}
engines: {node: '>=8'}
......@@ -10788,6 +10826,13 @@ packages:
semver: 5.7.1
dev: true
/debounce-fn/4.0.0:
resolution: {integrity: sha512-8pYCQiL9Xdcg0UPSD3d+0KMlOjp+KGU5EPwYddgzQ7DATsg4fuUDjQtsYLmWjnk2obnNHgV3vE2Y4jejSOJVBQ==}
engines: {node: '>=10'}
dependencies:
mimic-fn: 3.1.0
dev: true
/debug/0.8.1:
resolution: {integrity: sha512-HlXEJm99YsRjLJ8xmuz0Lq8YUwrv7hAJkTEr6/Em3sUlSUNl0UdFA+1SrY4fnykeq1FVkUEUtwRGHs9VvlYbGA==}
peerDependencies:
......@@ -11451,6 +11496,11 @@ packages:
/env-paths/2.2.0:
resolution: {integrity: sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==}
engines: {node: '>=6'}
dev: true
/env-paths/2.2.1:
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
engines: {node: '>=6'}
/envinfo/7.7.4:
resolution: {integrity: sha512-TQXTYFVVwwluWSFis6K2XKxgrD22jEv0FTuLCQI+OjH7rn93+iY0fSSFM5lrSxFY+H1+B0/cvvlamr3UsBivdQ==}
......@@ -13338,6 +13388,17 @@ packages:
once: 1.4.0
path-is-absolute: 1.0.1
/glob/8.0.3:
resolution: {integrity: sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==}
engines: {node: '>=12'}
dependencies:
fs.realpath: 1.0.0
inflight: 1.0.6
inherits: 2.0.4
minimatch: 5.1.0
once: 1.4.0
dev: true
/global-dirs/2.1.0:
resolution: {integrity: sha512-MG6kdOUh/xBnyo9cJFeIKkLEc1AyFq42QTU4XiX51i2NEdxLxLWXIjEjmqKeSuKR7pAZjTqUVoT2b2huxVLgYQ==}
engines: {node: '>=8'}
......@@ -17206,6 +17267,11 @@ packages:
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
engines: {node: '>=6'}
/mimic-fn/3.1.0:
resolution: {integrity: sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ==}
engines: {node: '>=8'}
dev: true
/mimic-response/1.0.1:
resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==}
engines: {node: '>=4'}
......@@ -17608,7 +17674,7 @@ packages:
engines: {node: '>= 6.0.0'}
hasBin: true
dependencies:
env-paths: 2.2.0
env-paths: 2.2.1
glob: 7.2.0
graceful-fs: 4.2.10
mkdirp: 0.5.5
......@@ -17626,7 +17692,7 @@ packages:
engines: {node: '>= 10.12.0'}
hasBin: true
dependencies:
env-paths: 2.2.0
env-paths: 2.2.1
glob: 7.2.0
graceful-fs: 4.2.10
nopt: 5.0.0
......@@ -17643,7 +17709,7 @@ packages:
engines: {node: '>= 10.12.0'}
hasBin: true
dependencies:
env-paths: 2.2.0
env-paths: 2.2.1
glob: 7.2.0
graceful-fs: 4.2.10
make-fetch-happen: 9.1.0
......
......@@ -13,7 +13,7 @@
import execa from 'execa'
import fs from 'fs-extra'
import path from 'path'
import Conf from 'next/dist/compiled/conf'
import { useTempDir } from '../../lib/use-temp-dir'
import {
projectFilesShouldExist,
......@@ -25,8 +25,11 @@ const cli = require.resolve('create-next-app/dist/index.js')
const exampleRepo = 'https://github.com/vercel/next.js/tree/canary'
const examplePath = 'examples/basic-css'
const run = (args: string[], options: execa.Options) =>
execa('node', [cli].concat(args), options)
const run = (args: string[], options: execa.Options) => {
const conf = new Conf({ projectName: 'create-next-app' })
conf.clear()
return execa('node', [cli].concat(args), options)
}
describe('create next app', () => {
if (!process.env.NEXT_TEST_CNA) {
......@@ -48,6 +51,7 @@ describe('create next app', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -72,6 +76,7 @@ describe('create next app', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{ cwd }
)
......@@ -320,6 +325,7 @@ describe('create next app', () => {
'--example',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -355,6 +361,7 @@ describe('create next app', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -388,7 +395,14 @@ describe('create next app', () => {
}
const res = await run(
['.', '--js', '--eslint', '--no-src-dir', '--no-experimental-app'],
[
'.',
'--js',
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
env,
......@@ -407,7 +421,13 @@ describe('create next app', () => {
await useTempDir(async (cwd) => {
const projectName = 'test-project'
const res = await run(
['--js', '--eslint', '--no-src-dir', '--no-experimental-app'],
[
'--js',
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
input: `${projectName}\n`,
......@@ -430,6 +450,7 @@ describe('create next app', () => {
'--use-npm',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -482,6 +503,7 @@ describe('create next app', () => {
'--use-pnpm',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -551,6 +573,7 @@ describe('create next app', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -616,6 +639,7 @@ describe('create next app', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -688,6 +712,7 @@ describe('create next app', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......
......@@ -8,6 +8,7 @@ import { ChildProcess, spawn, SpawnOptions } from 'child_process'
import { existsSync } from 'fs'
import { resolve } from 'path'
import glob from 'glob'
import Conf from 'next/dist/compiled/conf'
import {
getProjectSetting,
......@@ -22,6 +23,9 @@ const cli = require.resolve('create-next-app/dist/index.js')
* Run the built version of `create-next-app` with the given arguments.
*/
export const createNextApp = (args: string[], options?: SpawnOptions) => {
const conf = new Conf({ projectName: 'create-next-app' })
conf.clear()
console.log(`[TEST] $ ${cli} ${args.join(' ')}`, { options })
return spawn('node', [cli].concat(args), {
...options,
......
......@@ -31,7 +31,13 @@ describe('create-next-app templates', () => {
* Start the create-next-app call.
*/
const childProcess = createNextApp(
[projectName, '--eslint', '--no-src-dir', '--no-experimental-app'],
[
projectName,
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{ cwd }
)
/**
......@@ -72,6 +78,7 @@ describe('create-next-app templates', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -88,7 +95,14 @@ describe('create-next-app templates', () => {
await useTempDir(async (cwd) => {
const projectName = 'typescript-test'
const childProcess = createNextApp(
[projectName, '--ts', '--eslint', '--src-dir', '--no-experimental-app'],
[
projectName,
'--ts',
'--eslint',
'--src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
}
......@@ -133,6 +147,7 @@ describe('create-next-app templates', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -149,7 +164,14 @@ describe('create-next-app templates', () => {
await useTempDir(async (cwd) => {
const projectName = 'javascript-test'
const childProcess = createNextApp(
[projectName, '--js', '--eslint', '--src-dir', '--no-experimental-app'],
[
projectName,
'--js',
'--eslint',
'--src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
}
......@@ -184,6 +206,7 @@ describe('create-next-app --experimental-app-dir', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -207,6 +230,7 @@ describe('create-next-app --experimental-app-dir', () => {
'--eslint',
'--no-src-dir',
'--no-experimental-app',
`--import-alias="@/*"`,
],
{
cwd,
......@@ -223,7 +247,14 @@ describe('create-next-app --experimental-app-dir', () => {
await useTempDir(async (cwd) => {
const projectName = 'appdir-test'
const childProcess = createNextApp(
[projectName, '--js', '--experimental-app', '--eslint', '--src-dir'],
[
projectName,
'--js',
'--experimental-app',
'--eslint',
'--src-dir',
'--import-alias="@/*"',
],
{
cwd,
stdio: 'inherit',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment