create-stardrive 1.0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/bin/index.js +234 -0
  4. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peltmonger
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
@@ -0,0 +1,45 @@
1
+ # create-stardrive
2
+
3
+ Launchpad to start the Astro Stardrive boilerplate.
4
+
5
+ It helps you getting Stardrive installed and also auto-adjusts some details for better fit.
6
+
7
+ <br />
8
+
9
+ Simply run:
10
+
11
+ ```sh
12
+ npm create stardrive
13
+ ```
14
+
15
+ *or*
16
+
17
+ ```sh
18
+ pnpm create stardrive
19
+ ```
20
+
21
+ *or*
22
+
23
+ ```sh
24
+ yarn create stardrive
25
+ ```
26
+
27
+ *or*
28
+
29
+ ```sh
30
+ bun create stardrive
31
+ ```
32
+
33
+ <br />
34
+
35
+ > [!TIP]
36
+ > Use the flag `--no-install` to skip the dependency install.
37
+ > Use the flag `--version X.X.X` to use a specific version.
38
+
39
+ <br />
40
+
41
+ Alternatively, you can also always simply fork/clone the original repository at [github.com/Peltmonger/stardrive](https://github.com/Peltmonger/stardrive).
42
+
43
+ For every following step, please also consult the original repository!
44
+
45
+ **Happy launching!** 🚀
package/bin/index.js ADDED
@@ -0,0 +1,234 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import os from "node:os";
6
+ import { execSync, spawnSync } from "node:child_process";
7
+
8
+ const args = process.argv.slice(2);
9
+
10
+ const skipInstall = args.includes("--no-install");
11
+
12
+ function parseFlag(name) {
13
+ const eqIndex = args.findIndex((a) => a.startsWith(`${name}=`));
14
+
15
+ if (eqIndex !== -1) {
16
+ return args[eqIndex].slice(name.length + 1);
17
+ }
18
+
19
+ const i = args.indexOf(name);
20
+
21
+ if (i !== -1 && args[i + 1] && !args[i + 1].startsWith("-")) {
22
+ return args[i + 1];
23
+ }
24
+
25
+ return undefined;
26
+ }
27
+
28
+ const requestedVersion = parseFlag("--version") || parseFlag("-v");
29
+
30
+ const positional = args.filter((a, i) => {
31
+ if (a.startsWith("-")) return false;
32
+ const prev = args[i - 1];
33
+ if (prev === "--version" || prev === "-v") return false;
34
+ return true;
35
+ });
36
+
37
+ const projectName = positional[0] || "my-stardrive";
38
+ const targetDir = path.resolve(projectName);
39
+
40
+ function detectPackageManager() {
41
+ const ua = process.env.npm_config_user_agent || "";
42
+
43
+ if (ua.startsWith("pnpm")) return "pnpm";
44
+ if (ua.startsWith("yarn")) return "yarn";
45
+ if (ua.startsWith("bun")) return "bun";
46
+
47
+ return "npm";
48
+ }
49
+
50
+ function commandExists(cmd) {
51
+ return spawnSync(cmd, ["--version"], {
52
+ stdio: "ignore",
53
+ }).status === 0;
54
+ }
55
+
56
+ const pm = detectPackageManager();
57
+
58
+ if (!commandExists(pm)) {
59
+ console.error(`${pm} is not installed`);
60
+ process.exit(1);
61
+ }
62
+
63
+ if (fs.existsSync(targetDir)) {
64
+ console.error(`Directory "${projectName}" already exists`);
65
+ process.exit(1);
66
+ }
67
+
68
+ //
69
+ // Download template repo
70
+ //
71
+
72
+ const repo = "https://github.com/Peltmonger/stardrive.git";
73
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "create-app-"));
74
+
75
+ function normalizeTag(tag) {
76
+ return tag.startsWith("v") ? tag : `v${tag}`;
77
+ }
78
+
79
+ function compareSemver(a, b) {
80
+ const pa = a.replace(/^v/, "").split("-")[0].split(".").map(Number);
81
+ const pb = b.replace(/^v/, "").split("-")[0].split(".").map(Number);
82
+
83
+ for (let i = 0; i < 3; i++) {
84
+ const diff = (pa[i] || 0) - (pb[i] || 0);
85
+ if (diff !== 0) return diff;
86
+ }
87
+
88
+ return 0;
89
+ }
90
+
91
+ function resolveTag() {
92
+ const output = execSync(`git ls-remote --tags --refs ${repo}`, {
93
+ encoding: "utf8",
94
+ });
95
+
96
+ const tags = output
97
+ .split("\n")
98
+ .map((line) => line.split("refs/tags/")[1])
99
+ .filter(Boolean);
100
+
101
+ if (requestedVersion) {
102
+ const wanted = normalizeTag(requestedVersion);
103
+
104
+ if (!tags.includes(wanted)) {
105
+ console.error(`Version "${requestedVersion}" not found in ${repo}`);
106
+ process.exit(1);
107
+ }
108
+
109
+ return wanted;
110
+ }
111
+
112
+ const stable = tags.filter((t) => /^v?\d+\.\d+\.\d+$/.test(t));
113
+
114
+ if (stable.length === 0) {
115
+ console.error(`No tagged releases found in ${repo}`);
116
+ process.exit(1);
117
+ }
118
+
119
+ return stable.sort(compareSemver).pop();
120
+ }
121
+
122
+ const tag = resolveTag();
123
+
124
+ console.log(`\nCloning ${repo} at ${tag}...\n`);
125
+
126
+ execSync(`git clone --depth=1 --branch ${tag} ${repo} "${tempDir}"`, {
127
+ stdio: "inherit",
128
+ });
129
+
130
+ fs.rmSync(path.join(tempDir, ".git"), {
131
+ recursive: true,
132
+ force: true,
133
+ });
134
+
135
+ fs.cpSync(tempDir, targetDir, {
136
+ recursive: true,
137
+ });
138
+
139
+ //
140
+ // Remove files not needed in the generated project
141
+ //
142
+
143
+ [
144
+ "scripts/syncVersion.js",
145
+ "SECURITY.md",
146
+ ".github",
147
+ ].forEach((entry) => {
148
+ fs.rmSync(path.join(targetDir, entry), {
149
+ recursive: true,
150
+ force: true,
151
+ });
152
+ });
153
+
154
+ //
155
+ // Remove all lockfiles (should not be there, but just to be safe)
156
+ //
157
+
158
+ [
159
+ "package-lock.json",
160
+ "pnpm-lock.yaml",
161
+ "yarn.lock",
162
+ "bun.lockb",
163
+ ].forEach((file) => {
164
+ fs.rmSync(path.join(targetDir, file), {
165
+ force: true,
166
+ });
167
+ });
168
+
169
+ //
170
+ // Update package.json
171
+ //
172
+
173
+ const packageJsonPath = path.join(targetDir, "package.json");
174
+
175
+ const pkg = JSON.parse(
176
+ fs.readFileSync(packageJsonPath, "utf8")
177
+ );
178
+
179
+ pkg.name = projectName;
180
+
181
+ if (pkg.scripts) {
182
+ delete pkg.scripts["sync-version"];
183
+ delete pkg.scripts.prebuild;
184
+ }
185
+
186
+ if (pm === "pnpm") {
187
+ pkg.packageManager = `pnpm@${execSync("pnpm --version")
188
+ .toString()
189
+ .trim()}`;
190
+ }
191
+
192
+ if (pm === "bun") {
193
+ pkg.packageManager = `bun@${execSync("bun --version")
194
+ .toString()
195
+ .trim()}`;
196
+ }
197
+
198
+ fs.writeFileSync(
199
+ packageJsonPath,
200
+ JSON.stringify(pkg, null, 2)
201
+ );
202
+
203
+ //
204
+ // Install dependencies
205
+ //
206
+
207
+ if (!skipInstall) {
208
+ console.log(`\nInstalling dependencies using ${pm}...\n`);
209
+
210
+ execSync(`${pm} install`, {
211
+ cwd: targetDir,
212
+ stdio: "inherit",
213
+ });
214
+ }
215
+
216
+ //
217
+ // Next steps
218
+ //
219
+
220
+ const devCommands = {
221
+ npm: "npm run dev",
222
+ pnpm: "pnpm dev",
223
+ yarn: "yarn dev",
224
+ bun: "bun run dev",
225
+ };
226
+
227
+ console.log(`
228
+ Done.
229
+
230
+ Next steps:
231
+
232
+ cd ${projectName}
233
+ ${devCommands[pm]}
234
+ `);
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "create-stardrive",
3
+ "version": "1.0.0",
4
+ "description": "This is the launchpad application to create the Astro Stardrive boilerplate.",
5
+ "bin": {
6
+ "create-stardrive": "bin/index.js"
7
+ },
8
+ "files": [
9
+ "index.js"
10
+ ],
11
+ "keywords": [
12
+ "astro",
13
+ "stardrive",
14
+ "javascript",
15
+ "typescript",
16
+ "html",
17
+ "tailwind",
18
+ "web",
19
+ "landingpage",
20
+ "starter",
21
+ "template",
22
+ "framework",
23
+ "boilerplate"
24
+ ],
25
+ "homepage": "https://github.com/Peltmonger/create-stardrive#readme",
26
+ "bugs": {
27
+ "url": "https://github.com/Peltmonger/create-stardrive/issues"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/Peltmonger/create-stardrive.git"
32
+ },
33
+ "author": {
34
+ "name": "Peltmonger Ventures GmbH",
35
+ "url": "https://peltmonger.com/"
36
+ },
37
+ "maintainers": [
38
+ {
39
+ "name": "Jens Kuerschner",
40
+ "url": "https://jekuer.com/"
41
+ }
42
+ ],
43
+ "license": "MIT",
44
+ "funding": "https://github.com/peltmonger/stardrive?sponsor=1",
45
+ "type": "module",
46
+ "engines": {
47
+ "node": ">=14"
48
+ }
49
+ }