create-alepha 0.14.3 → 0.15.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/dist/index.js +12 -47
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/CreateAlephaCoreCommands.ts +22 -86
package/dist/index.js
CHANGED
|
@@ -1,64 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $inject, Alepha,
|
|
3
|
-
import { access, mkdir } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { Readable } from "node:stream";
|
|
6
|
-
import { pipeline } from "node:stream/promises";
|
|
2
|
+
import { $inject, Alepha, run, t } from "alepha";
|
|
7
3
|
import { $command, CliProvider } from "alepha/command";
|
|
4
|
+
import { FileSystemProvider } from "alepha/file";
|
|
8
5
|
import { $logger } from "alepha/logger";
|
|
9
|
-
import * as tar from "tar";
|
|
10
6
|
import { readFileSync } from "node:fs";
|
|
11
7
|
|
|
12
8
|
//#region src/CreateAlephaCoreCommands.ts
|
|
13
9
|
var CreateAlephaCoreCommands = class {
|
|
14
10
|
log = $logger();
|
|
15
11
|
cli = $inject(CliProvider);
|
|
16
|
-
|
|
17
|
-
const ua = process.env.npm_config_user_agent || "";
|
|
18
|
-
if (ua.startsWith("yarn")) return "yarn";
|
|
19
|
-
if (ua.startsWith("pnpm")) return "pnpm";
|
|
20
|
-
if (ua.startsWith("bun")) return "bun";
|
|
21
|
-
return "npm";
|
|
22
|
-
}
|
|
12
|
+
fs = $inject(FileSystemProvider);
|
|
23
13
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
async downloadSampleProject(targetDir) {
|
|
27
|
-
const response = await fetch("https://api.github.com/repos/feunard/alepha/tarball/main", { headers: { "User-Agent": "Alepha-CLI" } });
|
|
28
|
-
if (!response.ok) throw new AlephaError(`Failed to download: ${response.statusText}`);
|
|
29
|
-
await pipeline(Readable.fromWeb(response.body), tar.extract({
|
|
30
|
-
cwd: targetDir,
|
|
31
|
-
strip: 3,
|
|
32
|
-
filter: (path) => {
|
|
33
|
-
const parts = path.split("/");
|
|
34
|
-
return parts.length >= 3 && parts[1] === "apps" && parts[2] === "starter";
|
|
35
|
-
}
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Called when no command is provided - shows help or creates a new project
|
|
14
|
+
* Called when no command is provided - delegates to alepha init
|
|
40
15
|
*/
|
|
41
16
|
root = $command({
|
|
42
17
|
root: true,
|
|
43
18
|
description: "Create a new Alepha project",
|
|
44
|
-
args: t.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
} catch {}
|
|
54
|
-
const pm = this.detectPackageManager();
|
|
55
|
-
await mkdir(dest, { recursive: true }).catch(() => null);
|
|
56
|
-
await run$1("downloading sample project", () => this.downloadSampleProject(dest));
|
|
57
|
-
await run$1(`cd ${name} && ${pm} install`, { alias: "installing dependencies" });
|
|
58
|
-
await run$1(`cd ${name} && ${pm} run lint`, { alias: "linting code" });
|
|
59
|
-
await run$1(`cd ${name} && ${pm} run typecheck`, { alias: "type checking" });
|
|
60
|
-
await run$1(`cd ${name} && ${pm} run test`, { alias: "running tests" });
|
|
61
|
-
await run$1(`cd ${name} && ${pm} run build`, { alias: "building project" });
|
|
19
|
+
args: t.text({ title: "name" }),
|
|
20
|
+
handler: async ({ run: run$1, args }) => {
|
|
21
|
+
const name = args;
|
|
22
|
+
await this.fs.mkdir(name);
|
|
23
|
+
await run$1(`cd ${name} && npx alepha@latest init ${name}`, { alias: "creating project" });
|
|
24
|
+
await run$1(`cd ${name} && npx alepha lint`, { alias: "alepha lint" });
|
|
25
|
+
await run$1(`cd ${name} && npx alepha typecheck`, { alias: "alepha typecheck" });
|
|
26
|
+
await run$1(`cd ${name} && npx alepha build`, { alias: "alepha build" });
|
|
62
27
|
}
|
|
63
28
|
});
|
|
64
29
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["run"],"sources":["../src/CreateAlephaCoreCommands.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","names":["run"],"sources":["../src/CreateAlephaCoreCommands.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["import { $inject, t } from \"alepha\";\nimport { $command, CliProvider } from \"alepha/command\";\nimport { FileSystemProvider } from \"alepha/file\";\nimport { $logger } from \"alepha/logger\";\n\nexport class CreateAlephaCoreCommands {\n protected readonly log = $logger();\n protected readonly cli = $inject(CliProvider);\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Called when no command is provided - delegates to alepha init\n */\n public readonly root = $command({\n root: true,\n description: \"Create a new Alepha project\",\n args: t.text({\n title: \"name\",\n }),\n handler: async ({ run, args }) => {\n const name = args;\n\n // create directory\n await this.fs.mkdir(name);\n\n // Delegate to alepha init command\n await run(`cd ${name} && npx alepha@latest init ${name}`, {\n alias: \"creating project\",\n });\n\n await run(`cd ${name} && npx alepha lint`, {\n alias: \"alepha lint\",\n });\n\n await run(`cd ${name} && npx alepha typecheck`, {\n alias: \"alepha typecheck\",\n });\n\n await run(`cd ${name} && npx alepha build`, {\n alias: \"alepha build\",\n });\n },\n });\n}\n","import { readFileSync } from \"node:fs\";\n\nconst packageJson = JSON.parse(\n readFileSync(new URL(\"../package.json\", import.meta.url), \"utf-8\"),\n);\n\nexport const version = packageJson.version;\n","#!/usr/bin/env node\nimport { Alepha, run } from \"alepha\";\nimport { CreateAlephaCoreCommands } from \"./CreateAlephaCoreCommands.ts\";\nimport { version } from \"./version.ts\";\n\nconst alepha = Alepha.create({\n env: {\n LOG_LEVEL: \"alepha.core:warn,info\",\n LOG_FORMAT: \"raw\",\n CLI_NAME: \"create-alepha\",\n CLI_DESCRIPTION: `Create Alepha v${version} - Create a new Alepha project.`,\n },\n});\n\nalepha.with(CreateAlephaCoreCommands);\n\nrun(alepha);\n"],"mappings":";;;;;;;;AAKA,IAAa,2BAAb,MAAsC;CACpC,AAAmB,MAAM,SAAS;CAClC,AAAmB,MAAM,QAAQ,YAAY;CAC7C,AAAmB,KAAK,QAAQ,mBAAmB;;;;CAKnD,AAAgB,OAAO,SAAS;EAC9B,MAAM;EACN,aAAa;EACb,MAAM,EAAE,KAAK,EACX,OAAO,QACR,CAAC;EACF,SAAS,OAAO,EAAE,YAAK,WAAW;GAChC,MAAM,OAAO;AAGb,SAAM,KAAK,GAAG,MAAM,KAAK;AAGzB,SAAMA,MAAI,MAAM,KAAK,6BAA6B,QAAQ,EACxD,OAAO,oBACR,CAAC;AAEF,SAAMA,MAAI,MAAM,KAAK,sBAAsB,EACzC,OAAO,eACR,CAAC;AAEF,SAAMA,MAAI,MAAM,KAAK,2BAA2B,EAC9C,OAAO,oBACR,CAAC;AAEF,SAAMA,MAAI,MAAM,KAAK,uBAAuB,EAC1C,OAAO,gBACR,CAAC;;EAEL,CAAC;;;;;ACxCJ,MAAM,cAAc,KAAK,MACvB,aAAa,IAAI,IAAI,mBAAmB,OAAO,KAAK,IAAI,EAAE,QAAQ,CACnE;AAED,MAAa,UAAU,YAAY;;;;ACDnC,MAAM,SAAS,OAAO,OAAO,EAC3B,KAAK;CACH,WAAW;CACX,YAAY;CACZ,UAAU;CACV,iBAAiB,kBAAkB,QAAQ;CAC5C,EACF,CAAC;AAEF,OAAO,KAAK,yBAAyB;AAErC,IAAI,OAAO"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "create-alepha",
|
|
3
3
|
"description": "Create a new Alepha project with a single command.",
|
|
4
4
|
"author": "Nicolas Foures",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.15.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22.0.0"
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
"src"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"alepha": "0.
|
|
18
|
-
"tar": "^7.5.2"
|
|
17
|
+
"alepha": "0.15.0"
|
|
19
18
|
},
|
|
20
19
|
"devDependencies": {
|
|
21
|
-
"tsdown": "^0.
|
|
22
|
-
"vitest": "^4.0.
|
|
20
|
+
"tsdown": "^0.20.0-beta.3",
|
|
21
|
+
"vitest": "^4.0.17"
|
|
23
22
|
},
|
|
24
23
|
"scripts": {
|
|
25
24
|
"lint": "biome check --fix",
|
|
@@ -1,107 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { Readable } from "node:stream";
|
|
4
|
-
import { pipeline } from "node:stream/promises";
|
|
5
|
-
import { $inject, AlephaError, t } from "alepha";
|
|
1
|
+
import { $inject, t } from "alepha";
|
|
6
2
|
import { $command, CliProvider } from "alepha/command";
|
|
3
|
+
import { FileSystemProvider } from "alepha/file";
|
|
7
4
|
import { $logger } from "alepha/logger";
|
|
8
|
-
import * as tar from "tar";
|
|
9
5
|
|
|
10
6
|
export class CreateAlephaCoreCommands {
|
|
11
7
|
protected readonly log = $logger();
|
|
12
8
|
protected readonly cli = $inject(CliProvider);
|
|
13
|
-
|
|
14
|
-
protected detectPackageManager(): "npm" | "yarn" | "pnpm" | "bun" {
|
|
15
|
-
const ua = process.env.npm_config_user_agent || "";
|
|
16
|
-
if (ua.startsWith("yarn")) return "yarn";
|
|
17
|
-
if (ua.startsWith("pnpm")) return "pnpm";
|
|
18
|
-
if (ua.startsWith("bun")) return "bun";
|
|
19
|
-
return "npm";
|
|
20
|
-
}
|
|
9
|
+
protected readonly fs = $inject(FileSystemProvider);
|
|
21
10
|
|
|
22
11
|
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
public async downloadSampleProject(targetDir: string): Promise<void> {
|
|
26
|
-
const url = "https://api.github.com/repos/feunard/alepha/tarball/main";
|
|
27
|
-
const response = await fetch(url, {
|
|
28
|
-
headers: {
|
|
29
|
-
"User-Agent": "Alepha-CLI",
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (!response.ok) {
|
|
34
|
-
throw new AlephaError(`Failed to download: ${response.statusText}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const tarStream = Readable.fromWeb(response.body as any);
|
|
38
|
-
await pipeline(
|
|
39
|
-
tarStream,
|
|
40
|
-
tar.extract({
|
|
41
|
-
cwd: targetDir,
|
|
42
|
-
strip: 3, // Remove feunard-alepha-<hash>/apps/starter prefix
|
|
43
|
-
filter: (path) => {
|
|
44
|
-
const parts = path.split("/");
|
|
45
|
-
return (
|
|
46
|
-
parts.length >= 3 && parts[1] === "apps" && parts[2] === "starter"
|
|
47
|
-
);
|
|
48
|
-
},
|
|
49
|
-
}),
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Called when no command is provided - shows help or creates a new project
|
|
12
|
+
* Called when no command is provided - delegates to alepha init
|
|
55
13
|
*/
|
|
56
14
|
public readonly root = $command({
|
|
57
15
|
root: true,
|
|
58
16
|
description: "Create a new Alepha project",
|
|
59
|
-
args: t.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.log.error(
|
|
72
|
-
`Directory "${name}" already exists. Please choose a different project name.`,
|
|
73
|
-
);
|
|
74
|
-
return;
|
|
75
|
-
} catch {
|
|
76
|
-
// Directory does not exist, proceed
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const pm = this.detectPackageManager();
|
|
80
|
-
|
|
81
|
-
await mkdir(dest, { recursive: true }).catch(() => null);
|
|
82
|
-
|
|
83
|
-
await run("downloading sample project", () =>
|
|
84
|
-
this.downloadSampleProject(dest),
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
await run(`cd ${name} && ${pm} install`, {
|
|
88
|
-
alias: "installing dependencies",
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
await run(`cd ${name} && ${pm} run lint`, {
|
|
92
|
-
alias: "linting code",
|
|
17
|
+
args: t.text({
|
|
18
|
+
title: "name",
|
|
19
|
+
}),
|
|
20
|
+
handler: async ({ run, args }) => {
|
|
21
|
+
const name = args;
|
|
22
|
+
|
|
23
|
+
// create directory
|
|
24
|
+
await this.fs.mkdir(name);
|
|
25
|
+
|
|
26
|
+
// Delegate to alepha init command
|
|
27
|
+
await run(`cd ${name} && npx alepha@latest init ${name}`, {
|
|
28
|
+
alias: "creating project",
|
|
93
29
|
});
|
|
94
30
|
|
|
95
|
-
await run(`cd ${name} &&
|
|
96
|
-
alias: "
|
|
31
|
+
await run(`cd ${name} && npx alepha lint`, {
|
|
32
|
+
alias: "alepha lint",
|
|
97
33
|
});
|
|
98
34
|
|
|
99
|
-
await run(`cd ${name} &&
|
|
100
|
-
alias: "
|
|
35
|
+
await run(`cd ${name} && npx alepha typecheck`, {
|
|
36
|
+
alias: "alepha typecheck",
|
|
101
37
|
});
|
|
102
38
|
|
|
103
|
-
await run(`cd ${name} &&
|
|
104
|
-
alias: "
|
|
39
|
+
await run(`cd ${name} && npx alepha build`, {
|
|
40
|
+
alias: "alepha build",
|
|
105
41
|
});
|
|
106
42
|
},
|
|
107
43
|
});
|