@jointhedots/gear 1.1.12 → 1.1.13
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.js +11 -9
- package/esm/builder/build-application.js +6 -5
- package/esm/builder/build-library.js +11 -9
- package/esm/builder/build-target.js +5 -142
- package/esm/builder/helpers/emit-bundle-manifest.js +29 -0
- package/esm/builder/{esbuild-plugins.js → helpers/emit-esmodules.js} +70 -30
- package/esm/builder/helpers/emit-package-manifest.js +19 -0
- package/esm/builder/helpers/emit-static-assets.js +47 -0
- package/esm/builder/{emit-dts.js → helpers/emit-typescript-definition.js} +35 -39
- package/esm/builder/helpers/task.js +9 -0
- package/esm/model/helpers/create-manifests.js +43 -22
- package/esm/model/helpers/discover-workspace.js +39 -21
- package/esm/model/workspace.js +7 -9
- package/esm/utils/file.js +53 -29
- package/package.json +3 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import Path from "node:path";
|
|
1
2
|
import { Bundle, Library } from "../model/workspace.js";
|
|
2
3
|
import { StorageFiles } from "../model/storage.js";
|
|
3
|
-
import { BuildTarget
|
|
4
|
-
import { TypescriptDefinitionTask } from "./emit-
|
|
5
|
-
import
|
|
4
|
+
import { BuildTarget } from "./build-target.js";
|
|
5
|
+
import { TypescriptDefinitionTask } from "./helpers/emit-typescript-definition.js";
|
|
6
|
+
import { PackageManifestTask } from "./helpers/emit-package-manifest.js";
|
|
6
7
|
import { PathQualifier } from "./helpers/path-helpers.js";
|
|
7
|
-
import {
|
|
8
|
-
import { DependencyDeduplicationPlugin, collectLibraryGraph } from "./
|
|
8
|
+
import { create_export_map } from "../model/helpers/create-manifests.js";
|
|
9
|
+
import { DependencyDeduplicationPlugin, collectLibraryGraph } from "./helpers/emit-esmodules.js";
|
|
10
|
+
import { BundleManifestTask } from "./helpers/emit-bundle-manifest.js";
|
|
9
11
|
export var PathStatus;
|
|
10
12
|
(function (PathStatus) {
|
|
11
13
|
PathStatus[PathStatus["Unknown"] = undefined] = "Unknown";
|
|
@@ -18,16 +20,16 @@ export function create_bundle_target(opts) {
|
|
|
18
20
|
const { bundle, library, storage } = opts;
|
|
19
21
|
const lib = library;
|
|
20
22
|
const target = new BuildTarget(bundle.id, storage, lib.workspace, opts.devmode == true, opts.watch == true, opts.clean == true);
|
|
21
|
-
const manifs = create_manifests(lib, bundle, opts.version);
|
|
22
23
|
// Prepare esm setup
|
|
23
24
|
target.esmodules.set_root(lib.path);
|
|
24
25
|
// Add bundle package.json
|
|
25
|
-
target.
|
|
26
|
+
target.tasks.push(new PackageManifestTask(target, lib, opts.version));
|
|
26
27
|
// Add bundle types.d.ts
|
|
27
28
|
target.tasks.push(new TypescriptDefinitionTask(target, lib));
|
|
28
29
|
// Add bundle exporteds
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const entries = create_export_map(lib, lib.bundle);
|
|
31
|
+
for (const exp_id in entries) {
|
|
32
|
+
const exp = entries[exp_id];
|
|
31
33
|
target.esmodules.add_entry(exp.basename, exp.source);
|
|
32
34
|
}
|
|
33
35
|
// Add bundle content
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Library, matchComponentSelection } from "../model/workspace.js";
|
|
2
|
-
import { StorageFiles } from "../model/storage.js";
|
|
3
|
-
import { BuildTarget, BuildTask, BundleManifestTask } from "./build-target.js";
|
|
4
1
|
import Path from "node:path";
|
|
5
|
-
import Fs from "node:fs";
|
|
6
2
|
import Sharp from "sharp";
|
|
7
3
|
import MIME from 'mime';
|
|
4
|
+
import { Library, matchComponentSelection } from "../model/workspace.js";
|
|
5
|
+
import { StorageFiles } from "../model/storage.js";
|
|
6
|
+
import { BuildTarget } from "./build-target.js";
|
|
8
7
|
import { build_app_composable_host } from "./build-app-host.js";
|
|
9
|
-
import { DependencyDeduplicationPlugin } from "./
|
|
8
|
+
import { DependencyDeduplicationPlugin } from "./helpers/emit-esmodules.js";
|
|
9
|
+
import { BundleManifestTask } from "./helpers/emit-bundle-manifest.js";
|
|
10
|
+
import { BuildTask } from "./helpers/task.js";
|
|
10
11
|
function collect_app_libraries(app) {
|
|
11
12
|
const libs = [app.library];
|
|
12
13
|
function collect_library_deps(lib) {
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
+
import Path from "node:path";
|
|
2
|
+
import ChildProcess from "child_process";
|
|
1
3
|
import { Library } from "../model/workspace.js";
|
|
2
4
|
import { StorageFiles } from "../model/storage.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import { BuildTarget } from "./build-target.js";
|
|
6
|
+
import { TypescriptDefinitionTask } from "./helpers/emit-typescript-definition.js";
|
|
7
|
+
import { PackageManifestTask } from "./helpers/emit-package-manifest.js";
|
|
8
|
+
import { create_export_map } from "../model/helpers/create-manifests.js";
|
|
9
|
+
import { BundleManifestTask } from "./helpers/emit-bundle-manifest.js";
|
|
8
10
|
export function create_library_target(opts) {
|
|
9
11
|
const lib = opts.library;
|
|
10
12
|
const target = new BuildTarget(lib.name, opts.storage, lib.workspace, opts.devmode == true, opts.watch == true, opts.clean == true);
|
|
11
|
-
const manifs = create_manifests(lib, lib.bundle, opts.version);
|
|
12
13
|
// Prepare esm setup
|
|
13
14
|
target.esmodules.set_root(lib.path);
|
|
14
15
|
// Add bundle exporteds
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const entries = create_export_map(lib, lib.bundle);
|
|
17
|
+
for (const exp_id in entries) {
|
|
18
|
+
const exp = entries[exp_id];
|
|
17
19
|
target.esmodules.add_entry(exp.basename, exp.source);
|
|
18
20
|
}
|
|
19
21
|
// Add library types.d.ts
|
|
20
22
|
target.tasks.push(new TypescriptDefinitionTask(target, lib));
|
|
21
23
|
// Add library package.json
|
|
22
|
-
target.
|
|
24
|
+
target.tasks.push(new PackageManifestTask(target, lib, opts.version));
|
|
23
25
|
// Add bundle content
|
|
24
26
|
const { bundle } = lib;
|
|
25
27
|
if (bundle) {
|
|
@@ -1,145 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { copyToStorageStream } from "../model/storage.js";
|
|
7
|
-
import * as esbuild from 'esbuild';
|
|
8
|
-
import { computeNameHashID } from "../utils/normalized-name.js";
|
|
9
|
-
export class BuildTask {
|
|
10
|
-
target;
|
|
11
|
-
constructor(target) {
|
|
12
|
-
this.target = target;
|
|
13
|
-
}
|
|
14
|
-
get log() { return this.target.log; }
|
|
15
|
-
async init() { }
|
|
16
|
-
}
|
|
17
|
-
export class BundleManifestTask extends BuildTask {
|
|
18
|
-
target;
|
|
19
|
-
bundle;
|
|
20
|
-
constructor(target, bundle) {
|
|
21
|
-
super(target);
|
|
22
|
-
this.target = target;
|
|
23
|
-
this.bundle = bundle;
|
|
24
|
-
}
|
|
25
|
-
async execute() {
|
|
26
|
-
const { target, bundle } = this;
|
|
27
|
-
const { manifest } = bundle;
|
|
28
|
-
const tx = this.target.edit();
|
|
29
|
-
// Emit static components manifest
|
|
30
|
-
const components = [];
|
|
31
|
-
for (const manif of target.components.values()) {
|
|
32
|
-
const pub = makeComponentPublication(manif);
|
|
33
|
-
pub.ref = await tx.commitContent(JSON.stringify(manif, null, 2), MIME.getType(".json"));
|
|
34
|
-
components.push(pub);
|
|
35
|
-
}
|
|
36
|
-
manifest.data.components = components;
|
|
37
|
-
// Emit bundle manifest
|
|
38
|
-
await tx.commitFile(`bundle.manifest.json`, JSON.stringify(manifest, null, 2));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export class AssetsTask extends BuildTask {
|
|
42
|
-
assets = [];
|
|
43
|
-
statics = {};
|
|
44
|
-
add_entry(entry, baseDir, library) {
|
|
45
|
-
let asset = null;
|
|
46
|
-
if (typeof entry === "string") {
|
|
47
|
-
const from = library.resolve_entry_path(entry, baseDir);
|
|
48
|
-
if (!from)
|
|
49
|
-
throw new Error(`In '${baseDir}', cannot found asset from: '${entry}'`);
|
|
50
|
-
asset = { from, to: Path.basename(entry) };
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const from = library.resolve_entry_path(entry.from, baseDir);
|
|
54
|
-
if (!from)
|
|
55
|
-
throw new Error(`In '${baseDir}', cannot found asset from: '${entry.from}'`);
|
|
56
|
-
asset = { from, to: entry.to };
|
|
57
|
-
}
|
|
58
|
-
this.log.info(`+ 📎 assets '${library.name}': ${asset.from} -> ${asset.to}`);
|
|
59
|
-
this.assets.push(asset);
|
|
60
|
-
}
|
|
61
|
-
add_static_text(name, data) {
|
|
62
|
-
this.statics[name] = data;
|
|
63
|
-
}
|
|
64
|
-
add_static_json(name, data) {
|
|
65
|
-
this.statics[name] = JSON.stringify(data, null, 2);
|
|
66
|
-
}
|
|
67
|
-
async execute() {
|
|
68
|
-
const tx = this.target.edit();
|
|
69
|
-
for (const key in this.statics) {
|
|
70
|
-
tx.commitFile(key, this.statics[key], MIME.getType(key));
|
|
71
|
-
}
|
|
72
|
-
for (const asset of this.assets) {
|
|
73
|
-
if (typeof asset === "string") {
|
|
74
|
-
copyToStorageStream(tx, asset, asset);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
copyToStorageStream(tx, asset.to, asset.from);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export class ESModulesTask extends BuildTask {
|
|
83
|
-
entries = {};
|
|
84
|
-
imports = {};
|
|
85
|
-
internals = new Map();
|
|
86
|
-
plugins = [];
|
|
87
|
-
context = null;
|
|
88
|
-
transaction = null;
|
|
89
|
-
polyfilled = true;
|
|
90
|
-
rootPath = null;
|
|
91
|
-
set_root(path) {
|
|
92
|
-
this.rootPath = path;
|
|
93
|
-
}
|
|
94
|
-
add_entry(name, path) {
|
|
95
|
-
this.entries[name] = path;
|
|
96
|
-
this.imports[path] = name;
|
|
97
|
-
}
|
|
98
|
-
add_entry_typescript(code, name) {
|
|
99
|
-
const id = computeNameHashID(code);
|
|
100
|
-
if (!name)
|
|
101
|
-
name = id;
|
|
102
|
-
this.internals.set(id, code);
|
|
103
|
-
this.add_entry(name, id);
|
|
104
|
-
return name;
|
|
105
|
-
}
|
|
106
|
-
add_resource_entry(resource, baseDir, library) {
|
|
107
|
-
if (typeof resource === "string") {
|
|
108
|
-
const parts = resource.split("#");
|
|
109
|
-
const file = library.resolve_entry_path(parts[0], baseDir);
|
|
110
|
-
if (file) {
|
|
111
|
-
let named = this.imports[file];
|
|
112
|
-
if (!named) {
|
|
113
|
-
named = library.make_file_id("lambda", file);
|
|
114
|
-
this.add_entry(named, file);
|
|
115
|
-
}
|
|
116
|
-
return `./${named}.js#${parts[1] || "default"}`;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
throw new Error(`${library.name}: Cannot resolve file: ${parts[0]}`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
return resource;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async execute() {
|
|
127
|
-
if (this.context) {
|
|
128
|
-
const prev_ctx = this.context;
|
|
129
|
-
this.context = null;
|
|
130
|
-
await prev_ctx.dispose();
|
|
131
|
-
}
|
|
132
|
-
const { target } = this;
|
|
133
|
-
this.context = await create_esbuild_context(this, target.devmode);
|
|
134
|
-
if (target.watch) {
|
|
135
|
-
await this.context.watch();
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
await this.context.rebuild();
|
|
139
|
-
await this.context.dispose();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
1
|
+
import {} from "../model/component.js";
|
|
2
|
+
import { Library, Workspace } from "../model/workspace.js";
|
|
3
|
+
import { ESModulesTask } from "./helpers/emit-esmodules.js";
|
|
4
|
+
import {} from "../model/storage.js";
|
|
5
|
+
import { AssetsTask } from "./helpers/emit-static-assets.js";
|
|
143
6
|
export class BuildTarget {
|
|
144
7
|
name;
|
|
145
8
|
storage;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { makeComponentPublication } from "../../model/component.js";
|
|
2
|
+
import { BuildTarget } from "../build-target.js";
|
|
3
|
+
import { BuildTask } from "./task.js";
|
|
4
|
+
import MIME from 'mime';
|
|
5
|
+
export class BundleManifestTask extends BuildTask {
|
|
6
|
+
target;
|
|
7
|
+
bundle;
|
|
8
|
+
constructor(target, bundle) {
|
|
9
|
+
super(target);
|
|
10
|
+
this.target = target;
|
|
11
|
+
this.bundle = bundle;
|
|
12
|
+
}
|
|
13
|
+
async execute() {
|
|
14
|
+
const { target, bundle } = this;
|
|
15
|
+
const { manifest } = bundle;
|
|
16
|
+
const tx = this.target.edit();
|
|
17
|
+
// Emit static components manifest
|
|
18
|
+
const components = [];
|
|
19
|
+
for (const manif of target.components.values()) {
|
|
20
|
+
const pub = makeComponentPublication(manif);
|
|
21
|
+
pub.ref = await tx.commitContent(JSON.stringify(manif, null, 2), MIME.getType(".json"));
|
|
22
|
+
components.push(pub);
|
|
23
|
+
}
|
|
24
|
+
manifest.data.components = components;
|
|
25
|
+
// Emit bundle manifest
|
|
26
|
+
await tx.commitFile(`bundle.manifest.json`, JSON.stringify(manifest, null, 2));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=emit-bundle-manifest.js.map
|
|
@@ -5,9 +5,10 @@ import MIME from 'mime';
|
|
|
5
5
|
import postcss from 'postcss';
|
|
6
6
|
import * as esbuild from 'esbuild';
|
|
7
7
|
import { sassPlugin } from 'esbuild-sass-plugin';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { PackageRootDir, resolve_normalized_suffixed_path } from "../../utils/file.js";
|
|
9
|
+
import { Library } from "../../model/workspace.js";
|
|
10
|
+
import { computeNameHashID } from "../../utils/normalized-name.js";
|
|
11
|
+
import { BuildTask } from "./task.js";
|
|
11
12
|
const VirtualOutDir = Path.normalize('X:/');
|
|
12
13
|
function getEsbuildLogLevel(mode) {
|
|
13
14
|
switch (mode) {
|
|
@@ -486,30 +487,6 @@ export function ESModuleResolverPlugin(opts, tsconfigPaths) {
|
|
|
486
487
|
".ts": "ts", ".tsx": "tsx", ".js": "js", ".jsx": "jsx",
|
|
487
488
|
".json": "json", ".txt": "text", ".md": "text", ".css": "css",
|
|
488
489
|
};
|
|
489
|
-
const FILE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json'];
|
|
490
|
-
/** Resolve a file path with extension probing */
|
|
491
|
-
function resolveFilePath(importPath, baseDir) {
|
|
492
|
-
const resolved = Path.resolve(baseDir, importPath);
|
|
493
|
-
// Check if exact path exists
|
|
494
|
-
if (Fs.existsSync(resolved) && Fs.statSync(resolved).isFile()) {
|
|
495
|
-
return resolved;
|
|
496
|
-
}
|
|
497
|
-
// Try with common extensions
|
|
498
|
-
for (const ext of FILE_EXTENSIONS) {
|
|
499
|
-
const withExt = resolved + ext;
|
|
500
|
-
if (Fs.existsSync(withExt))
|
|
501
|
-
return withExt;
|
|
502
|
-
}
|
|
503
|
-
// Try index files in directory
|
|
504
|
-
if (Fs.existsSync(resolved) && Fs.statSync(resolved).isDirectory()) {
|
|
505
|
-
for (const ext of FILE_EXTENSIONS) {
|
|
506
|
-
const indexPath = Path.join(resolved, `index${ext}`);
|
|
507
|
-
if (Fs.existsSync(indexPath))
|
|
508
|
-
return indexPath;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
return null;
|
|
512
|
-
}
|
|
513
490
|
return {
|
|
514
491
|
name: 'esm-resolver',
|
|
515
492
|
setup(build) {
|
|
@@ -546,14 +523,16 @@ export function ESModuleResolverPlugin(opts, tsconfigPaths) {
|
|
|
546
523
|
// 3. Handle relative/absolute file paths (entry points and local imports)
|
|
547
524
|
if (args.path.startsWith(".") || args.path.startsWith("/") || Path.isAbsolute(args.path)) {
|
|
548
525
|
const baseDir = args.resolveDir || workspaceRoot;
|
|
549
|
-
const resolved =
|
|
526
|
+
const resolved = resolve_normalized_suffixed_path(baseDir, args.path);
|
|
550
527
|
if (resolved) {
|
|
551
528
|
return { path: resolved, namespace: "file" };
|
|
552
529
|
}
|
|
553
530
|
}
|
|
554
531
|
// 4. Resolve tsconfig path aliases (e.g. @app/* -> ./src/*)
|
|
555
532
|
if (tsconfigPaths?.hasAliases) {
|
|
556
|
-
const resolved = tsconfigPaths.resolve(args.path,
|
|
533
|
+
const resolved = tsconfigPaths.resolve(args.path, (importPath, baseDir) => {
|
|
534
|
+
return resolve_normalized_suffixed_path(baseDir, importPath);
|
|
535
|
+
});
|
|
557
536
|
if (resolved) {
|
|
558
537
|
return { path: resolved, namespace: "file" };
|
|
559
538
|
}
|
|
@@ -572,4 +551,65 @@ export function ESModuleResolverPlugin(opts, tsconfigPaths) {
|
|
|
572
551
|
},
|
|
573
552
|
};
|
|
574
553
|
}
|
|
575
|
-
|
|
554
|
+
export class ESModulesTask extends BuildTask {
|
|
555
|
+
entries = {};
|
|
556
|
+
imports = {};
|
|
557
|
+
internals = new Map();
|
|
558
|
+
plugins = [];
|
|
559
|
+
context = null;
|
|
560
|
+
transaction = null;
|
|
561
|
+
polyfilled = true;
|
|
562
|
+
rootPath = null;
|
|
563
|
+
set_root(path) {
|
|
564
|
+
this.rootPath = path;
|
|
565
|
+
}
|
|
566
|
+
add_entry(name, path) {
|
|
567
|
+
this.entries[name] = path;
|
|
568
|
+
this.imports[path] = name;
|
|
569
|
+
}
|
|
570
|
+
add_entry_typescript(code, name) {
|
|
571
|
+
const id = computeNameHashID(code);
|
|
572
|
+
if (!name)
|
|
573
|
+
name = id;
|
|
574
|
+
this.internals.set(id, code);
|
|
575
|
+
this.add_entry(name, id);
|
|
576
|
+
return name;
|
|
577
|
+
}
|
|
578
|
+
add_resource_entry(resource, baseDir, library) {
|
|
579
|
+
if (typeof resource === "string") {
|
|
580
|
+
const parts = resource.split("#");
|
|
581
|
+
const file = library.resolve_entry_path(parts[0], baseDir);
|
|
582
|
+
if (file) {
|
|
583
|
+
let named = this.imports[file];
|
|
584
|
+
if (!named) {
|
|
585
|
+
named = library.make_file_id("lambda", file);
|
|
586
|
+
this.add_entry(named, file);
|
|
587
|
+
}
|
|
588
|
+
return `./${named}.js#${parts[1] || "default"}`;
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
throw new Error(`${library.name}: Cannot resolve file: ${parts[0]}`);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
return resource;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
async execute() {
|
|
599
|
+
if (this.context) {
|
|
600
|
+
const prev_ctx = this.context;
|
|
601
|
+
this.context = null;
|
|
602
|
+
await prev_ctx.dispose();
|
|
603
|
+
}
|
|
604
|
+
const { target } = this;
|
|
605
|
+
this.context = await create_esbuild_context(this, target.devmode);
|
|
606
|
+
if (target.watch) {
|
|
607
|
+
await this.context.watch();
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
await this.context.rebuild();
|
|
611
|
+
await this.context.dispose();
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
//# sourceMappingURL=emit-esmodules.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BuildTask } from "./task.js";
|
|
2
|
+
import { create_export_map, create_package_manifest } from "../../model/helpers/create-manifests.js";
|
|
3
|
+
import { console } from "node:inspector";
|
|
4
|
+
export class PackageManifestTask extends BuildTask {
|
|
5
|
+
library;
|
|
6
|
+
version;
|
|
7
|
+
constructor(target, library, version) {
|
|
8
|
+
super(target);
|
|
9
|
+
this.library = library;
|
|
10
|
+
this.version = version;
|
|
11
|
+
}
|
|
12
|
+
async execute() {
|
|
13
|
+
const { library, version } = this;
|
|
14
|
+
const pkg = create_package_manifest(library, library.bundle, version);
|
|
15
|
+
const tx = this.target.edit();
|
|
16
|
+
tx.commitFile("package.json", JSON.stringify(pkg, null, 2));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=emit-package-manifest.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Path from "node:path";
|
|
2
|
+
import MIME from 'mime';
|
|
3
|
+
import { Library } from "../../model/workspace.js";
|
|
4
|
+
import { copyToStorageStream } from "../../model/storage.js";
|
|
5
|
+
import { BuildTask } from "./task.js";
|
|
6
|
+
export class AssetsTask extends BuildTask {
|
|
7
|
+
assets = [];
|
|
8
|
+
statics = {};
|
|
9
|
+
add_entry(entry, baseDir, library) {
|
|
10
|
+
let asset = null;
|
|
11
|
+
if (typeof entry === "string") {
|
|
12
|
+
const from = library.resolve_entry_path(entry, baseDir);
|
|
13
|
+
if (!from)
|
|
14
|
+
throw new Error(`In '${baseDir}', cannot found asset from: '${entry}'`);
|
|
15
|
+
asset = { from, to: Path.basename(entry) };
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const from = library.resolve_entry_path(entry.from, baseDir);
|
|
19
|
+
if (!from)
|
|
20
|
+
throw new Error(`In '${baseDir}', cannot found asset from: '${entry.from}'`);
|
|
21
|
+
asset = { from, to: entry.to };
|
|
22
|
+
}
|
|
23
|
+
this.log.info(`+ 📎 assets '${library.name}': ${asset.from} -> ${asset.to}`);
|
|
24
|
+
this.assets.push(asset);
|
|
25
|
+
}
|
|
26
|
+
add_static_text(name, data) {
|
|
27
|
+
this.statics[name] = data;
|
|
28
|
+
}
|
|
29
|
+
add_static_json(name, data) {
|
|
30
|
+
this.statics[name] = JSON.stringify(data, null, 2);
|
|
31
|
+
}
|
|
32
|
+
async execute() {
|
|
33
|
+
const tx = this.target.edit();
|
|
34
|
+
for (const key in this.statics) {
|
|
35
|
+
tx.commitFile(key, this.statics[key], MIME.getType(key));
|
|
36
|
+
}
|
|
37
|
+
for (const asset of this.assets) {
|
|
38
|
+
if (typeof asset === "string") {
|
|
39
|
+
copyToStorageStream(tx, asset, asset);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
copyToStorageStream(tx, asset.to, asset.from);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=emit-static-assets.js.map
|
|
@@ -2,9 +2,11 @@ import * as Glob from 'glob';
|
|
|
2
2
|
import Os from 'os';
|
|
3
3
|
import Path from 'path';
|
|
4
4
|
import Ts from 'typescript';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { BuildTask } from "./task.js";
|
|
6
|
+
import { BuildTarget } from "../build-target.js";
|
|
7
|
+
import { Library } from "../../model/workspace.js";
|
|
8
|
+
import { file } from "../../utils/file.js";
|
|
9
|
+
import { create_export_map } from "../../model/helpers/create-manifests.js";
|
|
8
10
|
const eol = Os.EOL;
|
|
9
11
|
const indent = " ";
|
|
10
12
|
const DTSLEN = '.d.ts'.length;
|
|
@@ -178,44 +180,42 @@ export function generateTypescriptDefinition(options) {
|
|
|
178
180
|
const sourcesMap = {};
|
|
179
181
|
const internalsMap = {};
|
|
180
182
|
project.getSourceFiles().some(function (sourceFile) {
|
|
181
|
-
|
|
183
|
+
const { fileName } = sourceFile;
|
|
184
|
+
if (fileName.indexOf(normalizedBaseDir) !== 0)
|
|
182
185
|
return;
|
|
183
|
-
if (excludesMap[
|
|
186
|
+
if (excludesMap[fileName])
|
|
184
187
|
return;
|
|
185
|
-
const shortName =
|
|
186
|
-
const shortNameNoExt = shortName.slice(0, -Path.extname(
|
|
188
|
+
const shortName = fileName.slice(normalizedBaseDir.length);
|
|
189
|
+
const shortNameNoExt = shortName.slice(0, -Path.extname(fileName).length);
|
|
187
190
|
const strippedShortName = stripBaseUrlPrefix(shortName);
|
|
188
191
|
const strippedShortNameNoExt = stripBaseUrlPrefix(shortNameNoExt);
|
|
189
|
-
|
|
192
|
+
const moduleId = `${options.prefix}/${strippedShortNameNoExt}`;
|
|
190
193
|
internalsMap[shortName] = moduleId;
|
|
191
194
|
internalsMap[shortNameNoExt] = moduleId;
|
|
192
195
|
internalsMap[strippedShortName] = moduleId;
|
|
193
196
|
internalsMap[strippedShortNameNoExt] = moduleId;
|
|
194
|
-
sourcesMap[
|
|
197
|
+
sourcesMap[fileName] = true;
|
|
195
198
|
});
|
|
196
199
|
// Build reverse map from internal paths to export names
|
|
197
200
|
// e.g., "src/Inputs" -> "./Inputs" means internal path "src/Inputs" exports as "prefix/Inputs"
|
|
198
201
|
// Store as [internalPrefix, exportName] pairs for prefix matching
|
|
199
202
|
if (options.exports) {
|
|
200
|
-
for (const
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
+
for (const entry of Object.values(options.exports)) {
|
|
204
|
+
const fileName = entry.source;
|
|
205
|
+
if (fileName.indexOf(normalizedBaseDir) !== 0)
|
|
203
206
|
continue;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// Normalize internal path: remove leading ./, strip extensions
|
|
210
|
-
const internalPath = normalizeFileName(exported);
|
|
211
|
-
let shortNameNoExt = internalPath.replace(/^\.\//, '').replace(/\.(ts|tsx|js|jsx)$/, '');
|
|
212
|
-
if (shortNameNoExt.endsWith('/index'))
|
|
213
|
-
shortNameNoExt = shortNameNoExt.slice(0, -6);
|
|
207
|
+
if (excludesMap[fileName])
|
|
208
|
+
continue;
|
|
209
|
+
const shortName = fileName.slice(normalizedBaseDir.length);
|
|
210
|
+
const shortNameNoExt = shortName.slice(0, -Path.extname(fileName).length);
|
|
211
|
+
const strippedShortName = stripBaseUrlPrefix(shortName);
|
|
214
212
|
const strippedShortNameNoExt = stripBaseUrlPrefix(shortNameNoExt);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
internalsMap[shortNameNoExt] =
|
|
218
|
-
internalsMap[
|
|
213
|
+
const moduleId = entry.id;
|
|
214
|
+
internalsMap[shortName] = moduleId;
|
|
215
|
+
internalsMap[shortNameNoExt] = moduleId;
|
|
216
|
+
internalsMap[strippedShortName] = moduleId;
|
|
217
|
+
internalsMap[strippedShortNameNoExt] = moduleId;
|
|
218
|
+
sourcesMap[fileName] = true;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
// Unified module ID normalization: strip extensions, baseUrl prefix, and remap to exports
|
|
@@ -224,18 +224,11 @@ export function generateTypescriptDefinition(options) {
|
|
|
224
224
|
moduleId = moduleId.replace(/\.(d\.ts|ts|tsx|js|jsx)$/, '');
|
|
225
225
|
// Strip baseUrl prefix
|
|
226
226
|
moduleId = stripBaseUrlPrefix(moduleId);
|
|
227
|
-
// Strip index suffix
|
|
228
|
-
if (moduleId === "index") {
|
|
229
|
-
return options.prefix;
|
|
230
|
-
}
|
|
231
|
-
if (moduleId.endsWith("/index")) {
|
|
232
|
-
moduleId = moduleId.slice(0, -6);
|
|
233
|
-
}
|
|
234
227
|
// Apply resolved prefix
|
|
235
|
-
|
|
236
|
-
moduleId
|
|
237
|
-
|
|
238
|
-
return moduleId;
|
|
228
|
+
const remapped = internalsMap[moduleId] ||
|
|
229
|
+
internalsMap[moduleId + "/index"] ||
|
|
230
|
+
internalsMap[moduleId + "/index.ts"];
|
|
231
|
+
return remapped || moduleId;
|
|
239
232
|
}
|
|
240
233
|
// Generate source files
|
|
241
234
|
project.getSourceFiles().some(function (sourceFile) {
|
|
@@ -312,6 +305,9 @@ export function generateTypescriptDefinition(options) {
|
|
|
312
305
|
const resolved = resolveModuleImport(expression.text);
|
|
313
306
|
return ` require('${resolved}')`;
|
|
314
307
|
}
|
|
308
|
+
else if (isNodeKindImportDeclaration(node) && !node.importClause) {
|
|
309
|
+
return '';
|
|
310
|
+
}
|
|
315
311
|
else if (node.kind === Ts.SyntaxKind.DeclareKeyword) {
|
|
316
312
|
return '';
|
|
317
313
|
}
|
|
@@ -375,7 +371,7 @@ export class TypescriptDefinitionTask extends BuildTask {
|
|
|
375
371
|
project,
|
|
376
372
|
prefix: lib.name,
|
|
377
373
|
exclude: ["node_modules/**/*"],
|
|
378
|
-
exports: lib.
|
|
374
|
+
exports: create_export_map(lib, lib.bundle),
|
|
379
375
|
});
|
|
380
376
|
file.write.text(storage.getBaseDirFS() + "/types.d.ts", dts);
|
|
381
377
|
logDiagnostics(this.log, diagnostics);
|
|
@@ -385,4 +381,4 @@ export class TypescriptDefinitionTask extends BuildTask {
|
|
|
385
381
|
}
|
|
386
382
|
}
|
|
387
383
|
}
|
|
388
|
-
//# sourceMappingURL=emit-
|
|
384
|
+
//# sourceMappingURL=emit-typescript-definition.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import Path from "node:path";
|
|
2
2
|
import { makeComponentPublication } from "../component.js";
|
|
3
|
+
import { resolve_normalized_suffixed_path } from "../../utils/file.js";
|
|
3
4
|
function add_export_entry(exports, lib, key, value, baseDir) {
|
|
4
5
|
const basename = key.startsWith("./") ? key.slice(2) : key;
|
|
5
6
|
const filename = lib.make_file_id("export", basename);
|
|
6
7
|
const source_ref = typeof value === "string" ? value : value?.import ?? value?.default ?? value?.require;
|
|
7
|
-
const entry = source_ref ? lib.resolve_entry_path(source_ref, baseDir) : null;
|
|
8
|
+
const entry = source_ref ? resolve_normalized_suffixed_path(lib.resolve_entry_path(source_ref, baseDir), ".") : null;
|
|
8
9
|
const id = `${lib.name}${basename === "." ? "" : "/" + basename}`;
|
|
9
10
|
exports[id] = {
|
|
10
11
|
id,
|
|
@@ -14,7 +15,7 @@ function add_export_entry(exports, lib, key, value, baseDir) {
|
|
|
14
15
|
source: entry,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
function create_export_map(lib, bun) {
|
|
18
|
+
export function create_export_map(lib, bun) {
|
|
18
19
|
const exports = {};
|
|
19
20
|
if (bun) {
|
|
20
21
|
for (const id in bun.distribueds) {
|
|
@@ -43,26 +44,28 @@ function create_export_map(lib, bun) {
|
|
|
43
44
|
}
|
|
44
45
|
return exports;
|
|
45
46
|
}
|
|
46
|
-
export function
|
|
47
|
+
export function create_bundle_manifest(lib, bun) {
|
|
48
|
+
if (!bun)
|
|
49
|
+
return null;
|
|
47
50
|
const entries = create_export_map(lib, bun);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const exp = entries[id];
|
|
62
|
-
bundle_manif.data.exports[id] = exp.filename;
|
|
63
|
-
}
|
|
51
|
+
const bundle_manif = bun.manifest;
|
|
52
|
+
const components = [];
|
|
53
|
+
for (const comp of bun.components.values()) {
|
|
54
|
+
components.push(makeComponentPublication(comp));
|
|
55
|
+
}
|
|
56
|
+
bundle_manif.data = {
|
|
57
|
+
baseline: bun.id + "-v0",
|
|
58
|
+
components: components,
|
|
59
|
+
exports: {},
|
|
60
|
+
};
|
|
61
|
+
for (const id in entries) {
|
|
62
|
+
const exp = entries[id];
|
|
63
|
+
bundle_manif.data.exports[id] = exp.filename;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
return bundle_manif;
|
|
66
|
+
}
|
|
67
|
+
export function create_package_manifest(lib, bun, build_version) {
|
|
68
|
+
const entries = create_export_map(lib, bun);
|
|
66
69
|
const pkg_manif = {
|
|
67
70
|
...lib.descriptor,
|
|
68
71
|
name: lib.name,
|
|
@@ -74,14 +77,32 @@ export function create_manifests(lib, bun, build_version) {
|
|
|
74
77
|
devDependencies: undefined,
|
|
75
78
|
optionalDependencies: undefined,
|
|
76
79
|
};
|
|
80
|
+
if (pkg_manif.dependencies) {
|
|
81
|
+
const resolved = lib.workspace.resolved_versions;
|
|
82
|
+
for (const dep in pkg_manif.dependencies) {
|
|
83
|
+
if (pkg_manif.dependencies[dep] === "*") {
|
|
84
|
+
const dep_resolved = resolved[dep];
|
|
85
|
+
if (dep_resolved) {
|
|
86
|
+
const [major, minor] = dep_resolved.split(".");
|
|
87
|
+
pkg_manif.dependencies[dep] = `^${major}.${minor}.0`;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
lib.log.warn(`Library dependency '${dep}' is versioned as * but not updatable to locked version`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
77
95
|
for (const id in entries) {
|
|
78
96
|
const exp = entries[id];
|
|
79
97
|
if (exp.exported) {
|
|
80
98
|
if (!pkg_manif.exports)
|
|
81
99
|
pkg_manif.exports = {};
|
|
82
|
-
pkg_manif.exports[exp.exported] = {
|
|
100
|
+
pkg_manif.exports[exp.exported] = {
|
|
101
|
+
import: `./${exp.filename}`,
|
|
102
|
+
types: "./types.d.ts",
|
|
103
|
+
};
|
|
83
104
|
}
|
|
84
105
|
}
|
|
85
|
-
return
|
|
106
|
+
return pkg_manif;
|
|
86
107
|
}
|
|
87
108
|
//# sourceMappingURL=create-manifests.js.map
|
|
@@ -3,7 +3,7 @@ import Fsp from "node:fs/promises";
|
|
|
3
3
|
import { readJsonFile } from "../storage.js";
|
|
4
4
|
import { checkComponentManifest } from "../component.js";
|
|
5
5
|
import { makeNormalizedName, NameStyle } from "../../utils/normalized-name.js";
|
|
6
|
-
import {
|
|
6
|
+
import { create_bundle_manifest } from "./create-manifests.js";
|
|
7
7
|
import { Bundle, Library, Workspace } from "../workspace.js";
|
|
8
8
|
import { file, make_canonical_path, make_normalized_dirname, make_normalized_path, make_relative_path } from "../../utils/file.js";
|
|
9
9
|
import { findConfigFile, is_config_filename, readConfigFile, readSingletonConfigFile } from "./config-loader.js";
|
|
@@ -18,8 +18,8 @@ function is_ignored_dir(ws, path) {
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
function setup_library_bundle(lib, bundle_desc) {
|
|
21
|
-
const manif = make_library_bundle_manifest(lib, bundle_desc);
|
|
22
21
|
const ws = lib.workspace;
|
|
22
|
+
const manif = make_library_bundle_manifest(lib, bundle_desc);
|
|
23
23
|
let bun = ws.get_bundle(manif.$id);
|
|
24
24
|
if (!bun) {
|
|
25
25
|
bun = new Bundle(manif, lib.path, ws, lib);
|
|
@@ -118,6 +118,19 @@ async function discover_library_components(lib, path, subdir = false) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
export function collect_declarations_field(lib, key, value) {
|
|
122
|
+
for (const decl of lib.declarations.values()) {
|
|
123
|
+
if (typeof decl[key] === typeof value) {
|
|
124
|
+
if (Array.isArray(value))
|
|
125
|
+
value.push(...decl[key]);
|
|
126
|
+
else if (typeof value === "object")
|
|
127
|
+
Object.assign(value, decl[key]);
|
|
128
|
+
else
|
|
129
|
+
value = decl[key];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
121
134
|
function make_library_bundle_manifest(lib, file_desc) {
|
|
122
135
|
let $id = file_desc?.$id;
|
|
123
136
|
if ($id) {
|
|
@@ -131,26 +144,22 @@ function make_library_bundle_manifest(lib, file_desc) {
|
|
|
131
144
|
lib.log.info(`Bundle '${$id}' named from library '${lib.name}'`);
|
|
132
145
|
}
|
|
133
146
|
const data = {
|
|
134
|
-
alias: lib.name,
|
|
135
147
|
package: lib.get_id(),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
alias: collect_declarations_field(lib, "alias", lib.name),
|
|
149
|
+
namespaces: collect_declarations_field(lib, "namespaces", []),
|
|
150
|
+
dependencies: collect_declarations_field(lib, "dependencies", []),
|
|
151
|
+
distribueds: collect_declarations_field(lib, "distribueds", {}),
|
|
139
152
|
};
|
|
140
153
|
if (file_desc?.data) {
|
|
141
154
|
data.alias = file_desc.data.alias ?? data.alias;
|
|
142
|
-
if (file_desc.data.
|
|
143
|
-
|
|
144
|
-
if (Array.isArray(distribueds))
|
|
145
|
-
distribueds.forEach(dist => data.redistribueds[dist] = "*");
|
|
146
|
-
else
|
|
147
|
-
Object.assign(data.redistribueds, distribueds);
|
|
155
|
+
if (file_desc.data.distribueds) {
|
|
156
|
+
Object.assign(data.distribueds, file_desc.data.distribueds);
|
|
148
157
|
}
|
|
149
|
-
if (file_desc.data.namespaces) {
|
|
150
|
-
data.namespaces
|
|
158
|
+
if (Array.isArray(file_desc.data.namespaces)) {
|
|
159
|
+
data.namespaces.push(...file_desc.data.namespaces);
|
|
151
160
|
}
|
|
152
|
-
if (file_desc.data.dependencies) {
|
|
153
|
-
data.dependencies
|
|
161
|
+
if (Array.isArray(file_desc.data.dependencies)) {
|
|
162
|
+
data.dependencies.push(...file_desc.data.dependencies);
|
|
154
163
|
}
|
|
155
164
|
}
|
|
156
165
|
const manifest = {
|
|
@@ -203,9 +212,9 @@ async function discover_library(ws, location, installed) {
|
|
|
203
212
|
ws.libraries.push(lib);
|
|
204
213
|
ws.log.info(`+ 📚 library: ${installed ? "⏬" : "🐣"} ${lib.get_id()} (${make_relative_path(ws.path, location)})`);
|
|
205
214
|
// Setup library infos from bundle manifest
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
setup_library_bundle(lib, manifest_desc);
|
|
216
|
+
// Analyze library deployment manifest (supports json/yaml/yml/toml, singleton)
|
|
217
|
+
if (manifest_desc?.data?.components) {
|
|
209
218
|
for (const pub of manifest_desc.data.components) {
|
|
210
219
|
const fpath = lib_path + "/" + (pub.ref ?? pub.id);
|
|
211
220
|
await discover_component(lib, fpath);
|
|
@@ -270,14 +279,23 @@ export async function discover_workspace(ws) {
|
|
|
270
279
|
if (!package_lock) {
|
|
271
280
|
throw new Error(`Package lock not found for '${ws.name}'`);
|
|
272
281
|
}
|
|
282
|
+
for (const location in package_lock.packages) {
|
|
283
|
+
let pkg = package_lock.packages[location];
|
|
284
|
+
if (location.startsWith("node_modules/")) {
|
|
285
|
+
if (pkg.link) {
|
|
286
|
+
pkg = package_lock.packages[pkg.resolved];
|
|
287
|
+
}
|
|
288
|
+
const name = location.replace(/^.*node_modules\//, "");
|
|
289
|
+
ws.resolved_versions[name] = pkg.version;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
273
292
|
await discover_workspace_libraries(ws);
|
|
274
293
|
for (const location in package_lock.packages) {
|
|
275
294
|
await discover_library(ws, location, true);
|
|
276
295
|
}
|
|
277
296
|
for (const bun of ws.bundles) {
|
|
278
297
|
if (bun.source) {
|
|
279
|
-
|
|
280
|
-
bun.manifest = manifs.bundle;
|
|
298
|
+
bun.manifest = create_bundle_manifest(bun.source, bun);
|
|
281
299
|
}
|
|
282
300
|
}
|
|
283
301
|
show_constants(ws);
|
package/esm/model/workspace.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import Fs from "node:fs";
|
|
2
|
-
import Fsp from "node:fs/promises";
|
|
3
2
|
import Path from "node:path";
|
|
4
3
|
import Process from "node:process";
|
|
4
|
+
import DotEnv from "dotenv";
|
|
5
5
|
import { readJsonFile } from "./storage.js";
|
|
6
6
|
import {} from "./component.js";
|
|
7
|
-
import { topologicalSort } from "../utils/graph-ordering.js";
|
|
8
|
-
import DotEnv from "dotenv";
|
|
9
7
|
import { computeNameHashID, makeNormalizedName, NameStyle } from "../utils/normalized-name.js";
|
|
10
|
-
import {
|
|
8
|
+
import { make_normalized_path } from "../utils/file.js";
|
|
11
9
|
import { Logger, Log } from "./helpers/logger.js";
|
|
12
10
|
import { discover_workspace } from "./helpers/discover-workspace.js";
|
|
13
|
-
import {
|
|
11
|
+
import { create_bundle_manifest } from "./helpers/create-manifests.js";
|
|
14
12
|
export class WorkspaceItem {
|
|
15
13
|
workspace;
|
|
16
14
|
log;
|
|
@@ -51,13 +49,13 @@ export class Library extends WorkspaceItem {
|
|
|
51
49
|
return base ? prefix + "." + base : prefix;
|
|
52
50
|
}
|
|
53
51
|
resolve_entry_path(entryId, baseDir) {
|
|
54
|
-
const fpath =
|
|
52
|
+
const fpath = make_normalized_path(Path.resolve(baseDir, entryId));
|
|
55
53
|
if (entryId.startsWith("."))
|
|
56
54
|
return fpath;
|
|
57
55
|
const parts = entryId.split("/");
|
|
58
56
|
for (const search_path of this.search_directories) {
|
|
59
57
|
if (Fs.existsSync(search_path + "/" + parts[0])) {
|
|
60
|
-
return
|
|
58
|
+
return make_normalized_path(search_path + "/" + entryId);
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
if (Fs.existsSync(fpath))
|
|
@@ -94,8 +92,7 @@ export class Bundle extends WorkspaceItem {
|
|
|
94
92
|
}
|
|
95
93
|
resolve_export(ref) {
|
|
96
94
|
if (!this.manifest) {
|
|
97
|
-
|
|
98
|
-
this.manifest = manifs.bundle;
|
|
95
|
+
this.manifest = create_bundle_manifest(this.source, this);
|
|
99
96
|
this.configured = true;
|
|
100
97
|
}
|
|
101
98
|
return this.exports?.[ref];
|
|
@@ -110,6 +107,7 @@ export class Workspace {
|
|
|
110
107
|
bundles = [];
|
|
111
108
|
libraries = [];
|
|
112
109
|
constants = {};
|
|
110
|
+
resolved_versions = {};
|
|
113
111
|
search_directories = [];
|
|
114
112
|
ignored_directories = new Set();
|
|
115
113
|
logger = new Logger();
|
package/esm/utils/file.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import Path from "path";
|
|
2
|
-
import
|
|
2
|
+
import Fs from "fs";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
export const PackageRootDir = Path.resolve(fileURLToPath(import.meta.url), "../../..");
|
|
5
5
|
export const file = {
|
|
6
6
|
exists(path) {
|
|
7
|
-
return
|
|
7
|
+
return Fs.existsSync(path) && Fs.lstatSync(path).isFile();
|
|
8
8
|
},
|
|
9
9
|
copy: {
|
|
10
10
|
toFile(src, dest) {
|
|
11
11
|
dest = Path.resolve(dest);
|
|
12
12
|
directory.make(Path.dirname(dest));
|
|
13
|
-
|
|
13
|
+
Fs.copyFileSync(src, dest);
|
|
14
14
|
return dest;
|
|
15
15
|
},
|
|
16
16
|
toDir(src, dest) {
|
|
17
17
|
dest = Path.resolve(dest, Path.basename(src));
|
|
18
18
|
directory.make(Path.dirname(dest));
|
|
19
|
-
|
|
19
|
+
Fs.copyFileSync(src, dest);
|
|
20
20
|
return dest;
|
|
21
21
|
}
|
|
22
22
|
},
|
|
@@ -24,22 +24,22 @@ export const file = {
|
|
|
24
24
|
toFile(src, dest) {
|
|
25
25
|
dest = Path.resolve(dest);
|
|
26
26
|
directory.make(Path.dirname(dest));
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
Fs.copyFileSync(src, dest);
|
|
28
|
+
Fs.unlinkSync(src);
|
|
29
29
|
return dest;
|
|
30
30
|
},
|
|
31
31
|
toDir(src, dest) {
|
|
32
32
|
dest = Path.resolve(dest, Path.basename(src));
|
|
33
33
|
directory.make(Path.dirname(dest));
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
Fs.copyFileSync(src, dest);
|
|
35
|
+
Fs.unlinkSync(src);
|
|
36
36
|
return dest;
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
read: {
|
|
40
40
|
json(path) {
|
|
41
41
|
try {
|
|
42
|
-
return JSON.parse(
|
|
42
|
+
return JSON.parse(Fs.readFileSync(path).toString());
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
45
|
return undefined;
|
|
@@ -47,7 +47,7 @@ export const file = {
|
|
|
47
47
|
},
|
|
48
48
|
text(path) {
|
|
49
49
|
try {
|
|
50
|
-
return
|
|
50
|
+
return Fs.readFileSync(path).toString();
|
|
51
51
|
}
|
|
52
52
|
catch (e) {
|
|
53
53
|
return undefined;
|
|
@@ -57,11 +57,11 @@ export const file = {
|
|
|
57
57
|
write: {
|
|
58
58
|
json(path, data) {
|
|
59
59
|
directory.make(Path.dirname(path));
|
|
60
|
-
|
|
60
|
+
Fs.writeFileSync(path, JSON.stringify(data, null, 2));
|
|
61
61
|
},
|
|
62
62
|
text(path, data) {
|
|
63
63
|
directory.make(Path.dirname(path));
|
|
64
|
-
|
|
64
|
+
Fs.writeFileSync(path, Array.isArray(data) ? data.join("\n") : data.toString());
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
find: {
|
|
@@ -69,30 +69,30 @@ export const file = {
|
|
|
69
69
|
let previous, current = Path.resolve(base);
|
|
70
70
|
do {
|
|
71
71
|
previous = current;
|
|
72
|
-
if (
|
|
72
|
+
if (Fs.existsSync(Path.join(current, subpath)))
|
|
73
73
|
return current;
|
|
74
74
|
current = Path.dirname(current);
|
|
75
75
|
} while (current != previous);
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
remove(path) {
|
|
79
|
-
if (
|
|
80
|
-
|
|
79
|
+
if (Fs.existsSync(path)) {
|
|
80
|
+
Fs.unlinkSync(path);
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
export const directory = {
|
|
85
85
|
exists(path) {
|
|
86
|
-
return
|
|
86
|
+
return Fs.existsSync(path) && Fs.lstatSync(path).isDirectory();
|
|
87
87
|
},
|
|
88
88
|
filenames(path, recursive) {
|
|
89
89
|
try {
|
|
90
90
|
if (recursive) {
|
|
91
91
|
function* walkSync(dir) {
|
|
92
|
-
const files =
|
|
92
|
+
const files = Fs.readdirSync(dir);
|
|
93
93
|
for (const file of files) {
|
|
94
94
|
const pathToFile = Path.join(dir, file);
|
|
95
|
-
const isDirectory =
|
|
95
|
+
const isDirectory = Fs.statSync(pathToFile).isDirectory();
|
|
96
96
|
if (isDirectory) {
|
|
97
97
|
yield* walkSync(pathToFile);
|
|
98
98
|
}
|
|
@@ -108,7 +108,7 @@ export const directory = {
|
|
|
108
108
|
return _Result;
|
|
109
109
|
}
|
|
110
110
|
else
|
|
111
|
-
return
|
|
111
|
+
return Fs.readdirSync(path) || [];
|
|
112
112
|
}
|
|
113
113
|
catch (e) {
|
|
114
114
|
return [];
|
|
@@ -116,9 +116,9 @@ export const directory = {
|
|
|
116
116
|
},
|
|
117
117
|
copy(src, dest, filter) {
|
|
118
118
|
if (directory.exists(src)) {
|
|
119
|
-
for (const name of
|
|
119
|
+
for (const name of Fs.readdirSync(src)) {
|
|
120
120
|
const path = Path.join(src, name);
|
|
121
|
-
const stats =
|
|
121
|
+
const stats = Fs.lstatSync(path);
|
|
122
122
|
const destination = Path.join(dest, name);
|
|
123
123
|
if (stats.isDirectory()) {
|
|
124
124
|
directory.copy(path, destination, filter);
|
|
@@ -130,15 +130,15 @@ export const directory = {
|
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
make(path) {
|
|
133
|
-
if (path && !
|
|
134
|
-
|
|
133
|
+
if (path && !Fs.existsSync(path)) {
|
|
134
|
+
Fs.mkdirSync(path, { recursive: true });
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
remove(path, onlyInner) {
|
|
138
|
-
if (
|
|
139
|
-
|
|
138
|
+
if (Fs.existsSync(path) && Fs.lstatSync(path).isDirectory()) {
|
|
139
|
+
Fs.readdirSync(path).forEach(function (entry) {
|
|
140
140
|
var entry_path = Path.join(path, entry);
|
|
141
|
-
if (
|
|
141
|
+
if (Fs.lstatSync(entry_path).isDirectory()) {
|
|
142
142
|
directory.remove(entry_path);
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
@@ -151,7 +151,7 @@ export const directory = {
|
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
if (!onlyInner) {
|
|
154
|
-
|
|
154
|
+
Fs.rmdirSync(path);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
},
|
|
@@ -180,12 +180,36 @@ export function make_normalized_dirname(baseDir, ...path) {
|
|
|
180
180
|
export function make_canonical_path(baseDir, ...path) {
|
|
181
181
|
let targetPath = Path.resolve(baseDir, ...path);
|
|
182
182
|
try {
|
|
183
|
-
const stats =
|
|
183
|
+
const stats = Fs.lstatSync(targetPath);
|
|
184
184
|
if (stats.isSymbolicLink()) {
|
|
185
|
-
targetPath =
|
|
185
|
+
targetPath = Fs.readlinkSync(targetPath);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
catch (err) { }
|
|
189
189
|
return make_normalized_path(targetPath);
|
|
190
190
|
}
|
|
191
|
+
const FILE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json'];
|
|
192
|
+
/** Resolve a file path with extension probing */
|
|
193
|
+
export function resolve_normalized_suffixed_path(baseDir, path, exts = FILE_EXTENSIONS) {
|
|
194
|
+
const resolved = make_normalized_path(baseDir, path);
|
|
195
|
+
// Check if exact path exists
|
|
196
|
+
if (Fs.existsSync(resolved) && Fs.statSync(resolved).isFile()) {
|
|
197
|
+
return resolved;
|
|
198
|
+
}
|
|
199
|
+
// Try with common extensions
|
|
200
|
+
for (const ext of exts) {
|
|
201
|
+
const withExt = resolved + ext;
|
|
202
|
+
if (Fs.existsSync(withExt))
|
|
203
|
+
return withExt;
|
|
204
|
+
}
|
|
205
|
+
// Try index files in directory
|
|
206
|
+
if (Fs.existsSync(resolved) && Fs.statSync(resolved).isDirectory()) {
|
|
207
|
+
for (const ext of exts) {
|
|
208
|
+
const indexPath = make_normalized_path(resolved, `index${ext}`);
|
|
209
|
+
if (Fs.existsSync(indexPath))
|
|
210
|
+
return indexPath;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
191
215
|
//# sourceMappingURL=file.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jointhedots/gear",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"jointhedots-gear": "esm/cli.js"
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
":build:ui": "node --enable-source-maps --watch-path=esm esm/cli make --buns jointhedots.ui --ws ../jointhedots-core/packages/jointhedots-ui",
|
|
20
20
|
":build:cortex": "node --enable-source-maps --watch-path=esm esm/cli make --buns @jointhedots/cortex --devmode --ws ../jointhedots-core/packages/jointhedots-cortex",
|
|
21
21
|
":build:libs": "node --enable-source-maps --watch-path=esm esm/cli make --libs @jointhedots/core,@jointhedots/ui --devmode --ws ../jointhedots-core",
|
|
22
|
+
":build:lib:core": "node --enable-source-maps --watch-path=esm esm/cli make --libs @jointhedots/core --devmode --ws ../jointhedots-core/packages/jointhedots-core",
|
|
23
|
+
":build:lib:ui": "node --enable-source-maps --watch-path=esm esm/cli make --libs @jointhedots/ui --devmode --ws ../jointhedots-core/packages/jointhedots-ui",
|
|
22
24
|
":build:app": "node --enable-source-maps --watch-path=esm esm/cli make --apps playground:ui --ws ../jointhedots-core",
|
|
23
25
|
"serve:mono": "node --enable-source-maps --watch-path=esm esm/cli serve --app playground:ui --devmode --port 3002 --ws ../jointhedots-core",
|
|
24
26
|
"serve:host": "node --enable-source-maps --watch-path=esm esm/cli serve --app playground:ui:host --port 3002 --ws ../jointhedots-core",
|