@akanjs/devkit 3.4.0-rc.0 → 3.4.0-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/executors/executors.test.ts +51 -44
- package/executors/pkgExecutor.ts +13 -10
- package/package.json +3 -4
- package/pipeline/PipelineCompiler.test.ts +49 -3
- package/pipeline/PipelineCompiler.ts +2 -1
- package/quality/runtimeImports.test.ts +1 -1
- package/workspace/dependencyScanner.test.ts +10 -0
- package/workspace/dependencyScanner.ts +1 -1
|
@@ -1319,10 +1319,10 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
1319
1319
|
});
|
|
1320
1320
|
|
|
1321
1321
|
describe("PkgExecutor package generation", () => {
|
|
1322
|
-
test("generates dist package metadata from root dependency versions", async () => {
|
|
1322
|
+
test("generates dist package metadata from root dependency versions, leaving the source manifest alone", async () => {
|
|
1323
1323
|
const root = await makeTempRoot();
|
|
1324
1324
|
await writeJson(path.join(root, "package.json"), rootPackageJson());
|
|
1325
|
-
|
|
1325
|
+
const sourcePackageJson = {
|
|
1326
1326
|
name: "@sample/tool",
|
|
1327
1327
|
version: "0.1.0",
|
|
1328
1328
|
description: "tool",
|
|
@@ -1330,7 +1330,8 @@ describe("PkgExecutor package generation", () => {
|
|
|
1330
1330
|
peerDependencies: { react: "19.0.0" },
|
|
1331
1331
|
peerDependenciesMeta: { react: { optional: true } },
|
|
1332
1332
|
optionalDependencies: { "@sample/native": "1.0.0" },
|
|
1333
|
-
}
|
|
1333
|
+
};
|
|
1334
|
+
await writeJson(path.join(root, "pkgs/@sample/tool/package.json"), sourcePackageJson);
|
|
1334
1335
|
|
|
1335
1336
|
const workspace = new WorkspaceExecutor({ workspaceRoot: root, repoName: "repo" });
|
|
1336
1337
|
const pkg = PkgExecutor.from(workspace, "@sample/tool");
|
|
@@ -1352,7 +1353,7 @@ describe("PkgExecutor package generation", () => {
|
|
|
1352
1353
|
default: "./index.ts",
|
|
1353
1354
|
});
|
|
1354
1355
|
expect(await Bun.file(path.join(root, "dist/pkgs/@sample/tool/package.json")).json()).toEqual(distPackageJson);
|
|
1355
|
-
expect(await Bun.file(path.join(root, "pkgs/@sample/tool/package.json")).json()).toEqual(
|
|
1356
|
+
expect(await Bun.file(path.join(root, "pkgs/@sample/tool/package.json")).json()).toEqual(sourcePackageJson);
|
|
1356
1357
|
});
|
|
1357
1358
|
|
|
1358
1359
|
test("names a sibling the root links as workspace:* at the sibling's own version", async () => {
|
|
@@ -1623,48 +1624,54 @@ describe("SysExecutor scan", () => {
|
|
|
1623
1624
|
expect(fullSrv).toContain('import * as cnst from "./cnst";\nimport * as db from "./db";');
|
|
1624
1625
|
});
|
|
1625
1626
|
|
|
1626
|
-
test.skipIf(!hasBiome)(
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1627
|
+
test.skipIf(!hasBiome)(
|
|
1628
|
+
"writes barrels, module indexes and akan.lib.json the way Biome prints them",
|
|
1629
|
+
async () => {
|
|
1630
|
+
const component = "export const C = () => null;\n";
|
|
1631
|
+
const uiFiles = ["QRCode", "Qa", "SSOButton", "Select", "Icon10", "Icon2"].map((name) => [
|
|
1632
|
+
`ui/${name}.tsx`,
|
|
1633
|
+
component,
|
|
1634
|
+
]);
|
|
1635
|
+
const srvkitFiles = ["aB", "aa", "a10", "a9"].map((name) => [`srvkit/${name}.ts`, "export const x = 1;\n"]);
|
|
1636
|
+
const moduleFiles = ["Template", "Unit", "View"].map((role) => [`lib/post/Post.${role}.tsx`, component]);
|
|
1637
|
+
const { root, lib, libDir } = await createScannableLib("biomestable", {
|
|
1638
|
+
files: Object.fromEntries([
|
|
1639
|
+
...uiFiles,
|
|
1640
|
+
...srvkitFiles,
|
|
1641
|
+
...moduleFiles,
|
|
1642
|
+
["lib/post/post.constant.ts", "export class Post {}\n"],
|
|
1643
|
+
]),
|
|
1644
|
+
});
|
|
1645
|
+
expect(await formatWithBiome('export * from "./b";\nexport * from "./a";\n', "libs/x/srvkit/index.ts")).toBe(
|
|
1646
|
+
'export * from "./a";\nexport * from "./b";\n',
|
|
1647
|
+
);
|
|
1645
1648
|
|
|
1646
|
-
|
|
1649
|
+
await lib.scan();
|
|
1647
1650
|
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1651
|
+
expect(await lib.readFile("ui/index.ts")).toBe(
|
|
1652
|
+
["Icon2", "Icon10", "Qa", "QRCode", "Select", "SSOButton"]
|
|
1653
|
+
.map((name) => `export * from "./${name}";\n`)
|
|
1654
|
+
.join(""),
|
|
1655
|
+
);
|
|
1656
|
+
expect(await lib.readFile("srvkit/index.ts")).toBe(
|
|
1657
|
+
["a9", "a10", "aa", "aB"].map((name) => `export * from "./${name}";\n`).join(""),
|
|
1658
|
+
);
|
|
1659
|
+
for (const file of [
|
|
1660
|
+
"ui/index.ts",
|
|
1661
|
+
"srvkit/index.ts",
|
|
1662
|
+
"lib/post/index.ts",
|
|
1663
|
+
"akan.lib.json",
|
|
1664
|
+
"env/env.server.type.ts",
|
|
1665
|
+
]) {
|
|
1666
|
+
const generated = await lib.readFile(file);
|
|
1667
|
+
expect(await formatWithBiome(generated, `libs/biomestable/${file}`)).toBe(generated);
|
|
1668
|
+
}
|
|
1669
|
+
const devSync = new DevGeneratedIndexSync({ workspaceRoot: root });
|
|
1670
|
+
const events = ["ui/QRCode.tsx", "srvkit/a9.ts", "lib/post"].map((file) => path.join(libDir, file));
|
|
1671
|
+
expect(await devSync.syncForBatch(events)).toEqual({ changedFiles: [], errors: [] });
|
|
1672
|
+
},
|
|
1673
|
+
30_000,
|
|
1674
|
+
);
|
|
1668
1675
|
|
|
1669
1676
|
test.skipIf(!hasBiome)(
|
|
1670
1677
|
"writes env.server.type.ts the way Biome prints it, spreading libs in dependency order",
|
package/executors/pkgExecutor.ts
CHANGED
|
@@ -71,18 +71,21 @@ export class PkgExecutor extends Executor {
|
|
|
71
71
|
Object.fromEntries(names.map((dep) => [dep, dependencyVersions.get(dep) as string]));
|
|
72
72
|
return { dependencies: toDependencyMap(dependencyNames), devDependencies: toDependencyMap(devDependencyNames) };
|
|
73
73
|
}
|
|
74
|
-
async
|
|
74
|
+
async updateDistPackageJsonDependencies(
|
|
75
75
|
dependencies: string[] = [],
|
|
76
76
|
devDependencies: string[] = [],
|
|
77
|
-
): Promise<PackageJson> {
|
|
78
|
-
|
|
77
|
+
): Promise<PackageJson | null> {
|
|
78
|
+
if (!(await this.dist.exists("package.json"))) return null;
|
|
79
|
+
const [rootPackageJson, distPkgJson] = await Promise.all([
|
|
80
|
+
this.workspace.getPackageJson(),
|
|
81
|
+
this.dist.readJson("package.json") as Promise<PackageJson>,
|
|
82
|
+
]);
|
|
79
83
|
const dependencyMaps = await this.#toDependencyMap(rootPackageJson, dependencies, devDependencies);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return newPkgJson;
|
|
84
|
+
//? A build script that drops a dependency field from its manifest has bundled those packages into its output.
|
|
85
|
+
const keptMaps = Object.fromEntries(Object.entries(dependencyMaps).filter(([field]) => field in distPkgJson));
|
|
86
|
+
const newDistPkgJson: PackageJson = { ...distPkgJson, ...keptMaps };
|
|
87
|
+
await this.dist.writeJson("package.json", newDistPkgJson);
|
|
88
|
+
return newDistPkgJson;
|
|
86
89
|
}
|
|
87
90
|
async generateDistPackageJson(dependencies: string[] = [], devDependencies: string[] = []): Promise<PackageJson> {
|
|
88
91
|
const [rootPackageJson, pkgJson] = await Promise.all([this.workspace.getPackageJson(), this.getPackageJson()]);
|
|
@@ -101,7 +104,7 @@ export class PkgExecutor extends Executor {
|
|
|
101
104
|
engines: { bun: ">=1.4.4" },
|
|
102
105
|
...dependencyMaps,
|
|
103
106
|
};
|
|
104
|
-
await
|
|
107
|
+
await this.dist.writeJson("package.json", distPkgJson);
|
|
105
108
|
return distPkgJson;
|
|
106
109
|
}
|
|
107
110
|
async build(): Promise<void> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "3.4.0-rc.
|
|
3
|
+
"version": "3.4.0-rc.1",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@akanjs/language": "3.4.0-rc.
|
|
55
|
+
"@akanjs/language": "3.4.0-rc.1",
|
|
56
56
|
"@inquirer/prompts": "^8.7.3",
|
|
57
57
|
"@tailwindcss/node": "^4.3.3",
|
|
58
|
-
"akanjs": "3.4.0-rc.
|
|
58
|
+
"akanjs": "3.4.0-rc.1",
|
|
59
59
|
"chalk": "^6.0.1",
|
|
60
60
|
"commander": "^15.0.0",
|
|
61
61
|
"dayjs": "^1.11.23",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"fonteditor-core": "^2.6.3",
|
|
64
64
|
"ignore": "^7.0.12",
|
|
65
65
|
"ora": "^9.4.1",
|
|
66
|
-
"react-server-dom-webpack": "^19.3.1",
|
|
67
66
|
"subset-font": "^2.9.0",
|
|
68
67
|
"tailwind-scrollbar": "^4.0.2",
|
|
69
68
|
"tailwindcss": "^4.3.3",
|
|
@@ -668,7 +668,7 @@ describe("PipelineCompiler", () => {
|
|
|
668
668
|
});
|
|
669
669
|
});
|
|
670
670
|
|
|
671
|
-
test("is skipped with the app's earlier action,
|
|
671
|
+
test("is skipped with the app's earlier action, and takes when.changed like any action", () => {
|
|
672
672
|
const plan = planOf(
|
|
673
673
|
compile({
|
|
674
674
|
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
@@ -676,7 +676,8 @@ describe("PipelineCompiler", () => {
|
|
|
676
676
|
apps: {
|
|
677
677
|
web: {
|
|
678
678
|
stages: [
|
|
679
|
-
{ use: "
|
|
679
|
+
{ use: "build" },
|
|
680
|
+
{ use: "deploy", when: { branch: "main" } },
|
|
680
681
|
{ use: "desktop-ota", platforms: [mac], when: { changed: ["apps/web/**"] } },
|
|
681
682
|
],
|
|
682
683
|
},
|
|
@@ -684,11 +685,56 @@ describe("PipelineCompiler", () => {
|
|
|
684
685
|
}),
|
|
685
686
|
);
|
|
686
687
|
expect(desktopPhase(plan)?.stages[0]).toMatchObject({
|
|
687
|
-
skip: { reason: "
|
|
688
|
+
skip: { reason: "deploy of web is skipped" },
|
|
688
689
|
runtimeWhen: { changed: ["apps/web/**"] },
|
|
689
690
|
});
|
|
690
691
|
});
|
|
691
692
|
|
|
693
|
+
test("never takes on the skip of ota, a separate release, but takes the one of the action before it", () => {
|
|
694
|
+
const lanes = (deploy: { branch: string } | undefined) =>
|
|
695
|
+
planOf(
|
|
696
|
+
compile({
|
|
697
|
+
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
698
|
+
nativeTargets: webTargets,
|
|
699
|
+
apps: {
|
|
700
|
+
web: {
|
|
701
|
+
stages: [
|
|
702
|
+
{ use: "build" },
|
|
703
|
+
{ use: "deploy", ...(deploy ? { when: deploy } : {}) },
|
|
704
|
+
{ use: "ota", when: { branch: "release" } },
|
|
705
|
+
{ use: "desktop-ota", platforms: [mac] },
|
|
706
|
+
],
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
}),
|
|
710
|
+
);
|
|
711
|
+
const released = lanes(undefined);
|
|
712
|
+
expect(released.phases.find((phase) => phase.action === "ota")?.stages[0]?.skip).toEqual({
|
|
713
|
+
reason: 'branch "develop" does not match "release"',
|
|
714
|
+
});
|
|
715
|
+
expect(desktopPhase(released)?.stages[0]?.skip).toBeNull();
|
|
716
|
+
const undeployed = lanes({ branch: "main" });
|
|
717
|
+
expect(undeployed.phases.find((phase) => phase.action === "ota")?.stages[0]?.skip).toEqual({
|
|
718
|
+
reason: 'branch "develop" does not match "release"',
|
|
719
|
+
});
|
|
720
|
+
expect(desktopPhase(undeployed)?.stages[0]?.skip).toEqual({ reason: "deploy of web is skipped" });
|
|
721
|
+
const alone = planOf(
|
|
722
|
+
compile({
|
|
723
|
+
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
724
|
+
nativeTargets: webTargets,
|
|
725
|
+
apps: {
|
|
726
|
+
web: {
|
|
727
|
+
stages: [
|
|
728
|
+
{ use: "ota", when: { branch: "release" } },
|
|
729
|
+
{ use: "desktop-ota", platforms: [mac] },
|
|
730
|
+
],
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
}),
|
|
734
|
+
);
|
|
735
|
+
expect(desktopPhase(alone)?.stages[0]?.skip).toBeNull();
|
|
736
|
+
});
|
|
737
|
+
|
|
692
738
|
test("a workspace stage may not take the id of its phase or of the slot behind it", () => {
|
|
693
739
|
for (const name of ["Desktop OTA", "After desktop OTA", "After desktop OTA 2"])
|
|
694
740
|
expect(codes(compile({ workspace: { before: [{ name, sh: "x" }] } }))).toEqual(["pipeline.id.reserved"]);
|
|
@@ -359,7 +359,8 @@ export class PipelineCompiler {
|
|
|
359
359
|
if (!stage) continue;
|
|
360
360
|
const inherited = previous && lane.skips.get(previous) ? { reason: `${previous} of ${app} is skipped` } : null;
|
|
361
361
|
lane.skips.set(action, this.#skipOf(stage.when) ?? inherited);
|
|
362
|
-
|
|
362
|
+
//? A phone bundle and a desktop app are separate releases: `desktop-ota` never takes on `ota`'s skip.
|
|
363
|
+
if (action !== "ota") previous = action;
|
|
363
364
|
}
|
|
364
365
|
return lane;
|
|
365
366
|
}
|
|
@@ -93,7 +93,7 @@ describe("RuntimeImports", () => {
|
|
|
93
93
|
}
|
|
94
94
|
expect(skipped).toEqual([]);
|
|
95
95
|
expect(resolved).toBeGreaterThan(20000);
|
|
96
|
-
});
|
|
96
|
+
}, 30_000);
|
|
97
97
|
|
|
98
98
|
test("reads a specifier through its extension, index, doubled slashes and dot segments", () => {
|
|
99
99
|
const file = "apps/demo/lib/memo/Memo.Zone.tsx";
|
|
@@ -84,4 +84,14 @@ describe("TypeScriptDependencyScanner — getPackageBuildDependencies", () => {
|
|
|
84
84
|
|
|
85
85
|
expect((await scanner.getPackageBuildDependencies("@akanjs/devkit")).missingDeps).toEqual(["pkg-b"]);
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
test("skips a *.fixture.* file, which only a test loads", async () => {
|
|
89
|
+
const root = await makeTempRoot();
|
|
90
|
+
await write(root, "pkgs/@akanjs/devkit/transforms/render.fixture.tsx", `await import("pkg-a/server.node");\n`);
|
|
91
|
+
await write(root, "pkgs/@akanjs/devkit/quality/table.fixture.ts", `import b from "pkg-b";\nexport const x = b;\n`);
|
|
92
|
+
await write(root, "pkgs/@akanjs/devkit/transforms/render.ts", `import c from "pkg-c";\nexport const x = c;\n`);
|
|
93
|
+
const scanner = await scannerFor(root);
|
|
94
|
+
|
|
95
|
+
expect((await scanner.getPackageBuildDependencies("@akanjs/devkit")).missingDeps).toEqual(["pkg-c"]);
|
|
96
|
+
});
|
|
87
97
|
});
|
|
@@ -6,7 +6,7 @@ import type { App, Lib, Pkg } from "../commandDecorators";
|
|
|
6
6
|
import { FileSys } from "../util/fileSys";
|
|
7
7
|
import type { PackageJson, TsConfigJson } from "./types";
|
|
8
8
|
|
|
9
|
-
const testFileRegex = /\.(?:test|spec)\.[cm]?[tj]sx?$/;
|
|
9
|
+
const testFileRegex = /\.(?:test|spec|fixture)\.[cm]?[tj]sx?$/;
|
|
10
10
|
// `__fixtures__` holds deliberately invalid lint-rule samples, whose imports are violations, not dependencies.
|
|
11
11
|
const skipDirs = ["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android", "__fixtures__"];
|
|
12
12
|
const isSkippedPath = (filePath: string) => {
|