Skip to content

Commit 5128bb6

Browse files
committed
Fix build
1 parent ca31ed1 commit 5128bb6

File tree

7 files changed

+22
-48
lines changed

7 files changed

+22
-48
lines changed

packages/create-next-stack/src/main/commands/create-next-stack.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import chalk from "chalk"
33
import endent from "endent"
44
import { commandInstance } from "../command-instance"
55
import {
6-
CreateNextStackArgs,
76
CreateNextStackFlags,
87
validateArgs,
98
validateFlags,
@@ -20,7 +19,7 @@ export default class CreateNextStack extends Command {
2019
static args = {
2120
app_name: Args.string({
2221
description: `The name of your app, optionally including a path prefix. Eg.: "my-app" or "path/to/my-app"`,
23-
required: false,
22+
required: true,
2423
}),
2524
}
2625

@@ -40,6 +39,7 @@ export default class CreateNextStack extends Command {
4039

4140
// Package manager:
4241
"package-manager": Flags.string({
42+
required: true,
4343
options: writablePackageManagerOptions,
4444
description: "Sets the preferred package manager. (Required)",
4545
}),
@@ -51,6 +51,7 @@ export default class CreateNextStack extends Command {
5151

5252
// Styling:
5353
styling: Flags.string({
54+
required: true,
5455
options: writableStylingOptions,
5556
description: `Sets the preferred styling method. (Required) <styling-method> = ${writableStylingOptions.join(
5657
"|"
@@ -101,11 +102,7 @@ export default class CreateNextStack extends Command {
101102
commandInstance.set(this)
102103

103104
try {
104-
const { args: weaklyTypedArgs, flags: weaklyTypedFlags } =
105-
await this.parse(CreateNextStack)
106-
107-
const args = weaklyTypedArgs as CreateNextStackArgs
108-
const flags = weaklyTypedFlags as CreateNextStackFlags
105+
const { args, flags } = await this.parse(CreateNextStack)
109106

110107
if (flags.debug) process.env["DEBUG"] = "true"
111108

packages/create-next-stack/src/main/create-next-stack-types.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Config } from "@oclif/core"
22
import CreateNextStack from "./commands/create-next-stack"
3-
import { UnknownObject } from "./helpers/is-unknown-object"
43
import { validateProjectPathInput } from "./helpers/validate-project-path"
54
import { Writable } from "./helpers/writable"
65

@@ -21,11 +20,8 @@ export type CreateNextStackParserOutput = ReturnType<
2120
typeof temporaryWrapperForTypeSafety
2221
>
2322

24-
// Unvalidated Args and Flags types
25-
export type CreateNextStackArgs = UnknownObject // Change to ParserOutput["args"] if it becomes strongly typed in the future. (Currently a normal object with any-values.)
26-
export type CreateNextStackFlags = Partial<
27-
Awaited<CreateNextStackParserOutput>["flags"]
28-
> // Change to CreateNextStackParserOutput["flags"] if it becomes strongly typed in the future. (Currently not a Partial.)
23+
export type CreateNextStackArgs = Awaited<CreateNextStackParserOutput>["args"]
24+
export type CreateNextStackFlags = Awaited<CreateNextStackParserOutput>["flags"]
2925

3026
// Package manager flag:
3127
export const packageManagerOptions = ["pnpm", "yarn", "npm"] as const
@@ -48,22 +44,13 @@ export const writableStylingOptions = stylingOptions as Writable<
4844
>
4945

5046
// Valid Args type and type guard
51-
export type ValidCreateNextStackArgs = CreateNextStackArgs & { appName: string }
5247
export const validateArgs = (
5348
args: CreateNextStackArgs
54-
): args is ValidCreateNextStackArgs => {
55-
if (typeof args["appName"] !== "string") {
56-
throw new TypeError(
57-
'You are required to specify a name for your application. Read about the "appName" argument using --help.'
58-
)
59-
}
60-
61-
const appNameValidationResult = validateProjectPathInput(args["appName"])
62-
49+
): args is CreateNextStackArgs => {
50+
const appNameValidationResult = validateProjectPathInput(args.app_name)
6351
if (typeof appNameValidationResult === "string") {
6452
throw new TypeError("Invalid app name: " + appNameValidationResult)
6553
}
66-
6754
return true
6855
}
6956

@@ -76,16 +63,6 @@ export const validateFlags = (
7663
flags: CreateNextStackFlags
7764
): flags is ValidCreateNextStackFlags => {
7865
// TODO: Define validator using zod.
79-
if (typeof flags["package-manager"] !== "string") {
80-
throw new Error(
81-
'You are required to specify a package manager. Read about the "--package-manager" option using --help.'
82-
)
83-
}
84-
if (typeof flags.styling !== "string") {
85-
throw new Error(
86-
'You are required to specify a styling method. Read about the "--styling" option using --help.'
87-
)
88-
}
8966
if (flags.chakra && flags.styling !== "emotion") {
9067
throw new Error(
9168
"Chakra UI (category: Component library, flag: --chakra) requires Emotion (category: Styling, flag: --styling=emotion)."
@@ -110,6 +87,6 @@ export const validateFlags = (
11087
}
11188

11289
export type ValidCNSInputs = {
113-
args: ValidCreateNextStackArgs
90+
args: CreateNextStackArgs
11491
flags: ValidCreateNextStackFlags
11592
}

packages/create-next-stack/src/main/plugins/create-next-stack/add-content/pages/generate-index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const generateIndexPage = ({ args }: ValidCNSInputs): string => endent`
1111
return (
1212
<>
1313
<Head>
14-
<title>${getProjectNameOfPath(args.appName)}</title>
14+
<title>${getProjectNameOfPath(args.app_name)}</title>
1515
<meta name="description" content="Generated by Create Next Stack." />
1616
</Head>
1717
<LandingPageTemplate />

packages/create-next-stack/src/main/plugins/create-next-stack/add-content/templates/LandingPage/generate-LandingPageTemplate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const generateLandingPageTemplate = (inputs: ValidCNSInputs): string => {
1919
const LandingPageTemplate = () => {
2020
const onConfettiLoad = () => {
2121
const key = "create-next-stack-hasShownConfetti-${encodeURI(
22-
getProjectNameOfPath(inputs.args.appName)
22+
getProjectNameOfPath(inputs.args.app_name)
2323
)}";
2424
const hasShownConfetti = localStorage.getItem(key);
2525
if (hasShownConfetti != null) return;

packages/create-next-stack/src/main/plugins/create-next-stack/add-readme/generate-readme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const generateReadme = async (
1313
const runCommand = runCommandMap[flags["package-manager"]]
1414

1515
return endent`
16-
# ${getProjectNameOfPath(args.appName)}
16+
# ${getProjectNameOfPath(args.app_name)}
1717
1818
🎉 Congratulations, your project was successfully generated with [Create Next Stack](https://www.create-next-stack.com/)!
1919

packages/create-next-stack/src/main/plugins/next.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { makeDirectory, writeFile } from "../helpers/io"
55
import { remove } from "../helpers/remove"
66
import { runCommand } from "../helpers/run-command"
77
import { logDebug } from "../logging"
8-
import { createPlugin, Package } from "../plugin"
8+
import { Package, createPlugin } from "../plugin"
99
import { getNameVersionCombo } from "../setup/packages"
1010
import { generateNextConfig } from "./create-next-stack/add-next-config/generate-next-config"
1111

@@ -62,18 +62,18 @@ export const nextPlugin = createPlugin({
6262

6363
run: async ({ args, flags }) => {
6464
// Make sure directory exists to avoid error from create-next-app
65-
await makeDirectory(args.appName)
65+
await makeDirectory(args.app_name)
6666

6767
logDebug(endent`
68-
Directory created: ${args.appName}
68+
Directory created: ${args.app_name}
6969
7070
To open the project in vscode, run:
7171
72-
${chalk.cyan(`code ${path.resolve(args.appName)}`)}
72+
${chalk.cyan(`code ${path.resolve(args.app_name)}`)}
7373
`)
7474

7575
const createNextAppArgs = [
76-
args.appName,
76+
args.app_name,
7777
"--typescript",
7878
"--eslint",
7979
"--no-experimental-app",
@@ -122,8 +122,8 @@ export const nextPlugin = createPlugin({
122122
// Reset npm_config_user_agent
123123
process.env["npm_config_user_agent"] = oldNpmConfigUserAgent
124124

125-
logDebug("Changing directory to", args.appName)
126-
process.chdir(args.appName)
125+
logDebug("Changing directory to", args.app_name)
126+
process.chdir(args.app_name)
127127
},
128128
},
129129
removeOfficialCNAContent: {

packages/create-next-stack/src/main/setup/print-final-messages.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ export const printFinalMessages = ({ args, flags }: ValidCNSInputs): void => {
1414
logInfo("")
1515
logInfo(
1616
chalk.green(
17-
`Successfully created project ${getProjectNameOfPath(args.appName)}!`
17+
`Successfully created project ${getProjectNameOfPath(args.app_name)}!`
1818
)
1919
)
2020
logInfo("")
2121
logInfo("To get started, run:")
2222
logInfo("")
23-
if (args.appName !== ".") {
24-
logInfo(chalk.cyan(` cd ${args.appName}`))
23+
if (args.app_name !== ".") {
24+
logInfo(chalk.cyan(` cd ${args.app_name}`))
2525
}
2626
logInfo(chalk.cyan(` ${runCommandMap[flags["package-manager"]]} dev`))
2727
logInfo("")

0 commit comments

Comments
 (0)