@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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCli(argv: Array<string>): Promise<unknown>;
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Command, createOption } from "@commander-js/extra-typings";
|
|
2
|
+
import { packageManagerOption } from "./modules/packageManager.mjs";
|
|
3
|
+
import { logo } from "./logo.mjs";
|
|
4
|
+
import {
|
|
5
|
+
scaffoldTemplate,
|
|
6
|
+
templateCliOption,
|
|
7
|
+
templatePrompt
|
|
8
|
+
} from "./templates/index.mjs";
|
|
9
|
+
import { createDebugger, debugCliOption, initDebug } from "./utils/debug.mjs";
|
|
10
|
+
import { getAbsolutePath, newProjectDirectoryPrompt } from "./directory.mjs";
|
|
11
|
+
import { packageNameCliOption } from "./modules/packageJson.mjs";
|
|
12
|
+
import { ideCliOption } from "./modules/ide.mjs";
|
|
13
|
+
const logger = createDebugger("cli");
|
|
14
|
+
const options = {
|
|
15
|
+
template: templateCliOption,
|
|
16
|
+
packageNameCliOption,
|
|
17
|
+
packageManager: packageManagerOption,
|
|
18
|
+
directory: createOption("--directory <string>", "The directory to use"),
|
|
19
|
+
installDeps: createOption(
|
|
20
|
+
"--install-deps",
|
|
21
|
+
"Install dependencies after scaffolding"
|
|
22
|
+
),
|
|
23
|
+
noInstallDeps: createOption(
|
|
24
|
+
"--no-install-deps",
|
|
25
|
+
"Skip installing dependencies after scaffolding"
|
|
26
|
+
),
|
|
27
|
+
initGit: createOption("--init-git", "Initialise git"),
|
|
28
|
+
noInitGit: createOption("--no-init-git", "Skip initialising git"),
|
|
29
|
+
hideLogo: createOption("--hide-logo", "Hide the Tanstack Start logo"),
|
|
30
|
+
ide: ideCliOption,
|
|
31
|
+
debug: debugCliOption
|
|
32
|
+
};
|
|
33
|
+
const addNewProjectOptions = (command) => {
|
|
34
|
+
return command.addOption(options.template).addOption(options.packageNameCliOption).addOption(options.packageManager).addOption(options.directory).addOption(options.installDeps).addOption(options.noInstallDeps).addOption(options.initGit).addOption(options.noInitGit).addOption(options.hideLogo).addOption(options.ide).addOption(options.debug);
|
|
35
|
+
};
|
|
36
|
+
const program = addNewProjectOptions(
|
|
37
|
+
new Command("create-start").name("create-start").description("Scaffold a Tanstack Start appliaction").command("default", {
|
|
38
|
+
isDefault: true,
|
|
39
|
+
hidden: true
|
|
40
|
+
})
|
|
41
|
+
).action(async (options2) => {
|
|
42
|
+
logger.info("Starting CLI action", { options: options2 });
|
|
43
|
+
initDebug(options2.debug);
|
|
44
|
+
const templateId = options2.template ?? await templatePrompt();
|
|
45
|
+
logger.verbose("Template selected", { templateId });
|
|
46
|
+
const directory = options2.directory ?? await newProjectDirectoryPrompt();
|
|
47
|
+
const targetPath = getAbsolutePath(directory);
|
|
48
|
+
logger.verbose("Target directory resolved", { directory, targetPath });
|
|
49
|
+
logger.info("Starting scaffold process", {
|
|
50
|
+
templateId,
|
|
51
|
+
targetPath,
|
|
52
|
+
packageManager: options2.packageManager,
|
|
53
|
+
installDeps: options2.installDeps,
|
|
54
|
+
packageName: options2.packageName,
|
|
55
|
+
initGit: options2.initGit,
|
|
56
|
+
ide: options2.ide
|
|
57
|
+
});
|
|
58
|
+
await scaffoldTemplate({
|
|
59
|
+
cfg: {
|
|
60
|
+
packageManager: {
|
|
61
|
+
packageManager: options2.packageManager,
|
|
62
|
+
installDeps: options2.installDeps
|
|
63
|
+
},
|
|
64
|
+
packageJson: {
|
|
65
|
+
type: "new",
|
|
66
|
+
name: options2.packageName
|
|
67
|
+
},
|
|
68
|
+
git: {
|
|
69
|
+
setupGit: options2.initGit
|
|
70
|
+
},
|
|
71
|
+
ide: {
|
|
72
|
+
ide: options2.ide
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
targetPath,
|
|
76
|
+
templateId
|
|
77
|
+
});
|
|
78
|
+
logger.info("Scaffold process complete");
|
|
79
|
+
});
|
|
80
|
+
export async function runCli(argv) {
|
|
81
|
+
logger.info("CLI starting", { argv });
|
|
82
|
+
if (!argv.includes("--hide-logo")) {
|
|
83
|
+
logo();
|
|
84
|
+
}
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
logger.verbose("Parsing CLI arguments");
|
|
87
|
+
program.parseAsync(argv).then(resolve).catch((error) => {
|
|
88
|
+
logger.error("CLI execution failed", error);
|
|
89
|
+
reject(error);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const getAbsolutePath: (relativePath: string) => any;
|
|
2
|
+
export declare const newProjectDirectoryCliOption: import("@commander-js/extra-typings").Option<"--directory <string>", undefined, undefined, Promise<string>, false, undefined>;
|
|
3
|
+
export declare const newProjectDirectoryPrompt: () => Promise<string>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { InvalidArgumentError, createOption } from "@commander-js/extra-typings";
|
|
4
|
+
import { input } from "@inquirer/prompts";
|
|
5
|
+
export const getAbsolutePath = (relativePath) => {
|
|
6
|
+
return path.resolve(process.cwd(), relativePath);
|
|
7
|
+
};
|
|
8
|
+
const doesPathExist = async (absolutePath) => {
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(absolutePath);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const isFolderEmpty = async (absolutePath) => {
|
|
17
|
+
try {
|
|
18
|
+
const files = await fs.readdir(absolutePath);
|
|
19
|
+
return files.length === 0;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const DEFAULT_NAME = "my-tanstack-start-app";
|
|
25
|
+
const generateDefaultName = async () => {
|
|
26
|
+
let folderName = DEFAULT_NAME;
|
|
27
|
+
let absolutePath = getAbsolutePath(folderName);
|
|
28
|
+
let pathExists = await doesPathExist(absolutePath);
|
|
29
|
+
let counter = 1;
|
|
30
|
+
while (pathExists) {
|
|
31
|
+
folderName = `${DEFAULT_NAME}-${counter}`;
|
|
32
|
+
absolutePath = getAbsolutePath(folderName);
|
|
33
|
+
pathExists = await doesPathExist(absolutePath);
|
|
34
|
+
counter++;
|
|
35
|
+
}
|
|
36
|
+
return `./${folderName}`;
|
|
37
|
+
};
|
|
38
|
+
const validateDirectory = async (directory) => {
|
|
39
|
+
const absolutePath = getAbsolutePath(directory);
|
|
40
|
+
const pathExists = await doesPathExist(absolutePath);
|
|
41
|
+
if (!pathExists) return true;
|
|
42
|
+
const folderEmpty = await isFolderEmpty(absolutePath);
|
|
43
|
+
if (folderEmpty) return true;
|
|
44
|
+
return "The directory is not empty. New projects can only be scaffolded in empty directories";
|
|
45
|
+
};
|
|
46
|
+
export const newProjectDirectoryCliOption = createOption(
|
|
47
|
+
"--directory <string>",
|
|
48
|
+
"The directory to scaffold your app in"
|
|
49
|
+
).argParser(async (directory) => {
|
|
50
|
+
const validationResult = await validateDirectory(directory);
|
|
51
|
+
if (validationResult === true) return directory;
|
|
52
|
+
throw new InvalidArgumentError(validationResult);
|
|
53
|
+
});
|
|
54
|
+
export const newProjectDirectoryPrompt = async () => {
|
|
55
|
+
return await input({
|
|
56
|
+
message: "Where should the project be created?",
|
|
57
|
+
default: await generateDefaultName(),
|
|
58
|
+
validate: async (path2) => {
|
|
59
|
+
return await validateDirectory(path2);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|