@tanstack/create-start 1.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/cli-entry.d.ts +1 -0
- package/dist/cli-entry.mjs +5 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +92 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.mjs +7 -0
- package/dist/directory.d.ts +3 -0
- package/dist/directory.mjs +62 -0
- package/dist/index.d.ts +2446 -0
- package/dist/index.mjs +15 -0
- package/dist/logo.d.ts +1 -0
- package/dist/logo.mjs +28 -0
- package/dist/module.d.ts +67 -0
- package/dist/module.mjs +168 -0
- package/dist/modules/core/index.d.ts +1446 -0
- package/dist/modules/core/index.mjs +218 -0
- package/dist/modules/core/template/app/client.tsx +10 -0
- package/dist/modules/core/template/app/router.tsx +18 -0
- package/dist/modules/core/template/app/routes/__root.tsx +50 -0
- package/dist/modules/core/template/app/ssr.tsx +15 -0
- package/dist/modules/core/template/app.config.ts +5 -0
- package/dist/modules/core/template/tsconfig.json +10 -0
- package/dist/modules/git.d.ts +231 -0
- package/dist/modules/git.mjs +114 -0
- package/dist/modules/ide.d.ts +92 -0
- package/dist/modules/ide.mjs +70 -0
- package/dist/modules/packageJson.d.ts +541 -0
- package/dist/modules/packageJson.mjs +153 -0
- package/dist/modules/packageManager.d.ts +139 -0
- package/dist/modules/packageManager.mjs +89 -0
- package/dist/modules/vscode/index.d.ts +33 -0
- package/dist/modules/vscode/index.mjs +35 -0
- package/dist/modules/vscode/template/_dot_vscode/settings.json +11 -0
- package/dist/templates/barebones/index.d.ts +1507 -0
- package/dist/templates/barebones/index.mjs +60 -0
- package/dist/templates/barebones/template/app/routes/index.tsx +11 -0
- package/dist/templates/index.d.ts +13 -0
- package/dist/templates/index.mjs +60 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.mjs +0 -0
- package/dist/utils/debug.d.ts +11 -0
- package/dist/utils/debug.mjs +71 -0
- package/dist/utils/getPackageManager.d.ts +2 -0
- package/dist/utils/getPackageManager.mjs +11 -0
- package/dist/utils/helpers/helperFactory.d.ts +15 -0
- package/dist/utils/helpers/helperFactory.mjs +3 -0
- package/dist/utils/helpers/index.d.ts +51 -0
- package/dist/utils/helpers/index.mjs +227 -0
- package/dist/utils/runCmd.d.ts +1 -0
- package/dist/utils/runCmd.mjs +4 -0
- package/dist/utils/runPackageManagerCommand.d.ts +4 -0
- package/dist/utils/runPackageManagerCommand.mjs +17 -0
- package/dist/utils/spawnCmd.d.ts +1 -0
- package/dist/utils/spawnCmd.mjs +30 -0
- package/dist/utils/validateProjectName.d.ts +8 -0
- package/dist/utils/validateProjectName.mjs +14 -0
- package/index.js +3 -0
- package/package.json +66 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createModule } from "./module.mjs";
|
|
2
|
+
import { ideModule as unstable_ideModule } from "./modules/ide.mjs";
|
|
3
|
+
import { gitModule as unstable_gitModule } from "./modules/git.mjs";
|
|
4
|
+
import { coreModule as unstable_coreModule } from "./modules/core/index.mjs";
|
|
5
|
+
import { packageJsonModule as unstable_packageJsonModule } from "./modules/packageJson.mjs";
|
|
6
|
+
import { packageManagerModule as unstable_packageManagerModule } from "./modules/packageManager.mjs";
|
|
7
|
+
export { createModule as unstable_createModule };
|
|
8
|
+
export { scaffoldTemplate as unstable_scaffoldTemplate } from "./templates/index.mjs";
|
|
9
|
+
export const modules = {
|
|
10
|
+
unstable_ideModule,
|
|
11
|
+
unstable_gitModule,
|
|
12
|
+
unstable_coreModule,
|
|
13
|
+
unstable_packageJsonModule,
|
|
14
|
+
unstable_packageManagerModule
|
|
15
|
+
};
|
package/dist/logo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logo: () => void;
|
package/dist/logo.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import gradient from "gradient-string";
|
|
2
|
+
const LEFT_PADDING = 5;
|
|
3
|
+
export const logo = () => {
|
|
4
|
+
const logoText = `|\u2597\u2584\u2584\u2584\u2596\u2597\u2584\u2596 \u2597\u2596 \u2597\u2596 \u2597\u2584\u2584\u2596\u2597\u2584\u2584\u2584\u2596\u2597\u2584\u2596 \u2597\u2584\u2584\u2596\u2597\u2596 \u2597\u2596
|
|
5
|
+
| \u2588 \u2590\u258C \u2590\u258C\u2590\u259B\u259A\u2596\u2590\u258C\u2590\u258C \u2588 \u2590\u258C \u2590\u258C\u2590\u258C \u2590\u258C\u2597\u259E\u2598
|
|
6
|
+
| \u2588 \u2590\u259B\u2580\u259C\u258C\u2590\u258C \u259D\u259C\u258C \u259D\u2580\u259A\u2596 \u2588 \u2590\u259B\u2580\u259C\u258C\u2590\u258C \u2590\u259B\u259A\u2596
|
|
7
|
+
| \u2588 \u2590\u258C \u2590\u258C\u2590\u258C \u2590\u258C\u2597\u2584\u2584\u259E\u2598 \u2588 \u2590\u258C \u2590\u258C\u259D\u259A\u2584\u2584\u2596\u2590\u258C \u2590\u258C
|
|
8
|
+
`;
|
|
9
|
+
const startText = `| \u2597\u2584\u2584\u2596\u2597\u2584\u2584\u2584\u2596\u2597\u2584\u2596 \u2597\u2584\u2584\u2596\u2597\u2584\u2584\u2584\u2596
|
|
10
|
+
| \u2590\u258C \u2588 \u2590\u258C \u2590\u258C\u2590\u258C \u2590\u258C \u2588
|
|
11
|
+
| \u259D\u2580\u259A\u2596 \u2588 \u2590\u259B\u2580\u259C\u258C\u2590\u259B\u2580\u259A\u2596 \u2588
|
|
12
|
+
| \u2597\u2584\u2584\u259E\u2598 \u2588 \u2590\u258C \u2590\u258C\u2590\u258C \u2590\u258C \u2588
|
|
13
|
+
`;
|
|
14
|
+
const removeLeadngChars = (str) => {
|
|
15
|
+
return str.split("\n").map((line) => line.replace(/^\s*\|/, "")).join("\n");
|
|
16
|
+
};
|
|
17
|
+
const padLeft = (str) => {
|
|
18
|
+
return str.split("\n").map((line) => " ".repeat(LEFT_PADDING) + line).join("\n");
|
|
19
|
+
};
|
|
20
|
+
const logoGradient = gradient(["#00bba6", "#8a5eec"]);
|
|
21
|
+
const startGradient = gradient(["#00bba6", "#00bba6"]);
|
|
22
|
+
const logo2 = logoGradient.multiline(padLeft(removeLeadngChars(logoText)));
|
|
23
|
+
const start = startGradient.multiline(padLeft(removeLeadngChars(startText)));
|
|
24
|
+
console.log();
|
|
25
|
+
console.log(logo2);
|
|
26
|
+
console.log(start);
|
|
27
|
+
console.log();
|
|
28
|
+
};
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ParseReturnType, SafeParseReturnType, ZodType, input, output, z } from 'zod';
|
|
2
|
+
type Schema = ZodType<any, any, any>;
|
|
3
|
+
declare class ModuleBase<TSchema extends Schema> {
|
|
4
|
+
private _baseSchema;
|
|
5
|
+
constructor(baseSchema: TSchema);
|
|
6
|
+
init<TInitSchema extends Schema>(fn: (baseSchema: TSchema) => TInitSchema): InitModule<TSchema, TInitSchema>;
|
|
7
|
+
}
|
|
8
|
+
declare class InitModule<TSchema extends Schema, TInitSchema extends Schema> {
|
|
9
|
+
private _baseSchema;
|
|
10
|
+
private _initSchema;
|
|
11
|
+
constructor(baseSchema: TSchema, initSchema: TInitSchema);
|
|
12
|
+
prompt<TPromptSchema extends Schema>(fn: (initSchema: TInitSchema) => TPromptSchema): PromptModule<TSchema, TInitSchema, TPromptSchema>;
|
|
13
|
+
}
|
|
14
|
+
declare class PromptModule<TSchema extends Schema, TInitSchema extends Schema, TPromptSchema extends Schema> {
|
|
15
|
+
private _baseSchema;
|
|
16
|
+
private _initSchema;
|
|
17
|
+
private _promptSchema;
|
|
18
|
+
constructor(baseSchema: TSchema, initSchema: TInitSchema, promptSchema: TPromptSchema);
|
|
19
|
+
validateAndApply<TApplyFn extends ApplyFn<TPromptSchema>, TValidateFn extends ValidateFn<TPromptSchema>>({ validate, apply, spinnerConfigFn, }: {
|
|
20
|
+
validate?: TValidateFn;
|
|
21
|
+
apply: TApplyFn;
|
|
22
|
+
spinnerConfigFn?: SpinnerConfigFn<TPromptSchema>;
|
|
23
|
+
}): FinalModule<TSchema, TInitSchema, TPromptSchema, TValidateFn, TApplyFn>;
|
|
24
|
+
}
|
|
25
|
+
type ApplyFn<TPromptSchema extends Schema> = (opts: {
|
|
26
|
+
targetPath: string;
|
|
27
|
+
cfg: z.output<TPromptSchema>;
|
|
28
|
+
}) => void | Promise<void>;
|
|
29
|
+
type ValidateFn<TPromptSchema extends Schema> = (opts: {
|
|
30
|
+
targetPath: string;
|
|
31
|
+
cfg: z.output<TPromptSchema>;
|
|
32
|
+
}) => Promise<Array<string>> | Array<string>;
|
|
33
|
+
type SpinnerOptions = {
|
|
34
|
+
success: string;
|
|
35
|
+
error: string;
|
|
36
|
+
inProgress: string;
|
|
37
|
+
};
|
|
38
|
+
type SpinnerConfigFn<TValidateSchema extends Schema> = (cfg: z.infer<TValidateSchema>) => SpinnerOptions | undefined;
|
|
39
|
+
declare class FinalModule<TSchema extends Schema, TInitSchema extends Schema, TPromptSchema extends Schema, TValidateFn extends ValidateFn<TPromptSchema>, TApplyFn extends ApplyFn<TPromptSchema>> {
|
|
40
|
+
_baseSchema: TSchema;
|
|
41
|
+
_initSchema: TInitSchema;
|
|
42
|
+
_promptSchema: TPromptSchema;
|
|
43
|
+
_applyFn: TApplyFn;
|
|
44
|
+
_validateFn: TValidateFn | undefined;
|
|
45
|
+
_spinnerConfigFn: SpinnerConfigFn<TPromptSchema> | undefined;
|
|
46
|
+
constructor(baseSchema: TSchema, initSchema: TInitSchema, promptSchema: TPromptSchema, applyFn: TApplyFn, validateFn?: TValidateFn, spinnerConfigFn?: SpinnerConfigFn<TPromptSchema>);
|
|
47
|
+
init(cfg: input<TInitSchema>): Promise<ParseReturnType<TInitSchema>>;
|
|
48
|
+
initSafe(cfg: input<TInitSchema>): Promise<SafeParseReturnType<input<TInitSchema>, output<TInitSchema>>>;
|
|
49
|
+
prompt(cfg: input<TPromptSchema>): Promise<SafeParseReturnType<input<TPromptSchema>, output<TPromptSchema>>>;
|
|
50
|
+
validate(cfg: input<TPromptSchema>): Promise<SafeParseReturnType<input<TPromptSchema>, output<TPromptSchema>>>;
|
|
51
|
+
apply({ cfg, targetPath, }: {
|
|
52
|
+
cfg: output<TPromptSchema>;
|
|
53
|
+
targetPath: string;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
execute({ cfg, targetPath, type, applyingMessage, }: {
|
|
56
|
+
cfg: input<TSchema>;
|
|
57
|
+
targetPath: string;
|
|
58
|
+
type: 'new-project' | 'update';
|
|
59
|
+
applyingMessage?: string;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export declare function createModule<TSchema extends Schema>(baseSchema: TSchema): ModuleBase<TSchema>;
|
|
63
|
+
export declare const runWithSpinner: ({ spinnerOptions, fn, }: {
|
|
64
|
+
spinnerOptions: SpinnerOptions | undefined;
|
|
65
|
+
fn: () => Promise<void>;
|
|
66
|
+
}) => Promise<void>;
|
|
67
|
+
export {};
|
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import yoctoSpinner from "yocto-spinner";
|
|
2
|
+
import { checkFolderExists, checkFolderIsEmpty } from "./utils/helpers/index.mjs";
|
|
3
|
+
import { createDebugger } from "./utils/debug.mjs";
|
|
4
|
+
const debug = createDebugger("module");
|
|
5
|
+
class ModuleBase {
|
|
6
|
+
_baseSchema;
|
|
7
|
+
constructor(baseSchema) {
|
|
8
|
+
this._baseSchema = baseSchema;
|
|
9
|
+
debug.info("Creating new module");
|
|
10
|
+
}
|
|
11
|
+
init(fn) {
|
|
12
|
+
debug.verbose("Initializing module with schema transformer");
|
|
13
|
+
const schema = fn(this._baseSchema);
|
|
14
|
+
return new InitModule(this._baseSchema, schema);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class InitModule {
|
|
18
|
+
_baseSchema;
|
|
19
|
+
_initSchema;
|
|
20
|
+
constructor(baseSchema, initSchema) {
|
|
21
|
+
this._baseSchema = baseSchema;
|
|
22
|
+
this._initSchema = initSchema;
|
|
23
|
+
debug.verbose("Created init module");
|
|
24
|
+
}
|
|
25
|
+
prompt(fn) {
|
|
26
|
+
debug.verbose("Creating prompt module with schema transformer");
|
|
27
|
+
const schema = fn(this._initSchema);
|
|
28
|
+
return new PromptModule(
|
|
29
|
+
this._baseSchema,
|
|
30
|
+
this._initSchema,
|
|
31
|
+
schema
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class PromptModule {
|
|
36
|
+
_baseSchema;
|
|
37
|
+
_initSchema;
|
|
38
|
+
_promptSchema;
|
|
39
|
+
constructor(baseSchema, initSchema, promptSchema) {
|
|
40
|
+
this._baseSchema = baseSchema;
|
|
41
|
+
this._initSchema = initSchema;
|
|
42
|
+
this._promptSchema = promptSchema;
|
|
43
|
+
debug.verbose("Created prompt module");
|
|
44
|
+
}
|
|
45
|
+
validateAndApply({
|
|
46
|
+
validate,
|
|
47
|
+
apply,
|
|
48
|
+
spinnerConfigFn
|
|
49
|
+
}) {
|
|
50
|
+
debug.verbose("Creating final module with validate and apply functions");
|
|
51
|
+
return new FinalModule(
|
|
52
|
+
this._baseSchema,
|
|
53
|
+
this._initSchema,
|
|
54
|
+
this._promptSchema,
|
|
55
|
+
apply,
|
|
56
|
+
validate,
|
|
57
|
+
spinnerConfigFn
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class FinalModule {
|
|
62
|
+
_baseSchema;
|
|
63
|
+
_initSchema;
|
|
64
|
+
_promptSchema;
|
|
65
|
+
_applyFn;
|
|
66
|
+
_validateFn;
|
|
67
|
+
_spinnerConfigFn;
|
|
68
|
+
constructor(baseSchema, initSchema, promptSchema, applyFn, validateFn, spinnerConfigFn) {
|
|
69
|
+
this._baseSchema = baseSchema;
|
|
70
|
+
this._initSchema = initSchema;
|
|
71
|
+
this._promptSchema = promptSchema;
|
|
72
|
+
this._applyFn = applyFn;
|
|
73
|
+
this._validateFn = validateFn;
|
|
74
|
+
if (spinnerConfigFn) this._spinnerConfigFn = spinnerConfigFn;
|
|
75
|
+
debug.verbose("Created final module");
|
|
76
|
+
}
|
|
77
|
+
async init(cfg) {
|
|
78
|
+
debug.verbose("Running init", { cfg });
|
|
79
|
+
return await this._initSchema.parseAsync(cfg);
|
|
80
|
+
}
|
|
81
|
+
async initSafe(cfg) {
|
|
82
|
+
debug.verbose("Running safe init", { cfg });
|
|
83
|
+
return await this._initSchema.safeParseAsync(cfg);
|
|
84
|
+
}
|
|
85
|
+
async prompt(cfg) {
|
|
86
|
+
debug.verbose("Running prompt", { cfg });
|
|
87
|
+
return await this._promptSchema.parseAsync(cfg);
|
|
88
|
+
}
|
|
89
|
+
async validate(cfg) {
|
|
90
|
+
debug.verbose("Running validate", { cfg });
|
|
91
|
+
return await this._promptSchema.safeParseAsync(cfg);
|
|
92
|
+
}
|
|
93
|
+
async apply({
|
|
94
|
+
cfg,
|
|
95
|
+
targetPath
|
|
96
|
+
}) {
|
|
97
|
+
debug.verbose("Running apply", { cfg, targetPath });
|
|
98
|
+
const spinnerOptions = this._spinnerConfigFn?.(cfg);
|
|
99
|
+
await runWithSpinner({
|
|
100
|
+
fn: async () => {
|
|
101
|
+
return await this._applyFn({ cfg, targetPath });
|
|
102
|
+
},
|
|
103
|
+
spinnerOptions
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async execute({
|
|
107
|
+
cfg,
|
|
108
|
+
targetPath,
|
|
109
|
+
type,
|
|
110
|
+
applyingMessage
|
|
111
|
+
}) {
|
|
112
|
+
debug.info("Executing module", { type, targetPath });
|
|
113
|
+
const targetExists = await checkFolderExists(targetPath);
|
|
114
|
+
const targetIsEmpty = await checkFolderIsEmpty(targetPath);
|
|
115
|
+
debug.verbose("Target directory status", { targetExists, targetIsEmpty });
|
|
116
|
+
if (type === "new-project") {
|
|
117
|
+
if (targetExists && !targetIsEmpty) {
|
|
118
|
+
debug.error("Target directory is not empty for new project");
|
|
119
|
+
console.error("The target folder isn't empty");
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (type === "update") {
|
|
124
|
+
if (!targetExists) {
|
|
125
|
+
debug.error("Target directory does not exist for update");
|
|
126
|
+
console.error("The target folder doesn't exist");
|
|
127
|
+
process.exit(0);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
debug.verbose("Parsing init state");
|
|
131
|
+
const initState = await this._initSchema.parseAsync(cfg);
|
|
132
|
+
debug.verbose("Parsing prompt state");
|
|
133
|
+
const promptState = await this._promptSchema.parseAsync(initState);
|
|
134
|
+
if (applyingMessage) {
|
|
135
|
+
console.log();
|
|
136
|
+
console.log(applyingMessage);
|
|
137
|
+
}
|
|
138
|
+
debug.verbose("Applying module");
|
|
139
|
+
await this.apply({ cfg: promptState, targetPath });
|
|
140
|
+
debug.info("Module execution complete");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export function createModule(baseSchema) {
|
|
144
|
+
return new ModuleBase(baseSchema);
|
|
145
|
+
}
|
|
146
|
+
export const runWithSpinner = async ({
|
|
147
|
+
spinnerOptions,
|
|
148
|
+
fn
|
|
149
|
+
}) => {
|
|
150
|
+
let spinner;
|
|
151
|
+
if (spinnerOptions != void 0) {
|
|
152
|
+
spinner = yoctoSpinner({
|
|
153
|
+
text: spinnerOptions.inProgress
|
|
154
|
+
}).start();
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
await fn();
|
|
158
|
+
if (spinnerOptions) {
|
|
159
|
+
spinner.success(spinnerOptions.success);
|
|
160
|
+
}
|
|
161
|
+
} catch (e) {
|
|
162
|
+
if (spinnerOptions) {
|
|
163
|
+
spinner.error(spinnerOptions.error);
|
|
164
|
+
}
|
|
165
|
+
debug.error("Error in spinner operation", e);
|
|
166
|
+
throw e;
|
|
167
|
+
}
|
|
168
|
+
};
|