@jointhedots/gear 1.2.2 → 1.2.3
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/esm/builder/build-app-bundle.d.ts +1 -0
- package/esm/builder/build-app-bundle.js +9 -5
- package/esm/builder/build-app-host.js +20 -18
- package/esm/builder/build-application.d.ts +4 -0
- package/esm/builder/build-application.js +52 -72
- package/esm/builder/build-library.d.ts +1 -0
- package/esm/builder/build-library.js +12 -8
- package/esm/builder/build-target.d.ts +13 -4
- package/esm/builder/build-target.js +20 -11
- package/esm/builder/helpers/emit-artifact.d.ts +13 -0
- package/esm/builder/helpers/emit-artifact.js +40 -0
- package/esm/builder/helpers/emit-bundle-manifest.d.ts +12 -2
- package/esm/builder/helpers/emit-bundle-manifest.js +37 -14
- package/esm/builder/helpers/emit-esmodules.d.ts +2 -2
- package/esm/builder/helpers/emit-esmodules.js +17 -17
- package/esm/builder/helpers/emit-package-manifest.js +1 -1
- package/esm/builder/helpers/emit-typescript-definition.js +1 -1
- package/esm/commands/install.js +1 -1
- package/esm/commands/make.d.ts +1 -0
- package/esm/commands/make.js +10 -2
- package/esm/commands/serve.js +8 -9
- package/esm/workspace/helpers/create-manifests.js +3 -3
- package/esm/workspace/helpers/discover-workspace.d.ts +2 -2
- package/esm/workspace/helpers/discover-workspace.js +19 -29
- package/esm/workspace/helpers/lockfile.d.ts +3 -3
- package/esm/workspace/helpers/lockfile.js +13 -13
- package/esm/workspace/helpers/logger.d.ts +1 -1
- package/esm/workspace/helpers/logger.js +1 -1
- package/esm/workspace/packagers/packager-standard.js +3 -3
- package/esm/workspace/workspace.d.ts +11 -7
- package/esm/workspace/workspace.js +26 -14
- package/package.json +74 -73
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BundleManifest } from "../../workspace/component.ts";
|
|
2
|
+
import { type AppDescriptor, type Bundle } from "../../workspace/workspace.ts";
|
|
2
3
|
import { BuildTarget } from "../build-target.ts";
|
|
3
4
|
import { BuildTask } from "./task.ts";
|
|
4
|
-
export declare class
|
|
5
|
+
export declare abstract class BaseManifestTask extends BuildTask {
|
|
6
|
+
write_manifest(manifest: BundleManifest): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class BundleManifestTask extends BaseManifestTask {
|
|
5
9
|
readonly target: BuildTarget;
|
|
6
10
|
readonly bundle: Bundle;
|
|
7
11
|
constructor(target: BuildTarget, bundle: Bundle);
|
|
8
12
|
execute(): Promise<void>;
|
|
9
13
|
}
|
|
14
|
+
export declare class ApplicationManifestTask extends BaseManifestTask {
|
|
15
|
+
readonly target: BuildTarget;
|
|
16
|
+
readonly app: AppDescriptor;
|
|
17
|
+
constructor(target: BuildTarget, app: AppDescriptor);
|
|
18
|
+
execute(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { makeComponentPublication } from "../../workspace/component.js";
|
|
2
|
+
import { Library } from "../../workspace/workspace.js";
|
|
2
3
|
import { BuildTarget } from "../build-target.js";
|
|
3
4
|
import { BuildTask } from "./task.js";
|
|
4
5
|
import MIME from "mime";
|
|
5
|
-
export class
|
|
6
|
+
export class BaseManifestTask extends BuildTask {
|
|
7
|
+
async write_manifest(manifest) {
|
|
8
|
+
const tx = this.target.edit();
|
|
9
|
+
const pubs = [];
|
|
10
|
+
for (const manif of this.target.components.values()) {
|
|
11
|
+
const pub = makeComponentPublication(manif);
|
|
12
|
+
pub.ref = await tx.commitContent(JSON.stringify(manif, null, 2), MIME.getType(".json"));
|
|
13
|
+
pubs.push(pub);
|
|
14
|
+
}
|
|
15
|
+
manifest.data.components = pubs;
|
|
16
|
+
await tx.commitFile(`bundle.manifest.json`, JSON.stringify(manifest, null, 2));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class BundleManifestTask extends BaseManifestTask {
|
|
6
20
|
target;
|
|
7
21
|
bundle;
|
|
8
22
|
constructor(target, bundle) {
|
|
@@ -11,18 +25,27 @@ export class BundleManifestTask extends BuildTask {
|
|
|
11
25
|
this.bundle = bundle;
|
|
12
26
|
}
|
|
13
27
|
async execute() {
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const { bundle } = this;
|
|
29
|
+
await this.write_manifest(bundle.manifest);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class ApplicationManifestTask extends BaseManifestTask {
|
|
33
|
+
target;
|
|
34
|
+
app;
|
|
35
|
+
constructor(target, app) {
|
|
36
|
+
super(target);
|
|
37
|
+
this.target = target;
|
|
38
|
+
this.app = app;
|
|
39
|
+
}
|
|
40
|
+
async execute() {
|
|
41
|
+
const { target, app } = this;
|
|
42
|
+
await this.write_manifest({
|
|
43
|
+
$id: target.name,
|
|
44
|
+
name: app.name,
|
|
45
|
+
icon: app.icon,
|
|
46
|
+
title: app.title,
|
|
47
|
+
description: app.description,
|
|
48
|
+
data: {},
|
|
49
|
+
});
|
|
27
50
|
}
|
|
28
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as esbuild from "esbuild";
|
|
2
2
|
import type { Log } from "../../workspace/helpers/logger.ts";
|
|
3
|
-
import { Library } from "../../workspace/workspace.ts";
|
|
3
|
+
import { Library, WorkspaceItem } from "../../workspace/workspace.ts";
|
|
4
4
|
import type { ResourceEntry } from "../../workspace/component.ts";
|
|
5
5
|
import type { IStorageTransaction } from "../../workspace/storage.ts";
|
|
6
6
|
import { BuildTask } from "./task.ts";
|
|
@@ -56,6 +56,6 @@ export declare class ESModulesTask extends BuildTask {
|
|
|
56
56
|
set_root(path: string): void;
|
|
57
57
|
add_entry(name: string, path: string): void;
|
|
58
58
|
add_entry_typescript(code: string, name?: string): string;
|
|
59
|
-
add_resource_entry(resource: ResourceEntry, baseDir: string,
|
|
59
|
+
add_resource_entry(resource: ResourceEntry, baseDir: string, origin: WorkspaceItem): ResourceEntry;
|
|
60
60
|
execute(): Promise<void>;
|
|
61
61
|
}
|
|
@@ -6,7 +6,7 @@ import postcss from "postcss";
|
|
|
6
6
|
import * as esbuild from "esbuild";
|
|
7
7
|
import { sassPlugin } from "esbuild-sass-plugin";
|
|
8
8
|
import { PackageRootDir, resolve_normalized_suffixed_path } from "../../utils/file.js";
|
|
9
|
-
import { Library } from "../../workspace/workspace.js";
|
|
9
|
+
import { Library, WorkspaceItem } from "../../workspace/workspace.js";
|
|
10
10
|
import { computeNameHashID } from "../../utils/normalized-name.js";
|
|
11
11
|
import { BuildTask } from "./task.js";
|
|
12
12
|
const VirtualOutDir = process.platform === 'win32' ? 'X:\\' : '/_/';
|
|
@@ -22,7 +22,7 @@ function getEsbuildLogLevel(mode) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
async function create_esbuild_context(task, devmode, onReady) {
|
|
25
|
-
const
|
|
25
|
+
const { library } = task.target;
|
|
26
26
|
// Define modules mapping - using @jspm/core polyfills (same as Vite)
|
|
27
27
|
const jspmPolyfills = Path.resolve(PackageRootDir, "node_modules/@jspm/core/nodelibs/browser");
|
|
28
28
|
// Side effects script that provides Node.js globals (like Buffer) for browser environment
|
|
@@ -52,7 +52,7 @@ async function create_esbuild_context(task, devmode, onReady) {
|
|
|
52
52
|
}
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
55
|
-
const tsconfig = new TSConfig(task.rootPath,
|
|
55
|
+
const tsconfig = new TSConfig(task.rootPath, library.path);
|
|
56
56
|
const modules_mapping = {
|
|
57
57
|
task,
|
|
58
58
|
routeds: {
|
|
@@ -76,9 +76,9 @@ async function create_esbuild_context(task, devmode, onReady) {
|
|
|
76
76
|
} : {}
|
|
77
77
|
};
|
|
78
78
|
// Define constants
|
|
79
|
-
const
|
|
79
|
+
const constants = Object.keys(library.constants).reduce((prev, key) => {
|
|
80
80
|
const name = `constants.${key}`;
|
|
81
|
-
prev[name] = JSON.stringify(
|
|
81
|
+
prev[name] = JSON.stringify(library.constants[key]);
|
|
82
82
|
return prev;
|
|
83
83
|
}, {});
|
|
84
84
|
const options = {
|
|
@@ -94,7 +94,7 @@ async function create_esbuild_context(task, devmode, onReady) {
|
|
|
94
94
|
splitting: true,
|
|
95
95
|
treeShaking: true,
|
|
96
96
|
write: false,
|
|
97
|
-
logLevel: getEsbuildLogLevel(
|
|
97
|
+
logLevel: getEsbuildLogLevel(library.log.logger.mode),
|
|
98
98
|
chunkNames: "chunk.[hash]",
|
|
99
99
|
jsx: "automatic",
|
|
100
100
|
jsxImportSource: "react",
|
|
@@ -105,7 +105,7 @@ async function create_esbuild_context(task, devmode, onReady) {
|
|
|
105
105
|
'global': 'globalThis',
|
|
106
106
|
"process.browser": "true",
|
|
107
107
|
"process.env.NODE_ENV": JSON.stringify(devmode ? "development" : "production"),
|
|
108
|
-
...
|
|
108
|
+
...constants,
|
|
109
109
|
},
|
|
110
110
|
plugins: [
|
|
111
111
|
ESModuleResolverPlugin(modules_mapping, tsconfig),
|
|
@@ -205,8 +205,8 @@ function copyAssets(task) {
|
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
export function StyleSheetPlugin(task) {
|
|
208
|
-
const
|
|
209
|
-
const useTailwind = hasTailwindConfig(
|
|
208
|
+
const rootPath = task.target.library.path;
|
|
209
|
+
const useTailwind = hasTailwindConfig(rootPath);
|
|
210
210
|
if (useTailwind) {
|
|
211
211
|
task.log.info(`+ 🎨 Tailwind CSS detected`);
|
|
212
212
|
}
|
|
@@ -216,7 +216,7 @@ export function StyleSheetPlugin(task) {
|
|
|
216
216
|
const plugins = [];
|
|
217
217
|
if (useTailwind) {
|
|
218
218
|
const tailwindcss = (await import('@tailwindcss/postcss')).default;
|
|
219
|
-
plugins.push(tailwindcss({ base:
|
|
219
|
+
plugins.push(tailwindcss({ base: rootPath }));
|
|
220
220
|
}
|
|
221
221
|
plugins.push(copyAssets(task));
|
|
222
222
|
const { css } = await postcss(plugins)
|
|
@@ -495,7 +495,7 @@ export function ESModuleResolverPlugin(opts, tsconfigPaths) {
|
|
|
495
495
|
name: 'esm-resolver',
|
|
496
496
|
setup(build) {
|
|
497
497
|
const { routeds = {}, replaceds = {}, task } = opts;
|
|
498
|
-
const
|
|
498
|
+
const rootPath = task.target.library.path;
|
|
499
499
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
500
500
|
// 0. Check for internal modules
|
|
501
501
|
if (task.internals.has(args.path)) {
|
|
@@ -526,7 +526,7 @@ export function ESModuleResolverPlugin(opts, tsconfigPaths) {
|
|
|
526
526
|
}
|
|
527
527
|
// 3. Handle relative/absolute file paths (entry points and local imports)
|
|
528
528
|
if (args.path.startsWith(".") || args.path.startsWith("/") || Path.isAbsolute(args.path)) {
|
|
529
|
-
const baseDir = args.resolveDir ||
|
|
529
|
+
const baseDir = args.resolveDir || rootPath;
|
|
530
530
|
const resolved = resolve_normalized_suffixed_path(baseDir, args.path);
|
|
531
531
|
if (resolved) {
|
|
532
532
|
return { path: resolved, namespace: "file" };
|
|
@@ -550,7 +550,7 @@ export function ESModuleResolverPlugin(opts, tsconfigPaths) {
|
|
|
550
550
|
}
|
|
551
551
|
const ext = Path.extname(args.path) || ".ts";
|
|
552
552
|
const loader = internalLoaders[ext] ?? "ts";
|
|
553
|
-
return { contents, loader, resolveDir:
|
|
553
|
+
return { contents, loader, resolveDir: rootPath };
|
|
554
554
|
});
|
|
555
555
|
},
|
|
556
556
|
};
|
|
@@ -579,20 +579,20 @@ export class ESModulesTask extends BuildTask {
|
|
|
579
579
|
this.add_entry(name, id);
|
|
580
580
|
return name;
|
|
581
581
|
}
|
|
582
|
-
add_resource_entry(resource, baseDir,
|
|
582
|
+
add_resource_entry(resource, baseDir, origin) {
|
|
583
583
|
if (typeof resource === "string") {
|
|
584
584
|
const parts = resource.split("#");
|
|
585
|
-
const file =
|
|
585
|
+
const file = origin.resolve_entry_path(parts[0], baseDir);
|
|
586
586
|
if (file) {
|
|
587
587
|
let named = this.imports[file];
|
|
588
588
|
if (!named) {
|
|
589
|
-
named =
|
|
589
|
+
named = origin.make_file_id("lambda", file);
|
|
590
590
|
this.add_entry(named, file);
|
|
591
591
|
}
|
|
592
592
|
return `./${named}.js#${parts[1] || "default"}`;
|
|
593
593
|
}
|
|
594
594
|
else {
|
|
595
|
-
|
|
595
|
+
origin.log.error(`Cannot resolve build resource file at: ${parts[0]}`);
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
else {
|
|
@@ -11,7 +11,7 @@ export class PackageManifestTask extends BuildTask {
|
|
|
11
11
|
}
|
|
12
12
|
async execute() {
|
|
13
13
|
const { library, version } = this;
|
|
14
|
-
const pkg = create_package_manifest(library, library.
|
|
14
|
+
const pkg = create_package_manifest(library, library.master, version);
|
|
15
15
|
const tx = this.target.edit();
|
|
16
16
|
tx.commitFile("package.json", JSON.stringify(pkg, null, 2));
|
|
17
17
|
}
|
|
@@ -278,7 +278,7 @@ export class TypescriptDefinitionTask extends BuildTask {
|
|
|
278
278
|
project,
|
|
279
279
|
prefix: lib.name + ":",
|
|
280
280
|
exclude: ["node_modules/**/*"],
|
|
281
|
-
exports: create_export_map(lib, lib.
|
|
281
|
+
exports: create_export_map(lib, lib.master),
|
|
282
282
|
});
|
|
283
283
|
file.write.text(storage.getBaseDirFS() + "/types.d.ts", dts);
|
|
284
284
|
project.cleanup();
|
package/esm/commands/install.js
CHANGED
|
@@ -29,7 +29,7 @@ export function command_install() {
|
|
|
29
29
|
// Select all workspace bundles
|
|
30
30
|
const selector = new BundleSelector(ws);
|
|
31
31
|
for (const lib of ws.libraries) {
|
|
32
|
-
selector.add(lib.
|
|
32
|
+
selector.add(lib.master);
|
|
33
33
|
}
|
|
34
34
|
if (selector.missing.length > 0) {
|
|
35
35
|
ws.log.warn(`Missing bundle dependencies: ${selector.missing.join(", ")}`);
|
package/esm/commands/make.d.ts
CHANGED
package/esm/commands/make.js
CHANGED
|
@@ -59,6 +59,10 @@ export function command_make() {
|
|
|
59
59
|
.option("dist", {
|
|
60
60
|
type: "string",
|
|
61
61
|
default: "./dist",
|
|
62
|
+
})
|
|
63
|
+
.option("artifact-dir", {
|
|
64
|
+
type: "string",
|
|
65
|
+
describe: "Directory to write output artifacts (npm if package.json, zip otherwise)",
|
|
62
66
|
}),
|
|
63
67
|
handler: async (argv) => {
|
|
64
68
|
const ws = await open_workspace({
|
|
@@ -89,8 +93,8 @@ export function command_make() {
|
|
|
89
93
|
const bundles = [];
|
|
90
94
|
if (argv.bundles === "*") {
|
|
91
95
|
for (const lib of ws.libraries) {
|
|
92
|
-
if (lib.
|
|
93
|
-
bundles.push(lib.
|
|
96
|
+
if (lib.master)
|
|
97
|
+
bundles.push(lib.master);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
else if (argv.bundles) {
|
|
@@ -112,6 +116,7 @@ export function command_make() {
|
|
|
112
116
|
ws.log.error(`application not found: ${appname}`);
|
|
113
117
|
}
|
|
114
118
|
}
|
|
119
|
+
const artifactDir = argv.artifactDir ? Path.resolve(argv.artifactDir) : undefined;
|
|
115
120
|
const pendings = [];
|
|
116
121
|
if (bundles.length > 0) {
|
|
117
122
|
const shelve = new StorageFiles("shelve", Path.resolve(argv.dist, "shelve"));
|
|
@@ -123,6 +128,7 @@ export function command_make() {
|
|
|
123
128
|
devmode: argv.devmode,
|
|
124
129
|
watch: argv.watch,
|
|
125
130
|
clean: argv.clean || !argv.devmode,
|
|
131
|
+
artifactDir,
|
|
126
132
|
}));
|
|
127
133
|
}
|
|
128
134
|
}
|
|
@@ -137,6 +143,7 @@ export function command_make() {
|
|
|
137
143
|
devmode: argv.devmode,
|
|
138
144
|
watch: argv.watch,
|
|
139
145
|
clean: argv.clean || !argv.devmode,
|
|
146
|
+
artifactDir,
|
|
140
147
|
}));
|
|
141
148
|
}
|
|
142
149
|
for (const lib of libraries) {
|
|
@@ -149,6 +156,7 @@ export function command_make() {
|
|
|
149
156
|
devmode: argv.devmode,
|
|
150
157
|
watch: argv.watch,
|
|
151
158
|
clean: argv.clean || !argv.devmode,
|
|
159
|
+
artifactDir,
|
|
152
160
|
}, argv.pack ? Path.resolve(argv.dist) : null));
|
|
153
161
|
}
|
|
154
162
|
await Promise.all(pendings);
|
package/esm/commands/serve.js
CHANGED
|
@@ -54,22 +54,21 @@ export function command_serve() {
|
|
|
54
54
|
}
|
|
55
55
|
const outputDir = Path.resolve(argv.dist, makeNormalizedName(argv.app, NameStyle.WEBC));
|
|
56
56
|
const storage = new StorageFiles(ws.name, outputDir);
|
|
57
|
+
let serverStarted = false;
|
|
57
58
|
const building = build_application({
|
|
58
59
|
app,
|
|
59
60
|
storage,
|
|
60
61
|
version,
|
|
61
62
|
devmode: argv.devmode,
|
|
62
63
|
devserver: argv.port && `http://localhost:${argv.port}`,
|
|
64
|
+
onNotification(event) {
|
|
65
|
+
if (event.type === "build-complete" && !serverStarted && argv.port) {
|
|
66
|
+
serverStarted = true;
|
|
67
|
+
serve(ws, argv.port, storage);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
63
70
|
});
|
|
64
|
-
|
|
65
|
-
await Promise.all([
|
|
66
|
-
building,
|
|
67
|
-
serve(ws, argv.port, storage)
|
|
68
|
-
]);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
await building;
|
|
72
|
-
}
|
|
71
|
+
await building;
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
}
|
|
@@ -20,8 +20,8 @@ export function create_export_map(lib, bun) {
|
|
|
20
20
|
const exports = {};
|
|
21
21
|
if (bun) {
|
|
22
22
|
for (const id in bun.distribueds) {
|
|
23
|
-
const basename =
|
|
24
|
-
const entry =
|
|
23
|
+
const basename = bun.make_file_id("redist", id);
|
|
24
|
+
const entry = bun.resolve_entry_path(id, lib.path);
|
|
25
25
|
exports[id] = {
|
|
26
26
|
id,
|
|
27
27
|
basename: basename,
|
|
@@ -84,7 +84,7 @@ export function create_package_manifest(lib, bun, build_version) {
|
|
|
84
84
|
optionalDependencies: undefined,
|
|
85
85
|
};
|
|
86
86
|
if (pkg_manif.dependencies) {
|
|
87
|
-
const resolved = lib.resolved_versions;
|
|
87
|
+
const resolved = lib.deps.resolved_versions;
|
|
88
88
|
for (const dep in pkg_manif.dependencies) {
|
|
89
89
|
if (pkg_manif.dependencies[dep] === "*") {
|
|
90
90
|
const dep_resolved = resolved[dep];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Library, Workspace } from "../workspace.ts";
|
|
2
|
-
export declare function discover_component(
|
|
1
|
+
import { Bundle, Library, Workspace } from "../workspace.ts";
|
|
2
|
+
export declare function discover_component(bundle: Bundle, fpath: string): Promise<boolean>;
|
|
3
3
|
export declare function discover_library_definitions(lib: Library, path: string, subdir?: boolean): Promise<void>;
|
|
4
4
|
export declare function discover_workspace(ws: Workspace): Promise<Workspace>;
|
|
@@ -2,8 +2,6 @@ import Fs from "node:fs";
|
|
|
2
2
|
import Fsp from "node:fs/promises";
|
|
3
3
|
import { readJsonFile } from "../storage.js";
|
|
4
4
|
import { checkComponentManifest } from "../component.js";
|
|
5
|
-
import { makeNormalizedName, NameStyle } from "../../utils/normalized-name.js";
|
|
6
|
-
import { create_bundle_manifest } from "./create-manifests.js";
|
|
7
5
|
import { Bundle, Library, Workspace } from "../workspace.js";
|
|
8
6
|
import { file, make_canonical_path, make_normalized_dirname, make_normalized_path, make_relative_path } from "../../utils/file.js";
|
|
9
7
|
import { findConfigFile, is_config_filename, readConfigFile, readSingletonConfigFile } from "./config-loader.js";
|
|
@@ -20,8 +18,7 @@ function is_ignored_dir(ws, path) {
|
|
|
20
18
|
}
|
|
21
19
|
return false;
|
|
22
20
|
}
|
|
23
|
-
export async function discover_component(
|
|
24
|
-
const { bundle } = lib;
|
|
21
|
+
export async function discover_component(bundle, fpath) {
|
|
25
22
|
if (bundle.components.has(fpath)) {
|
|
26
23
|
return true;
|
|
27
24
|
}
|
|
@@ -35,18 +32,18 @@ export async function discover_component(lib, fpath) {
|
|
|
35
32
|
throw err;
|
|
36
33
|
if (!desc.apis && desc["services"]) {
|
|
37
34
|
desc.apis = desc["services"]; // Migrate renaming 'services' -> 'apis'
|
|
38
|
-
|
|
35
|
+
bundle.log.warn(`Component '${desc.$id}' manifest shall rename 'services' -> 'apis'`);
|
|
39
36
|
}
|
|
40
37
|
bundle.components.set(fpath, desc);
|
|
41
|
-
|
|
38
|
+
bundle.log.info(`+ 🧩 component: ${desc.$id} ${desc.type ? `(${desc.type})` : ""}`);
|
|
42
39
|
return true;
|
|
43
40
|
}
|
|
44
41
|
else if (bundle.path !== make_normalized_dirname(fpath)) {
|
|
45
|
-
|
|
42
|
+
bundle.log.error(`invalid bundle component at ${fpath}`);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
catch (e) {
|
|
49
|
-
|
|
46
|
+
bundle.log.error(`invalid component at ${fpath}: ${e?.message}`);
|
|
50
47
|
}
|
|
51
48
|
return false;
|
|
52
49
|
}
|
|
@@ -86,14 +83,12 @@ export async function discover_library_definitions(lib, path, subdir = false) {
|
|
|
86
83
|
const fstat = await Fsp.stat(fpath);
|
|
87
84
|
if (fstat.isDirectory()) {
|
|
88
85
|
if (!exclude_dirs.includes(fname)) {
|
|
89
|
-
|
|
90
|
-
await discover_library_definitions(lib, fpath, true);
|
|
91
|
-
}
|
|
86
|
+
await discover_library_definitions(lib, fpath, true);
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
89
|
else if (fstat.isFile()) {
|
|
95
90
|
if (is_config_filename(fname, "component")) {
|
|
96
|
-
await discover_component(lib, fpath);
|
|
91
|
+
await discover_component(lib.master, fpath);
|
|
97
92
|
}
|
|
98
93
|
else if (is_config_filename(fname, "application")) {
|
|
99
94
|
await discover_application(lib, fpath);
|
|
@@ -145,7 +140,6 @@ async function discover_library(ws, location) {
|
|
|
145
140
|
ws.libraries.push(lib);
|
|
146
141
|
ws.log.info(`+ 📚 library: ${lib.get_id()} (${make_relative_path(ws.path, location)})`);
|
|
147
142
|
// Discover library-level search_directories, lockfile, and constants (walk up to workspace root)
|
|
148
|
-
let lockfile = null;
|
|
149
143
|
lib.constants = { ...ws.constants };
|
|
150
144
|
for (let path = lib.path;;) {
|
|
151
145
|
const package_json = await readJsonFile(path + "/package.json");
|
|
@@ -161,24 +155,20 @@ async function discover_library(ws, location) {
|
|
|
161
155
|
};
|
|
162
156
|
}
|
|
163
157
|
}
|
|
164
|
-
if (!
|
|
165
|
-
|
|
158
|
+
if (!lib.deps) {
|
|
159
|
+
lib.deps = await read_lockfile(path);
|
|
166
160
|
}
|
|
167
161
|
const next_path = make_normalized_dirname(path);
|
|
168
162
|
if (next_path === path)
|
|
169
163
|
break;
|
|
170
164
|
path = next_path;
|
|
171
165
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
throw new Error(`Lock file not found for '${ws.name}'`);
|
|
166
|
+
if (!lib.deps)
|
|
167
|
+
throw new Error(`Lock file not found for '${lib.name}'`);
|
|
168
|
+
// Discover side bundles from lock file
|
|
169
|
+
for (const dep_id in lib.descriptor.dependencies) {
|
|
170
|
+
const dep_path = lib.deps.resolved_paths[dep_id];
|
|
171
|
+
await discover_bundle(lib, dep_path);
|
|
182
172
|
}
|
|
183
173
|
// Load library packager
|
|
184
174
|
let packager = null;
|
|
@@ -217,15 +207,15 @@ async function discover_bundle(lib, location) {
|
|
|
217
207
|
return Discovered.Ignored;
|
|
218
208
|
}
|
|
219
209
|
}
|
|
220
|
-
|
|
221
|
-
lib.
|
|
210
|
+
// Register bundle into library
|
|
211
|
+
const bun = new Bundle(bun_manif, lib.path, lib);
|
|
222
212
|
lib.shelve.push(bun);
|
|
223
213
|
lib.log.info(`+ 📦 bundle: ${bun.id} ⏬`);
|
|
224
214
|
// Analyze library deployment manifest (supports json/yaml/yml/toml, singleton)
|
|
225
215
|
if (bun_manif?.data?.components) {
|
|
226
216
|
for (const pub of bun_manif.data.components) {
|
|
227
|
-
const fpath =
|
|
228
|
-
await discover_component(
|
|
217
|
+
const fpath = bun_path + "/" + (pub.ref ?? pub.id);
|
|
218
|
+
await discover_component(bun, fpath);
|
|
229
219
|
}
|
|
230
220
|
}
|
|
231
221
|
return Discovered.Registered;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type PackageDepsInfo = {
|
|
2
2
|
resolved_versions: Record<string, string>;
|
|
3
|
-
|
|
3
|
+
resolved_paths: Record<string, string>;
|
|
4
4
|
};
|
|
5
|
-
export declare function read_lockfile(dir: string): Promise<
|
|
5
|
+
export declare function read_lockfile(dir: string): Promise<PackageDepsInfo | null>;
|
|
@@ -19,27 +19,27 @@ export async function read_lockfile(dir) {
|
|
|
19
19
|
}
|
|
20
20
|
function parse_npm_lockfile(lock) {
|
|
21
21
|
const resolved_versions = {};
|
|
22
|
-
const
|
|
22
|
+
const resolved_paths = {};
|
|
23
23
|
for (const location in lock.packages) {
|
|
24
24
|
if (!location)
|
|
25
25
|
continue;
|
|
26
|
-
installed_locations.push(location);
|
|
27
26
|
if (location.startsWith("node_modules/")) {
|
|
28
27
|
let pkg = lock.packages[location];
|
|
29
28
|
if (pkg.link) {
|
|
30
29
|
pkg = lock.packages[pkg.resolved];
|
|
31
30
|
}
|
|
32
31
|
const name = location.replace(/^.*node_modules\//, "");
|
|
32
|
+
resolved_paths[name] = location;
|
|
33
33
|
if (pkg?.version) {
|
|
34
34
|
resolved_versions[name] = pkg.version;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
return { resolved_versions,
|
|
38
|
+
return { resolved_versions, resolved_paths };
|
|
39
39
|
}
|
|
40
40
|
function parse_pnpm_lockfile(lock) {
|
|
41
41
|
const resolved_versions = {};
|
|
42
|
-
const
|
|
42
|
+
const resolved_paths = {};
|
|
43
43
|
if (lock.packages) {
|
|
44
44
|
for (const key in lock.packages) {
|
|
45
45
|
const clean = key.startsWith("/") ? key.slice(1) : key;
|
|
@@ -49,7 +49,7 @@ function parse_pnpm_lockfile(lock) {
|
|
|
49
49
|
const version = clean.slice(atIdx + 1).split("(")[0];
|
|
50
50
|
if (name && version) {
|
|
51
51
|
resolved_versions[name] = version;
|
|
52
|
-
|
|
52
|
+
resolved_paths[name] = "node_modules/" + name;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -57,14 +57,14 @@ function parse_pnpm_lockfile(lock) {
|
|
|
57
57
|
if (lock.importers) {
|
|
58
58
|
for (const key in lock.importers) {
|
|
59
59
|
if (key !== ".")
|
|
60
|
-
|
|
60
|
+
resolved_paths[key] = key;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
return { resolved_versions,
|
|
63
|
+
return { resolved_versions, resolved_paths };
|
|
64
64
|
}
|
|
65
65
|
function parse_yarn_lockfile(text) {
|
|
66
66
|
const resolved_versions = {};
|
|
67
|
-
const
|
|
67
|
+
const resolved_paths = {};
|
|
68
68
|
if (text.includes("__metadata:")) {
|
|
69
69
|
const lock = YAML.parse(text);
|
|
70
70
|
for (const key in lock) {
|
|
@@ -74,15 +74,15 @@ function parse_yarn_lockfile(text) {
|
|
|
74
74
|
const name = extract_package_name(key.split(",")[0].trim());
|
|
75
75
|
if (name) {
|
|
76
76
|
resolved_versions[name] = lock[key].version;
|
|
77
|
-
|
|
77
|
+
resolved_paths[name] = "node_modules/" + name;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
parse_yarn_classic(text, resolved_versions,
|
|
83
|
+
parse_yarn_classic(text, resolved_versions, resolved_paths);
|
|
84
84
|
}
|
|
85
|
-
return { resolved_versions,
|
|
85
|
+
return { resolved_versions, resolved_paths };
|
|
86
86
|
}
|
|
87
87
|
function extract_package_name(entry) {
|
|
88
88
|
entry = entry.replace(/^"|"$/g, "");
|
|
@@ -90,7 +90,7 @@ function extract_package_name(entry) {
|
|
|
90
90
|
const at = entry.startsWith("@") ? entry.indexOf("@", 1) : entry.indexOf("@");
|
|
91
91
|
return at > 0 ? entry.slice(0, at) : null;
|
|
92
92
|
}
|
|
93
|
-
function parse_yarn_classic(text, resolved_versions,
|
|
93
|
+
function parse_yarn_classic(text, resolved_versions, resolved_paths) {
|
|
94
94
|
let current_name = null;
|
|
95
95
|
for (const line of text.split("\n")) {
|
|
96
96
|
const trimmed = line.trim();
|
|
@@ -100,7 +100,7 @@ function parse_yarn_classic(text, resolved_versions, locations) {
|
|
|
100
100
|
else if (current_name && trimmed.startsWith("version ")) {
|
|
101
101
|
const version = trimmed.slice(8).replace(/^"|"$/g, "");
|
|
102
102
|
resolved_versions[current_name] = version;
|
|
103
|
-
|
|
103
|
+
resolved_paths[current_name] = "node_modules/" + current_name;
|
|
104
104
|
current_name = null;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -35,8 +35,8 @@ export interface LogEntry {
|
|
|
35
35
|
}
|
|
36
36
|
export declare class Log {
|
|
37
37
|
readonly id: string;
|
|
38
|
+
readonly logger: Logger;
|
|
38
39
|
private entries;
|
|
39
|
-
private logger;
|
|
40
40
|
constructor(id: string, logger: Logger);
|
|
41
41
|
put(kind: LogKind, message: string | Error | Message): void;
|
|
42
42
|
error(message: string | Error | Message): void;
|
|
@@ -10,7 +10,7 @@ export class DefaultLibraryPackager {
|
|
|
10
10
|
setup_library_bundle(lib);
|
|
11
11
|
// Collect library declaration
|
|
12
12
|
await discover_library_definitions(lib, lib.path);
|
|
13
|
-
return lib.
|
|
13
|
+
return lib.master;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
export function setup_library_bundle(lib) {
|
|
@@ -18,8 +18,8 @@ export function setup_library_bundle(lib) {
|
|
|
18
18
|
const manif = make_library_bundle_manifest(lib);
|
|
19
19
|
let bun = lib.get_bundle(manif.$id);
|
|
20
20
|
if (!bun) {
|
|
21
|
-
bun = new Bundle(manif, lib.path,
|
|
22
|
-
lib.
|
|
21
|
+
bun = new Bundle(manif, lib.path, lib, lib);
|
|
22
|
+
lib.master = bun;
|
|
23
23
|
lib.shelve.push(bun);
|
|
24
24
|
lib.log.info(`+ 📦 bundle: ${bun.id} 🐣`);
|
|
25
25
|
return bun;
|