Skip to content

Commit

Permalink
feat: add deployment CLIs
Browse files Browse the repository at this point in the history
  • Loading branch information
selemondev committed Jun 29, 2024
1 parent bad5368 commit 888a2b8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/core/questions/react/createReactQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import eslintPrompt from "./eslint"
import stateManagement from './stateManagement'
import reactQuery from './reactQuery'
import program from '../../program'
import { packageJsonMap } from '../../utils/react/ejsMapConstant'
async function createReactQuestions(): Promise<void> {
try {
options.name = program.args[0] ?? (await createQuestion(projectName)).name;
Expand All @@ -34,7 +35,19 @@ async function createReactQuestions(): Promise<void> {
await createQuestion(packageManager)
}

await createQuestion(deploy);
const VercelCLI = packageJsonMap.get('vercelCLI');

const NetlifyCLI = packageJsonMap.get('netlifyCLI');

const deploymentCLI = await createQuestion(deploy);

options.VercelCLI = deploymentCLI?.deploy === 'vercel' && VercelCLI;

options.NetlifyCLI = deploymentCLI?.deploy === 'netlify' && NetlifyCLI;

options.useVercelCLI = !!options.VercelCLI;

options.useNetlifyCLI = !!options.NetlifyCLI;

await createQuestion(initializeGit);

Expand Down
4 changes: 4 additions & 0 deletions src/core/utils/react/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface Options {
Zustand?: string
Eslint?: string
Vitest?: string
VercelCLI?: string
NetlifyCLI?: string
TanStackReactQuery?: string
name?: string
version?: string
Expand All @@ -22,6 +24,8 @@ export interface Options {
useEslint?: boolean
useEslintTs?: boolean
useRouter?: boolean
useVercelCLI?: boolean
useNetlifyCLI?: boolean
useReactQuery?: boolean
useTailwind?: boolean
useTypeScript?: boolean
Expand Down
19 changes: 18 additions & 1 deletion src/deps/react/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,27 @@ const vitest = {
dev: ['dev', 'dev', 'dev', 'dev']
}

const vercelCLI = {
name: ['vercel'],
version: ["^34.1.7"],
stableVersion: ["^34.1.7"],
dev: ['dev']
}

const netlifyCLI = {
name: ['netlify-cli'],
version: ["^17.30.0"],
stableVersion: ["^17.30.0"],
dev: ['dev']
}

const constantDevDeps = {
name: options.useTypeScript ? typescript.name : javascript.name,
version: options.useTypeScript ? typescript.version : javascript.version,
stableVersion: options.useTypeScript ? typescript.stableVersion : javascript.stableVersion,
dev: options.useTypeScript ? typescript.dev : javascript.dev
}

const constantProDeps = {
name: ['react', 'react-dom'],
version: ['^18.2.0', '^18.2.0'],
Expand All @@ -126,5 +141,7 @@ export {
jotai,
reactHooks,
redux,
router
router,
vercelCLI,
netlifyCLI
}
6 changes: 6 additions & 0 deletions template/react-js/package.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<% if (useVitest) { -%>
<%- Vitest %>
<% } -%>
<% if (useVercelCLI) { -%>
<%- VercelCLI %>
<% } -%>
<% if (useNetlifyCLI) { -%>
<%- NetlifyCLI %>
<% } -%>
"@vitejs/plugin-react": "^4.2.1",
"vite": "^5.0.8"
}
Expand Down
6 changes: 6 additions & 0 deletions template/react-ts/package.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
<% if (useVitest) { -%>
<%- Vitest %>
<% } -%>
<% if (useVercelCLI) { -%>
<%- VercelCLI %>
<% } -%>
<% if (useNetlifyCLI) { -%>
<%- NetlifyCLI %>
<% } -%>
"@vitejs/plugin-react": "^4.2.1",
"vite": "^5.0.8"
}
Expand Down

0 comments on commit 888a2b8

Please sign in to comment.