Merge pull request #21156 from strapi/chore/change-quickstart-behavior

chore: update quickstart behavior to disable example app
This commit is contained in:
Alexandre BODIN 2024-09-06 09:12:04 +02:00 committed by GitHub
commit 30e866651b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 36 additions and 409 deletions

View File

@ -13,6 +13,7 @@ import { isStderrError } from './types';
import type { Scope } from './types';
import { logger } from './utils/logger';
import { gitIgnore } from './utils/gitignore';
async function createStrapi(scope: Scope) {
const { rootPath } = scope;
@ -30,7 +31,7 @@ async function createApp(scope: Scope) {
const {
rootPath,
useTypescript,
useExampleApp,
useExample,
installDependencies,
isQuickstart,
template,
@ -50,7 +51,7 @@ async function createApp(scope: Scope) {
}
if (!template) {
let templateName = useExampleApp ? 'example' : 'vanilla';
let templateName = useExample ? 'example' : 'vanilla';
if (!useTypescript) {
templateName = `${templateName}-js`;
@ -138,7 +139,13 @@ async function createApp(scope: Scope) {
// Init git
if (gitInit) {
logger.title('git', 'Initializing git repository.');
if (!(await fse.exists(join(rootPath, '.gitignore')))) {
await fse.writeFile(join(rootPath, '.gitignore'), gitIgnore);
}
await tryGitInit(rootPath);
logger.success('Initialized a git repository.');
}

View File

@ -133,6 +133,7 @@ async function run(args: string[]): Promise<void> {
templateBranch: options.templateBranch,
templatePath: options.templatePath,
isQuickstart: options.quickstart,
useExample: false,
runApp: options.quickstart === true && options.run !== false,
strapiVersion: version,
packageJsonStrapi: {
@ -157,13 +158,13 @@ async function run(args: string[]): Promise<void> {
};
if (options.template !== undefined) {
scope.useExampleApp = false;
} else if (options.example === true || options.quickstart) {
scope.useExampleApp = true;
} else if (options.example === false) {
scope.useExampleApp = false;
scope.useExample = false;
} else if (options.example === true) {
scope.useExample = true;
} else if (options.example === false || options.quickstart === true) {
scope.useExample = false;
} else {
scope.useExampleApp = await prompts.example();
scope.useExample = await prompts.example();
}
if (options.javascript === true) {

View File

@ -31,18 +31,18 @@ async function typescript() {
}
async function example() {
const { useExampleApp } = await inquirer.prompt<{
useExampleApp: boolean;
const { useExample } = await inquirer.prompt<{
useExample: boolean;
}>([
{
type: 'confirm',
name: 'useExampleApp',
name: 'useExample',
message: 'Start with an example structure & data?',
default: true,
},
]);
return useExampleApp;
return useExample;
}
async function gitInit() {

View File

@ -61,7 +61,7 @@ export interface Scope {
tmpPath?: string;
packageJsonStrapi?: Record<string, unknown>;
useTypescript?: boolean;
useExampleApp?: boolean;
useExample?: boolean;
gitInit?: boolean;
}

View File

@ -1,3 +1,4 @@
const baseGitIgnore = `
############################
# OS X
############################
@ -129,3 +130,6 @@ dist
build
.strapi-updater.json
.strapi-cloud.json
`;
export const gitIgnore = baseGitIgnore.trim();

View File

@ -12,6 +12,8 @@ function addPackageJsonStrapiMetadata(metadata: Record<string, unknown>, scope:
return _.defaults(metadata, packageJsonStrapi);
}
const boolToString = (value: boolean | undefined) => (value === true).toString();
const getProperties = (scope: Scope, error?: TrackError) => {
const eventProperties = {
error: typeof error === 'string' ? error : error && error.message,
@ -30,11 +32,17 @@ const getProperties = (scope: Scope, error?: TrackError) => {
docker: scope.docker,
useYarn: scope.packageManager === 'yarn',
packageManager: scope.packageManager,
useTypescriptOnServer: scope.useTypescript,
useTypescriptOnAdmin: scope.useTypescript,
/** @deprecated */
useTypescriptOnServer: boolToString(scope.useTypescript),
/** @deprecated */
useTypescriptOnAdmin: boolToString(scope.useTypescript),
useTypescript: boolToString(scope.useTypescript),
isHostedOnStrapiCloud: process.env.STRAPI_HOSTING === 'strapi.cloud',
noRun: (scope.runApp !== true).toString(),
noRun: boolToString(scope.runApp),
projectId: scope.uuid,
useExample: boolToString(scope.useExample),
gitInit: boolToString(scope.gitInit),
installDependencies: boolToString(scope.installDependencies),
};
return {

View File

@ -1,131 +0,0 @@
############################
# OS X
############################
.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*
############################
# Linux
############################
*~
############################
# Windows
############################
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
############################
# Packages
############################
*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid
############################
# Logs and databases
############################
.tmp
*.log
*.sql
*.sqlite
*.sqlite3
############################
# Misc.
############################
*#
ssl
.idea
nbproject
public/uploads/*
!public/uploads/.gitkeep
.tsbuildinfo
.eslintcache
############################
# Node.js
############################
lib-cov
lcov.info
pids
logs
results
node_modules
.node_history
############################
# Package managers
############################
.yarn/*
!.yarn/cache
!.yarn/unplugged
!.yarn/patches
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
yarn-error.log
############################
# Tests
############################
coverage
############################
# Strapi
############################
.env
license.txt
exports
.strapi
dist
build
.strapi-updater.json
.strapi-cloud.json

View File

@ -1,131 +0,0 @@
############################
# OS X
############################
.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*
############################
# Linux
############################
*~
############################
# Windows
############################
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
############################
# Packages
############################
*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid
############################
# Logs and databases
############################
.tmp
*.log
*.sql
*.sqlite
*.sqlite3
############################
# Misc.
############################
*#
ssl
.idea
nbproject
public/uploads/*
!public/uploads/.gitkeep
.tsbuildinfo
.eslintcache
############################
# Node.js
############################
lib-cov
lcov.info
pids
logs
results
node_modules
.node_history
############################
# Package managers
############################
.yarn/*
!.yarn/cache
!.yarn/unplugged
!.yarn/patches
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
yarn-error.log
############################
# Tests
############################
coverage
############################
# Strapi
############################
.env
license.txt
exports
.strapi
dist
build
.strapi-updater.json
.strapi-cloud.json

View File

@ -1,131 +0,0 @@
############################
# OS X
############################
.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*
############################
# Linux
############################
*~
############################
# Windows
############################
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
############################
# Packages
############################
*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid
############################
# Logs and databases
############################
.tmp
*.log
*.sql
*.sqlite
*.sqlite3
############################
# Misc.
############################
*#
ssl
.idea
nbproject
public/uploads/*
!public/uploads/.gitkeep
.tsbuildinfo
.eslintcache
############################
# Node.js
############################
lib-cov
lcov.info
pids
logs
results
node_modules
.node_history
############################
# Package managers
############################
.yarn/*
!.yarn/cache
!.yarn/unplugged
!.yarn/patches
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
yarn-error.log
############################
# Tests
############################
coverage
############################
# Strapi
############################
.env
license.txt
exports
.strapi
dist
build
.strapi-updater.json
.strapi-cloud.json