@akanjs/cli 2.4.0 → 2.4.1-rc.1
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/agent.command-h4afc69n.js +26 -0
- package/application.command-47mj9qsy.js +165 -0
- package/applicationBuildRunner-yz144508.js +284 -0
- package/applicationReleasePackager-brvth6rs.js +245 -0
- package/capacitorApp-y0h6cgft.js +58 -0
- package/cloud.command-qgjxja3n.js +94 -0
- package/commandManifest.json +1 -0
- package/context.command-nqbtak4f.js +82 -0
- package/dependencyScanner-m4x5maek.js +9 -0
- package/guideline.command-ya0dh44f.js +356 -0
- package/incrementalBuilder.proc.js +89 -17394
- package/index-1xdrsbry.js +1447 -0
- package/index-45aj5ry0.js +990 -0
- package/index-5vvwc0cz.js +559 -0
- package/index-61keag0s.js +40 -0
- package/index-6pz1j0zj.js +62 -0
- package/index-73pr2cmy.js +534 -0
- package/index-76rn3g2c.js +76 -0
- package/index-77crfweb.js +1884 -0
- package/index-85msc0wg.js +161 -0
- package/index-8pkbzj26.js +840 -0
- package/index-8rc0bm04.js +514 -0
- package/index-a5rmdgy4.js +4359 -0
- package/index-a6sbyy0b.js +2769 -0
- package/index-fgc8r6dj.js +33 -0
- package/index-h6ca6qg0.js +2777 -0
- package/index-hdqztm58.js +758 -0
- package/index-hwzpw9c1.js +202 -0
- package/index-pmm9e2jf.js +120 -0
- package/index-qaq13qk3.js +80 -0
- package/index-qhtr07v8.js +1072 -0
- package/index-r24hmh0q.js +4 -0
- package/index-sgmas1fc.js +462 -0
- package/index-ss469dec.js +11 -0
- package/index-swf4bmbg.js +25 -0
- package/index-wnp7hwq7.js +193 -0
- package/index-wq8jwx8z.js +224 -0
- package/index-x53a5nya.js +301 -0
- package/index-y3hdhy4p.js +229 -0
- package/index-z9gvz7b0.js +83 -0
- package/index.js +54 -23340
- package/library.command-r15zdqvp.js +33 -0
- package/localRegistry.command-p1pgxw78.js +178 -0
- package/module.command-qrj3kmyz.js +54 -0
- package/package.command-r8sq5kzp.js +43 -0
- package/package.json +2 -2
- package/page.command-c6xdx0xm.js +24 -0
- package/primitive.command-pv9ssmtf.js +62 -0
- package/quality.command-es67wvdp.js +809 -0
- package/repair.command-677675vw.js +67 -0
- package/routeSourceValidator-wbhmbwpj.js +132 -0
- package/scalar.command-kabkd6wd.js +35 -0
- package/templates/facetIndex/index.ts +1 -1
- package/typeChecker-kravn7ns.js +8 -0
- package/typecheck.proc.js +4 -194
- package/workflow.command-64r6cw0w.js +108 -0
- package/workspace.command-xk68sd6c.js +435 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ContextScript
|
|
4
|
+
} from "./index-qhtr07v8.js";
|
|
5
|
+
import"./index-45aj5ry0.js";
|
|
6
|
+
import {
|
|
7
|
+
CloudScript
|
|
8
|
+
} from "./index-z9gvz7b0.js";
|
|
9
|
+
import"./index-y3hdhy4p.js";
|
|
10
|
+
import"./index-73pr2cmy.js";
|
|
11
|
+
import"./index-85msc0wg.js";
|
|
12
|
+
import"./index-1xdrsbry.js";
|
|
13
|
+
import {
|
|
14
|
+
AgentScript
|
|
15
|
+
} from "./index-hwzpw9c1.js";
|
|
16
|
+
import"./index-8rc0bm04.js";
|
|
17
|
+
import {
|
|
18
|
+
getLatestPackageVersion,
|
|
19
|
+
getNpmRegistryUrl
|
|
20
|
+
} from "./index-sgmas1fc.js";
|
|
21
|
+
import {
|
|
22
|
+
ApplicationScript
|
|
23
|
+
} from "./index-77crfweb.js";
|
|
24
|
+
import"./index-76rn3g2c.js";
|
|
25
|
+
import {
|
|
26
|
+
LibraryScript
|
|
27
|
+
} from "./index-pmm9e2jf.js";
|
|
28
|
+
import {
|
|
29
|
+
PackageScript
|
|
30
|
+
} from "./index-wq8jwx8z.js";
|
|
31
|
+
import"./index-8pkbzj26.js";
|
|
32
|
+
import"./index-swf4bmbg.js";
|
|
33
|
+
import"./index-ss469dec.js";
|
|
34
|
+
import"./index-qaq13qk3.js";
|
|
35
|
+
import"./index-h6ca6qg0.js";
|
|
36
|
+
import {
|
|
37
|
+
GlobalConfig
|
|
38
|
+
} from "./index-5vvwc0cz.js";
|
|
39
|
+
import {
|
|
40
|
+
Exec,
|
|
41
|
+
Workspace,
|
|
42
|
+
command,
|
|
43
|
+
runner,
|
|
44
|
+
script
|
|
45
|
+
} from "./index-hdqztm58.js";
|
|
46
|
+
import"./index-fgc8r6dj.js";
|
|
47
|
+
import {
|
|
48
|
+
AppExecutor,
|
|
49
|
+
LibExecutor,
|
|
50
|
+
PkgExecutor,
|
|
51
|
+
WorkspaceExecutor
|
|
52
|
+
} from "./index-a6sbyy0b.js";
|
|
53
|
+
import"./index-x53a5nya.js";
|
|
54
|
+
import {
|
|
55
|
+
FileSys
|
|
56
|
+
} from "./index-61keag0s.js";
|
|
57
|
+
import"./index-6pz1j0zj.js";
|
|
58
|
+
import"./index-r24hmh0q.js";
|
|
59
|
+
|
|
60
|
+
// pkgs/@akanjs/cli/workspace/workspace.script.ts
|
|
61
|
+
import path2 from "path";
|
|
62
|
+
import { Logger } from "akanjs/common";
|
|
63
|
+
|
|
64
|
+
// pkgs/@akanjs/cli/workspace/workspace.runner.ts
|
|
65
|
+
import path from "path";
|
|
66
|
+
var defaultWorkspacePeerDependencies = new Set([
|
|
67
|
+
"@react-spring/web",
|
|
68
|
+
"@use-gesture/react",
|
|
69
|
+
"chance",
|
|
70
|
+
"croner",
|
|
71
|
+
"daisyui",
|
|
72
|
+
"react",
|
|
73
|
+
"react-dom",
|
|
74
|
+
"react-icons",
|
|
75
|
+
"react-refresh",
|
|
76
|
+
"react-server-dom-webpack",
|
|
77
|
+
"react-spring",
|
|
78
|
+
"scheduler",
|
|
79
|
+
"tailwind-scrollbar",
|
|
80
|
+
"tailwindcss",
|
|
81
|
+
"typescript"
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
class WorkspaceRunner extends runner("workspace") {
|
|
85
|
+
async generateAgentRules(workspace, { overwrite = false, cursorRules = true } = {}) {
|
|
86
|
+
const [appNames] = await workspace.getExecs();
|
|
87
|
+
const dict = {
|
|
88
|
+
repoName: workspace.repoName,
|
|
89
|
+
appName: appNames[0] ?? "app"
|
|
90
|
+
};
|
|
91
|
+
const created = await workspace.applyTemplate({
|
|
92
|
+
basePath: ".",
|
|
93
|
+
template: "workspaceRoot/AGENTS.md.template",
|
|
94
|
+
dict,
|
|
95
|
+
overwrite
|
|
96
|
+
});
|
|
97
|
+
created.push(...await workspace.applyTemplate({
|
|
98
|
+
basePath: ".",
|
|
99
|
+
template: "workspaceRoot/CLAUDE.md.template",
|
|
100
|
+
dict,
|
|
101
|
+
overwrite
|
|
102
|
+
}));
|
|
103
|
+
if (!cursorRules)
|
|
104
|
+
return created;
|
|
105
|
+
return [
|
|
106
|
+
...created,
|
|
107
|
+
...await workspace.applyTemplate({
|
|
108
|
+
basePath: ".cursor/rules",
|
|
109
|
+
template: "workspaceRoot/.cursor/rules/akan.mdc.template",
|
|
110
|
+
dict,
|
|
111
|
+
overwrite
|
|
112
|
+
})
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
async createWorkspace(repoName, appName, {
|
|
116
|
+
dirname = ".",
|
|
117
|
+
init = true,
|
|
118
|
+
akanVersion,
|
|
119
|
+
registryUrl,
|
|
120
|
+
owner = ""
|
|
121
|
+
}) {
|
|
122
|
+
const cwdPath = process.cwd();
|
|
123
|
+
const workspaceRoot = path.join(cwdPath, dirname, repoName);
|
|
124
|
+
const normalizedRegistryUrl = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
125
|
+
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
126
|
+
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname}/${repoName}...`);
|
|
127
|
+
const [latestBiomeVersion, latestTypesBunVersion] = await Promise.all([
|
|
128
|
+
getLatestPackageVersion("@biomejs/biome", "latest", normalizedRegistryUrl),
|
|
129
|
+
getLatestPackageVersion("@types/bun", "latest", normalizedRegistryUrl)
|
|
130
|
+
]);
|
|
131
|
+
await workspace.applyTemplate({
|
|
132
|
+
basePath: ".",
|
|
133
|
+
template: "workspaceRoot",
|
|
134
|
+
dict: { repoName, appName, serveDomain: "localhost", owner }
|
|
135
|
+
});
|
|
136
|
+
if (normalizedRegistryUrl)
|
|
137
|
+
await workspace.writeFile(".npmrc", `registry=${normalizedRegistryUrl}/
|
|
138
|
+
`);
|
|
139
|
+
templateSpinner.succeed(`Workspace files created in ${dirname}/${repoName}`);
|
|
140
|
+
const [rootPackageJson, peerDependencies] = await Promise.all([
|
|
141
|
+
workspace.getPackageJson(),
|
|
142
|
+
this.#getAkanPeerDependencies()
|
|
143
|
+
]);
|
|
144
|
+
const { typescript, ...dependencies } = peerDependencies;
|
|
145
|
+
const packageJson = {
|
|
146
|
+
...rootPackageJson,
|
|
147
|
+
dependencies: {
|
|
148
|
+
...rootPackageJson.dependencies,
|
|
149
|
+
...dependencies,
|
|
150
|
+
akanjs: akanVersion
|
|
151
|
+
},
|
|
152
|
+
devDependencies: {
|
|
153
|
+
...rootPackageJson.devDependencies,
|
|
154
|
+
"@biomejs/biome": latestBiomeVersion,
|
|
155
|
+
"@types/bun": latestTypesBunVersion,
|
|
156
|
+
"@akanjs/devkit": akanVersion,
|
|
157
|
+
...typescript ? { typescript } : {}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
await workspace.setPackageJson(packageJson);
|
|
161
|
+
if (init) {
|
|
162
|
+
const installSpinner = workspace.spinning("Installing dependencies with bun...");
|
|
163
|
+
await workspace.spawn("bun", ["install"]);
|
|
164
|
+
installSpinner.succeed("Dependencies installed with bun");
|
|
165
|
+
}
|
|
166
|
+
return workspace;
|
|
167
|
+
}
|
|
168
|
+
async#getAkanPeerDependencies() {
|
|
169
|
+
const [packageJson, cliPackageJson] = await Promise.all([this.#getAkanPackageJson(), this.#getCliPackageJson()]);
|
|
170
|
+
const dependencyVersions = {
|
|
171
|
+
...packageJson.dependencies,
|
|
172
|
+
...packageJson.peerDependencies,
|
|
173
|
+
...cliPackageJson.dependencies
|
|
174
|
+
};
|
|
175
|
+
return Object.fromEntries(Object.entries(dependencyVersions).filter(([dependency]) => defaultWorkspacePeerDependencies.has(dependency)));
|
|
176
|
+
}
|
|
177
|
+
async#getCliPackageJson() {
|
|
178
|
+
const packageJsonCandidates = [
|
|
179
|
+
path.join(import.meta.dir, "../package.json"),
|
|
180
|
+
path.join(import.meta.dir, "package.json"),
|
|
181
|
+
path.join(path.dirname(Bun.main), "package.json")
|
|
182
|
+
];
|
|
183
|
+
try {
|
|
184
|
+
packageJsonCandidates.unshift(Bun.resolveSync("@akanjs/cli/package.json", import.meta.dir));
|
|
185
|
+
} catch {}
|
|
186
|
+
for (const packageJsonPath of packageJsonCandidates) {
|
|
187
|
+
if (!await Bun.file(packageJsonPath).exists())
|
|
188
|
+
continue;
|
|
189
|
+
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
190
|
+
if (packageJson.name === "@akanjs/cli")
|
|
191
|
+
return packageJson;
|
|
192
|
+
}
|
|
193
|
+
return { name: "@akanjs/cli", version: "0.0.0", description: "@akanjs/cli" };
|
|
194
|
+
}
|
|
195
|
+
async#getAkanPackageJson() {
|
|
196
|
+
const packageJsonCandidates = [
|
|
197
|
+
path.join(import.meta.dir, "../../../akanjs/package.json"),
|
|
198
|
+
path.join(process.cwd(), "pkgs/akanjs/package.json"),
|
|
199
|
+
path.join(path.dirname(Bun.main), "node_modules/akanjs/package.json")
|
|
200
|
+
];
|
|
201
|
+
try {
|
|
202
|
+
packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json", import.meta.dir));
|
|
203
|
+
} catch {}
|
|
204
|
+
for (const packageJsonPath of packageJsonCandidates) {
|
|
205
|
+
if (!await Bun.file(packageJsonPath).exists())
|
|
206
|
+
continue;
|
|
207
|
+
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
208
|
+
if (packageJson.name === "akanjs")
|
|
209
|
+
return packageJson;
|
|
210
|
+
}
|
|
211
|
+
let current = import.meta.dir;
|
|
212
|
+
for (let depth = 0;depth < 6; depth++) {
|
|
213
|
+
const packageJsonPath = path.join(current, "package.json");
|
|
214
|
+
if (await Bun.file(packageJsonPath).exists()) {
|
|
215
|
+
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
216
|
+
if (packageJson.name === "akanjs")
|
|
217
|
+
return packageJson;
|
|
218
|
+
}
|
|
219
|
+
const parent = path.dirname(current);
|
|
220
|
+
if (parent === current)
|
|
221
|
+
break;
|
|
222
|
+
current = parent;
|
|
223
|
+
}
|
|
224
|
+
throw new Error(`[workspace] failed to locate akanjs package.json from ${import.meta.dir}`);
|
|
225
|
+
}
|
|
226
|
+
async lint(exec, workspace, { fix = true } = {}) {
|
|
227
|
+
await workspace.spawn("./node_modules/.bin/biome", [
|
|
228
|
+
"check",
|
|
229
|
+
...fix ? ["--write"] : [],
|
|
230
|
+
"--no-errors-on-unmatched",
|
|
231
|
+
exec.cwdPath
|
|
232
|
+
]);
|
|
233
|
+
}
|
|
234
|
+
async writeTopLevelEnv(workspace, devProjectId) {
|
|
235
|
+
await workspace.writeFile(".env", `AKAN_WORKSPACE_ID=${devProjectId}
|
|
236
|
+
|
|
237
|
+
# organization configuration, no need to change
|
|
238
|
+
AKAN_PUBLIC_REPO_NAME=${workspace.repoName}
|
|
239
|
+
|
|
240
|
+
# serve domain, it changes the domain of the server.
|
|
241
|
+
AKAN_PUBLIC_SERVE_DOMAIN=try.akanjs.com
|
|
242
|
+
|
|
243
|
+
# development branch, debug, develop, main, etc. mainly it changes databases.
|
|
244
|
+
AKAN_PUBLIC_ENV=local
|
|
245
|
+
|
|
246
|
+
# local, cloud, edge it changes the connection point of the clients.
|
|
247
|
+
AKAN_PUBLIC_OPERATION_MODE=local
|
|
248
|
+
|
|
249
|
+
# log level, debug, info, warn, error
|
|
250
|
+
AKAN_PUBLIC_LOG_LEVEL=debug
|
|
251
|
+
`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// pkgs/@akanjs/cli/workspace/workspace.script.ts
|
|
256
|
+
class WorkspaceScript extends script("workspace", [
|
|
257
|
+
WorkspaceRunner,
|
|
258
|
+
ApplicationScript,
|
|
259
|
+
LibraryScript,
|
|
260
|
+
PackageScript,
|
|
261
|
+
CloudScript,
|
|
262
|
+
ContextScript,
|
|
263
|
+
AgentScript
|
|
264
|
+
]) {
|
|
265
|
+
async createWorkspace(repoName, appName, {
|
|
266
|
+
dirname = ".",
|
|
267
|
+
installLibs = false,
|
|
268
|
+
init = true,
|
|
269
|
+
registryUrl,
|
|
270
|
+
owner,
|
|
271
|
+
mcpInstall = true,
|
|
272
|
+
agentInstall = true
|
|
273
|
+
}) {
|
|
274
|
+
const akanVersion = await this.packageScript.version(null, { log: false });
|
|
275
|
+
const workspace = await this.workspaceRunner.createWorkspace(repoName, appName, {
|
|
276
|
+
dirname,
|
|
277
|
+
init,
|
|
278
|
+
akanVersion,
|
|
279
|
+
...registryUrl ? { registryUrl } : {},
|
|
280
|
+
...owner ? { owner } : {}
|
|
281
|
+
});
|
|
282
|
+
if (installLibs) {
|
|
283
|
+
await this.libraryScript.installLibrary(workspace, "util");
|
|
284
|
+
await this.libraryScript.installLibrary(workspace, "shared");
|
|
285
|
+
}
|
|
286
|
+
await this.applicationScript.createApplication(appName, workspace, { libs: installLibs ? ["util", "shared"] : [] });
|
|
287
|
+
await workspace.applyTemplate({
|
|
288
|
+
basePath: `apps/${appName}`,
|
|
289
|
+
template: "appSample",
|
|
290
|
+
dict: { appName },
|
|
291
|
+
options: { libs: installLibs ? ["util", "shared"] : [] }
|
|
292
|
+
});
|
|
293
|
+
if (agentInstall)
|
|
294
|
+
await this.agentScript.agent(workspace, "install", "all", { force: true });
|
|
295
|
+
if (mcpInstall)
|
|
296
|
+
await this.contextScript.mcpInstall(workspace, "all", { force: true });
|
|
297
|
+
const gitSpinner = workspace.spinning("Initializing git repository and commit...");
|
|
298
|
+
try {
|
|
299
|
+
await workspace.commit("Initial commit", { init: true });
|
|
300
|
+
gitSpinner.succeed("Git repository initialized and committed");
|
|
301
|
+
} catch (_) {
|
|
302
|
+
gitSpinner.fail("Git repository initialization failed. It's not fatal, you can commit manually");
|
|
303
|
+
}
|
|
304
|
+
const workspacePath = path2.join(dirname, repoName);
|
|
305
|
+
Logger.rawLog(`
|
|
306
|
+
\uD83C\uDF89 Welcome aboard! Workspace created in ${dirname}/${repoName}`);
|
|
307
|
+
Logger.rawLog(`\uD83D\uDE80 Run \`cd ${workspacePath} && akan start ${appName}\` to start the development server.`);
|
|
308
|
+
Logger.rawLog(`
|
|
309
|
+
\uD83D\uDC4B Happy coding!`);
|
|
310
|
+
}
|
|
311
|
+
async generateAgentRules(workspace, { overwrite = false, cursorRules = true } = {}) {
|
|
312
|
+
const spinner = workspace.spinning("Generating agent rules...");
|
|
313
|
+
const files = await this.workspaceRunner.generateAgentRules(workspace, { overwrite, cursorRules });
|
|
314
|
+
spinner.succeed(`Agent rules ready (${files.length} file${files.length === 1 ? "" : "s"})`);
|
|
315
|
+
}
|
|
316
|
+
async lint(exec, workspace, { fix = true } = {}) {
|
|
317
|
+
if (exec instanceof AppExecutor)
|
|
318
|
+
await this.applicationScript.sync(exec);
|
|
319
|
+
else if (exec instanceof LibExecutor)
|
|
320
|
+
await this.libraryScript.syncLibrary(exec);
|
|
321
|
+
const spinner = workspace.spinning(`Linting${fix ? " with fix" : ""}...`);
|
|
322
|
+
try {
|
|
323
|
+
await this.workspaceRunner.lint(exec, workspace, { fix });
|
|
324
|
+
spinner.succeed("Lint completed with no errors");
|
|
325
|
+
} catch (error) {
|
|
326
|
+
spinner.fail("Lint failed with errors");
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async lintAll(workspace, { fix = true } = {}) {
|
|
331
|
+
const [appNames, libNames, pkgNames] = await workspace.getExecs();
|
|
332
|
+
await Promise.all(appNames.map((appName) => this.applicationScript.sync(AppExecutor.from(workspace, appName))));
|
|
333
|
+
await Promise.all(libNames.map((libName) => this.libraryScript.syncLibrary(LibExecutor.from(workspace, libName))));
|
|
334
|
+
await Promise.all([
|
|
335
|
+
...appNames.map((appName) => this.workspaceRunner.lint(AppExecutor.from(workspace, appName), workspace, { fix })),
|
|
336
|
+
...libNames.map((libName) => this.workspaceRunner.lint(LibExecutor.from(workspace, libName), workspace, { fix })),
|
|
337
|
+
...pkgNames.filter((pkgName) => pkgName !== "contract").map((pkgName) => this.workspaceRunner.lint(PkgExecutor.from(workspace, pkgName), workspace, { fix }))
|
|
338
|
+
]);
|
|
339
|
+
}
|
|
340
|
+
async syncAll(workspace) {
|
|
341
|
+
const [appNames, libNames] = await workspace.getExecs();
|
|
342
|
+
for (const libName of libNames)
|
|
343
|
+
await this.libraryScript.syncLibrary(LibExecutor.from(workspace, libName));
|
|
344
|
+
for (const appName of appNames)
|
|
345
|
+
await this.applicationScript.sync(AppExecutor.from(workspace, appName));
|
|
346
|
+
}
|
|
347
|
+
async init(devProjectId, workspace, { host } = {}) {
|
|
348
|
+
const [bunfigExists, packageJsonExists, tsconfigExists] = await Promise.all([
|
|
349
|
+
workspace.exists("bunfig.toml"),
|
|
350
|
+
workspace.exists("package.json"),
|
|
351
|
+
workspace.exists("tsconfig.json")
|
|
352
|
+
]);
|
|
353
|
+
const isRoot = bunfigExists && packageJsonExists && tsconfigExists;
|
|
354
|
+
if (!isRoot)
|
|
355
|
+
throw new Error("Current directory is not a root workspace");
|
|
356
|
+
const spinner = workspace.spinning("Initializing workspace...");
|
|
357
|
+
try {
|
|
358
|
+
await this.workspaceRunner.writeTopLevelEnv(workspace, devProjectId);
|
|
359
|
+
await this.cloudScript.downloadEnv(workspace, devProjectId, { host });
|
|
360
|
+
spinner.succeed("Workspace initialized");
|
|
361
|
+
} catch (error) {
|
|
362
|
+
spinner.fail("Workspace initialization failed");
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// pkgs/@akanjs/cli/workspace/workspace.command.ts
|
|
369
|
+
class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public: target }) => ({
|
|
370
|
+
createWorkspace: target({ desc: "Create a new Akan.js workspace", runsOnWorkspaceRoot: false }).arg("workspaceName", String, { desc: "what is the name of your organization?" }).option("app", String, {
|
|
371
|
+
desc: "what is the codename of your first application? (e.g. myapp)"
|
|
372
|
+
}).option("dir", String, {
|
|
373
|
+
desc: "directory of workspace",
|
|
374
|
+
default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "."
|
|
375
|
+
}).option("libs", Boolean, {
|
|
376
|
+
desc: "Do you want to install shared and util libraries? (admin, user file, etc.)",
|
|
377
|
+
enum: [
|
|
378
|
+
{ label: "No, I want to start with empty workspace (Recommended)", value: false },
|
|
379
|
+
{
|
|
380
|
+
label: "Yes, I want to accelerate development by installing shared and util libraries (for akanjs experts)",
|
|
381
|
+
value: true
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
default: false
|
|
385
|
+
}).option("init", Boolean, {
|
|
386
|
+
desc: "Do you want to initialize the workspace? (Recommended)",
|
|
387
|
+
default: true
|
|
388
|
+
}).option("registry", String, {
|
|
389
|
+
desc: "npm registry URL for installing Akan packages",
|
|
390
|
+
default: process.env.AKAN_NPM_REGISTRY ?? "https://registry.npmjs.org"
|
|
391
|
+
}).option("owner", String, {
|
|
392
|
+
desc: "owner of the workspace",
|
|
393
|
+
default: process.env.GITHUB_OWNER,
|
|
394
|
+
nullable: true
|
|
395
|
+
}).option("mcpInstall", Boolean, {
|
|
396
|
+
desc: "Install the Akan MCP server config for Cursor, Claude Code, and Codex? (Recommended)",
|
|
397
|
+
default: true
|
|
398
|
+
}).option("agentInstall", Boolean, {
|
|
399
|
+
flag: "A",
|
|
400
|
+
desc: "Install Akan agent rules (AGENTS.md, CLAUDE.md, Cursor)? (Recommended)",
|
|
401
|
+
default: true
|
|
402
|
+
}).exec(async function(workspaceName, app, dir, libs, init, registry, owner, mcpInstall, agentInstall) {
|
|
403
|
+
const appName = app || "app";
|
|
404
|
+
await this.workspaceScript.createWorkspace(workspaceName.toLowerCase().replace(/ /g, "-"), appName.toLowerCase().replace(/ /g, "-"), {
|
|
405
|
+
dirname: dir,
|
|
406
|
+
installLibs: libs,
|
|
407
|
+
init,
|
|
408
|
+
owner,
|
|
409
|
+
mcpInstall,
|
|
410
|
+
agentInstall,
|
|
411
|
+
...registry ? { registryUrl: registry } : {}
|
|
412
|
+
});
|
|
413
|
+
}),
|
|
414
|
+
generateAgentRules: target({
|
|
415
|
+
desc: "Generate AGENTS.md, CLAUDE.md, and optional Cursor rules for Akan coding agents"
|
|
416
|
+
}).option("overwrite", Boolean, { desc: "Overwrite existing agent rule files", default: false }).option("cursorRules", Boolean, { desc: "Generate .cursor/rules/akan.mdc", default: true }).with(Workspace).exec(async function(overwrite, cursorRules, workspace) {
|
|
417
|
+
await this.workspaceScript.generateAgentRules(workspace, { overwrite, cursorRules });
|
|
418
|
+
}),
|
|
419
|
+
lint: target({ desc: "Lint and fix code in a specific app/lib/pkg" }).with(Exec).option("fix", Boolean, { default: true }).with(Workspace).exec(async function(exec, fix, workspace) {
|
|
420
|
+
await this.workspaceScript.lint(exec, workspace, { fix });
|
|
421
|
+
}),
|
|
422
|
+
lintAll: target({ desc: "Lint and fix code in all apps and libraries" }).option("fix", Boolean, { default: true }).with(Workspace).exec(async function(fix, workspace) {
|
|
423
|
+
await this.workspaceScript.lintAll(workspace, { fix });
|
|
424
|
+
}),
|
|
425
|
+
syncAll: target({ desc: "Sync dependencies and configuration for all apps and libraries" }).with(Workspace).exec(async function(workspace) {
|
|
426
|
+
await this.workspaceScript.syncAll(workspace);
|
|
427
|
+
}),
|
|
428
|
+
init: target({ desc: "Initialize the workspace", runsOnWorkspaceRoot: false }).arg("devProjectId", String, { desc: "the ID of the workspace" }).option("host", String, { desc: "host of the cloud to target", default: GlobalConfig.akanCloudHost }).with(Workspace).exec(async function(devProjectId, host, workspace) {
|
|
429
|
+
await this.workspaceScript.init(devProjectId, workspace, { host });
|
|
430
|
+
})
|
|
431
|
+
})) {
|
|
432
|
+
}
|
|
433
|
+
export {
|
|
434
|
+
WorkspaceCommand
|
|
435
|
+
};
|