@jointhedots/gear 1.1.18 → 1.2.2
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 +28 -0
- package/esm/builder/build-app-bundle.js +4 -7
- package/esm/builder/build-app-host.d.ts +28 -0
- package/esm/builder/build-app-host.js +0 -1
- package/esm/builder/build-application.d.ts +47 -0
- package/esm/builder/build-application.js +3 -5
- package/esm/builder/build-library.d.ts +20 -0
- package/esm/builder/build-library.js +1 -2
- package/esm/builder/build-target.d.ts +27 -0
- package/esm/builder/build-target.js +3 -4
- package/esm/builder/helpers/emit-bundle-manifest.d.ts +9 -0
- package/esm/builder/helpers/emit-bundle-manifest.js +1 -2
- package/esm/builder/helpers/emit-components-dts.d.ts +9 -0
- package/esm/builder/helpers/emit-components-dts.js +1 -2
- package/esm/builder/helpers/emit-esmodules.d.ts +61 -0
- package/esm/builder/helpers/emit-esmodules.js +5 -6
- package/esm/builder/helpers/emit-package-manifest.d.ts +9 -0
- package/esm/builder/helpers/emit-package-manifest.js +0 -1
- package/esm/builder/helpers/emit-static-assets.d.ts +14 -0
- package/esm/builder/helpers/emit-static-assets.js +1 -2
- package/esm/builder/helpers/emit-typescript-definition.d.ts +35 -0
- package/esm/builder/helpers/emit-typescript-definition.js +6 -7
- package/esm/builder/helpers/path-helpers.d.ts +9 -0
- package/esm/builder/helpers/path-helpers.js +0 -1
- package/esm/builder/helpers/task.d.ts +8 -0
- package/esm/builder/helpers/task.js +0 -1
- package/esm/cli.d.ts +2 -0
- package/esm/cli.js +1 -4
- package/esm/commands/init.d.ts +2 -0
- package/esm/commands/init.js +0 -1
- package/esm/commands/install.d.ts +5 -0
- package/esm/commands/install.js +4 -5
- package/esm/commands/make.d.ts +16 -0
- package/esm/commands/make.js +5 -5
- package/esm/commands/run.d.ts +8 -0
- package/esm/commands/run.js +6 -7
- package/esm/commands/serve.d.ts +9 -0
- package/esm/commands/serve.js +3 -4
- package/esm/core/commands/interface.d.ts +26 -0
- package/esm/core/commands/interface.js +21 -0
- package/esm/core/components/components.d.ts +73 -0
- package/esm/core/components/components.js +2 -0
- package/esm/core/components/helpers.d.ts +7 -0
- package/esm/core/components/helpers.js +68 -0
- package/esm/core/components/manifold.d.ts +77 -0
- package/esm/core/components/manifold.js +442 -0
- package/esm/core/components/mod.d.ts +4 -0
- package/esm/core/components/mod.js +4 -0
- package/esm/core/components/provider.d.ts +42 -0
- package/esm/core/components/provider.js +127 -0
- package/esm/core/logging/mod.d.ts +53 -0
- package/esm/core/logging/mod.js +142 -0
- package/esm/core/logging/trace.d.ts +51 -0
- package/esm/core/logging/trace.js +17 -0
- package/esm/core/mod-browser.d.ts +1 -0
- package/esm/core/mod-browser.js +1 -0
- package/esm/core/mod-node.d.ts +1 -0
- package/esm/core/mod-node.js +1 -0
- package/esm/core/mod.d.ts +5 -0
- package/esm/core/mod.js +5 -0
- package/esm/core/schema/helpers.d.ts +36 -0
- package/esm/core/schema/helpers.js +163 -0
- package/esm/core/schema/mod.d.ts +3 -0
- package/esm/core/schema/mod.js +3 -0
- package/esm/core/schema/schema.d.ts +376 -0
- package/esm/core/schema/schema.js +234 -0
- package/esm/core/schema/zod.d.ts +44 -0
- package/esm/core/schema/zod.js +127 -0
- package/esm/core/services/mod.d.ts +5 -0
- package/esm/core/services/mod.js +5 -0
- package/esm/core/services/service-accessor.d.ts +17 -0
- package/esm/core/services/service-accessor.js +20 -0
- package/esm/core/services/service-definitions.d.ts +37 -0
- package/esm/core/services/service-definitions.js +44 -0
- package/esm/core/services/service-points.d.ts +40 -0
- package/esm/core/services/service-points.js +164 -0
- package/esm/core/services/service-specification.d.ts +52 -0
- package/esm/core/services/service-specification.js +59 -0
- package/esm/core/services/settings.d.ts +29 -0
- package/esm/core/services/settings.js +123 -0
- package/esm/utils/file.d.ts +39 -0
- package/esm/utils/file.js +3 -4
- package/esm/utils/graph-ordering.d.ts +21 -0
- package/esm/utils/graph-ordering.js +0 -1
- package/esm/utils/normalized-name.d.ts +17 -0
- package/esm/utils/normalized-name.js +0 -1
- package/esm/workspace/component.d.ts +70 -0
- package/esm/workspace/component.js +0 -1
- package/esm/workspace/helpers/config-loader.d.ts +37 -0
- package/esm/workspace/helpers/config-loader.js +4 -5
- package/esm/workspace/helpers/create-manifests.d.ts +13 -0
- package/esm/workspace/helpers/create-manifests.js +1 -2
- package/esm/workspace/helpers/discover-workspace.d.ts +4 -0
- package/esm/workspace/helpers/discover-workspace.js +130 -134
- package/esm/workspace/helpers/lockfile.d.ts +5 -0
- package/esm/workspace/helpers/lockfile.js +0 -1
- package/esm/workspace/helpers/logger.d.ts +65 -0
- package/esm/workspace/helpers/logger.js +0 -1
- package/esm/workspace/helpers/package-npm.d.ts +1 -0
- package/esm/workspace/helpers/package-npm.js +0 -1
- package/esm/workspace/mod.d.ts +1 -0
- package/esm/workspace/mod.js +1 -0
- package/esm/workspace/packager.d.ts +5 -0
- package/esm/workspace/packager.js +1 -2
- package/esm/workspace/packagers/packager-standard.d.ts +7 -0
- package/esm/workspace/packagers/packager-standard.js +48 -24
- package/esm/workspace/storage.d.ts +59 -0
- package/esm/workspace/storage.js +19 -15
- package/esm/workspace/workspace.d.ts +161 -0
- package/esm/workspace/workspace.js +25 -17
- package/package.json +25 -18
- package/esm/commands/publish.js +0 -36
- package/esm/publish/publish_aws_s3.js +0 -67
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type BundleID, type BundleManifest, type ComponentManifest, type DistributedConfig } from "./component.ts";
|
|
2
|
+
import type { WebAppManifest } from "web-app-manifest";
|
|
3
|
+
import { Logger, Log } from "./helpers/logger.ts";
|
|
4
|
+
export type FileID = string;
|
|
5
|
+
export type ModuleID = string;
|
|
6
|
+
export type ExportID = string;
|
|
7
|
+
export type AssetsEntry = string | {
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
};
|
|
11
|
+
export type WebviewEntry = {
|
|
12
|
+
title?: string;
|
|
13
|
+
entry: ModuleID;
|
|
14
|
+
favicon?: string;
|
|
15
|
+
};
|
|
16
|
+
export type ComponentSelection = {
|
|
17
|
+
selectors?: string[];
|
|
18
|
+
};
|
|
19
|
+
export interface AppDescriptorBase<Manifest = never> {
|
|
20
|
+
type: string;
|
|
21
|
+
name: string;
|
|
22
|
+
icon?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
webviews?: Record<string, WebviewEntry>;
|
|
26
|
+
modules?: Record<string, ModuleID>;
|
|
27
|
+
assets?: AssetsEntry[];
|
|
28
|
+
components?: ComponentSelection;
|
|
29
|
+
manifest?: Manifest;
|
|
30
|
+
}
|
|
31
|
+
export type ChromeAppManifest = chrome.runtime.ManifestV3;
|
|
32
|
+
export interface ComposableAppDescriptor extends AppDescriptorBase {
|
|
33
|
+
type: "composable";
|
|
34
|
+
}
|
|
35
|
+
export interface ChromeAppDescriptor extends AppDescriptorBase<ChromeAppManifest> {
|
|
36
|
+
type: "chrome";
|
|
37
|
+
}
|
|
38
|
+
export interface WebAppDescriptor extends AppDescriptorBase<WebAppManifest> {
|
|
39
|
+
type: "web";
|
|
40
|
+
}
|
|
41
|
+
export type AppDescriptor = ChromeAppDescriptor | WebAppDescriptor | ComposableAppDescriptor;
|
|
42
|
+
export type AppEntry = {
|
|
43
|
+
descriptor: AppDescriptor;
|
|
44
|
+
library: Library;
|
|
45
|
+
baseDir: string;
|
|
46
|
+
path: string;
|
|
47
|
+
};
|
|
48
|
+
export type DeclarationDescriptor = BundleManifest["data"] & {
|
|
49
|
+
packager?: string;
|
|
50
|
+
selectors?: string[];
|
|
51
|
+
assets?: AssetsEntry[];
|
|
52
|
+
exports?: {
|
|
53
|
+
[path: string]: PackageExport;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export type PackageExport = string | {
|
|
57
|
+
import?: string;
|
|
58
|
+
require?: string;
|
|
59
|
+
default?: string;
|
|
60
|
+
types?: string;
|
|
61
|
+
};
|
|
62
|
+
export interface PackageDescriptor {
|
|
63
|
+
name: string;
|
|
64
|
+
version: string;
|
|
65
|
+
module?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
dots?: boolean;
|
|
68
|
+
singleton?: boolean;
|
|
69
|
+
bin?: {
|
|
70
|
+
[commandName: string]: string;
|
|
71
|
+
};
|
|
72
|
+
scripts?: {
|
|
73
|
+
[scriptName: string]: string;
|
|
74
|
+
};
|
|
75
|
+
main?: string;
|
|
76
|
+
types?: string;
|
|
77
|
+
exports?: {
|
|
78
|
+
[path: string]: PackageExport;
|
|
79
|
+
};
|
|
80
|
+
dependencies?: {
|
|
81
|
+
[packageName: string]: string;
|
|
82
|
+
};
|
|
83
|
+
devDependencies?: {
|
|
84
|
+
[packageName: string]: string;
|
|
85
|
+
};
|
|
86
|
+
peerDependencies?: {
|
|
87
|
+
[packageName: string]: string;
|
|
88
|
+
};
|
|
89
|
+
optionalDependencies?: {
|
|
90
|
+
[packageName: string]: string;
|
|
91
|
+
};
|
|
92
|
+
[metadata: string]: any;
|
|
93
|
+
}
|
|
94
|
+
export declare class WorkspaceItem {
|
|
95
|
+
readonly workspace: Workspace;
|
|
96
|
+
readonly log: Log;
|
|
97
|
+
constructor(workspace: Workspace, loggerId: string);
|
|
98
|
+
}
|
|
99
|
+
export declare class Library extends WorkspaceItem {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly path: FileID;
|
|
102
|
+
readonly descriptor: PackageDescriptor;
|
|
103
|
+
readonly workspace: Workspace;
|
|
104
|
+
bundle: Bundle;
|
|
105
|
+
declarations: Map<string, DeclarationDescriptor>;
|
|
106
|
+
applications: Map<string, AppDescriptor>;
|
|
107
|
+
externals: Record<string, string>;
|
|
108
|
+
resolved_versions: Record<string, string>;
|
|
109
|
+
search_directories: FileID[];
|
|
110
|
+
constants: Constants;
|
|
111
|
+
shelve: Bundle[];
|
|
112
|
+
constructor(name: string, path: FileID, descriptor: PackageDescriptor, workspace: Workspace);
|
|
113
|
+
get_id(): string;
|
|
114
|
+
get_bundle(id: string): Bundle;
|
|
115
|
+
make_file_id(prefix: string, id: string): string;
|
|
116
|
+
resolve_entry_path(entryId: string, baseDir: string): string;
|
|
117
|
+
}
|
|
118
|
+
export declare class Bundle extends WorkspaceItem {
|
|
119
|
+
manifest: BundleManifest;
|
|
120
|
+
readonly path: string;
|
|
121
|
+
readonly workspace: Workspace;
|
|
122
|
+
readonly source: Library;
|
|
123
|
+
alias: string;
|
|
124
|
+
components: Map<string, ComponentManifest>;
|
|
125
|
+
distribueds: {
|
|
126
|
+
[packageName: string]: string | DistributedConfig;
|
|
127
|
+
};
|
|
128
|
+
configured: boolean;
|
|
129
|
+
constructor(manifest: BundleManifest, path: string, workspace: Workspace, source?: Library);
|
|
130
|
+
get id(): BundleID;
|
|
131
|
+
get dependencies(): string[];
|
|
132
|
+
get exports(): {
|
|
133
|
+
[id: string]: string;
|
|
134
|
+
};
|
|
135
|
+
resolve_export(ref: string): string;
|
|
136
|
+
}
|
|
137
|
+
export type Constants = {
|
|
138
|
+
[key: string]: string | number;
|
|
139
|
+
};
|
|
140
|
+
export type OpenWorkspaceOptions = {
|
|
141
|
+
workspace_path: string;
|
|
142
|
+
devmode: boolean;
|
|
143
|
+
ignored_directory?: string;
|
|
144
|
+
};
|
|
145
|
+
export declare class Workspace {
|
|
146
|
+
readonly name: string;
|
|
147
|
+
readonly version: string;
|
|
148
|
+
readonly path: string;
|
|
149
|
+
readonly devmode: boolean;
|
|
150
|
+
libraries: Library[];
|
|
151
|
+
constants: Constants;
|
|
152
|
+
ignored_directories: Set<string>;
|
|
153
|
+
readonly logger: Logger;
|
|
154
|
+
readonly log: Log;
|
|
155
|
+
constructor(name: string, version: string, path: string, devmode: boolean);
|
|
156
|
+
get_bundle(id: string): Bundle;
|
|
157
|
+
get_library(name: string): Library;
|
|
158
|
+
get_application(name: string): AppEntry;
|
|
159
|
+
}
|
|
160
|
+
export declare function open_workspace(options: OpenWorkspaceOptions): Promise<Workspace>;
|
|
161
|
+
export declare function matchComponentSelection(components: ComponentSelection, selectors: string[]): boolean;
|
|
@@ -4,7 +4,7 @@ import Process from "node:process";
|
|
|
4
4
|
import DotEnv from "dotenv";
|
|
5
5
|
import { readJsonFile } from "./storage.js";
|
|
6
6
|
import {} from "./component.js";
|
|
7
|
-
import { computeNameHashID
|
|
7
|
+
import { computeNameHashID } from "../utils/normalized-name.js";
|
|
8
8
|
import { make_normalized_path } from "../utils/file.js";
|
|
9
9
|
import { Logger, Log } from "./helpers/logger.js";
|
|
10
10
|
import { discover_workspace } from "./helpers/discover-workspace.js";
|
|
@@ -23,29 +23,40 @@ export class Library extends WorkspaceItem {
|
|
|
23
23
|
path;
|
|
24
24
|
descriptor;
|
|
25
25
|
workspace;
|
|
26
|
-
installed;
|
|
27
26
|
bundle = null;
|
|
28
27
|
declarations = new Map();
|
|
29
28
|
applications = new Map();
|
|
30
29
|
externals = {};
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
resolved_versions = {};
|
|
31
|
+
search_directories = [];
|
|
32
|
+
constants = {};
|
|
33
|
+
shelve = [];
|
|
34
|
+
constructor(name, path, descriptor, workspace) {
|
|
33
35
|
super(workspace, `lib:${name}`);
|
|
34
36
|
this.name = name;
|
|
35
37
|
this.path = path;
|
|
36
38
|
this.descriptor = descriptor;
|
|
37
39
|
this.workspace = workspace;
|
|
38
|
-
this.installed = installed;
|
|
39
|
-
this.search_directories = workspace.search_directories.slice();
|
|
40
40
|
Object.assign(this.externals, descriptor.peerDependencies, descriptor.dependencies);
|
|
41
41
|
}
|
|
42
42
|
get_id() {
|
|
43
43
|
const { name, version } = this.descriptor;
|
|
44
44
|
return `${name}-${version}`;
|
|
45
45
|
}
|
|
46
|
+
get_bundle(id) {
|
|
47
|
+
for (const bundle of this.shelve) {
|
|
48
|
+
if (bundle.id === id)
|
|
49
|
+
return bundle;
|
|
50
|
+
}
|
|
51
|
+
for (const bundle of this.shelve) {
|
|
52
|
+
if (bundle.alias === id)
|
|
53
|
+
return bundle;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
46
57
|
make_file_id(prefix, id) {
|
|
47
58
|
const devmode = true;
|
|
48
|
-
const base = devmode ?
|
|
59
|
+
const base = devmode ? id.replace(/[^a-zA-Z0-9]+/g, "_") : computeNameHashID(id);
|
|
49
60
|
return base ? prefix + "." + base : prefix;
|
|
50
61
|
}
|
|
51
62
|
resolve_entry_path(entryId, baseDir) {
|
|
@@ -104,11 +115,8 @@ export class Workspace {
|
|
|
104
115
|
version;
|
|
105
116
|
path;
|
|
106
117
|
devmode;
|
|
107
|
-
bundles = [];
|
|
108
118
|
libraries = [];
|
|
109
119
|
constants = {};
|
|
110
|
-
resolved_versions = {};
|
|
111
|
-
search_directories = [];
|
|
112
120
|
ignored_directories = new Set();
|
|
113
121
|
logger = new Logger();
|
|
114
122
|
log;
|
|
@@ -120,13 +128,14 @@ export class Workspace {
|
|
|
120
128
|
this.log = this.logger.get(`workspace:${name}`);
|
|
121
129
|
}
|
|
122
130
|
get_bundle(id) {
|
|
123
|
-
for (const
|
|
124
|
-
if (bundle.id === id)
|
|
125
|
-
return bundle;
|
|
131
|
+
for (const lib of this.libraries) {
|
|
132
|
+
if (lib.bundle.id === id)
|
|
133
|
+
return lib.bundle;
|
|
126
134
|
}
|
|
127
|
-
for (const
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
for (const lib of this.libraries) {
|
|
136
|
+
const bun = lib.get_bundle(id);
|
|
137
|
+
if (bun)
|
|
138
|
+
return bun;
|
|
130
139
|
}
|
|
131
140
|
return null;
|
|
132
141
|
}
|
|
@@ -216,4 +225,3 @@ export function matchComponentSelection(components, selectors) {
|
|
|
216
225
|
return true;
|
|
217
226
|
}
|
|
218
227
|
}
|
|
219
|
-
//# sourceMappingURL=workspace.js.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jointhedots/gear",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"packageManager": "pnpm@10.30.3",
|
|
6
6
|
"bin": {
|
|
7
7
|
"jointhedots-gear": "esm/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
|
-
"./workspace": "./esm/workspace.js"
|
|
10
|
+
"./workspace": "./esm/workspace/mod.js",
|
|
11
|
+
"./core": {
|
|
12
|
+
"browser": "./esm/core/mod-browser.js",
|
|
13
|
+
"node": "./esm/core/mod-node.js",
|
|
14
|
+
"deno": "./src/core/mod.ts",
|
|
15
|
+
"default": "./esm/core/mod.js"
|
|
16
|
+
}
|
|
11
17
|
},
|
|
12
18
|
"files": [
|
|
13
19
|
"esm",
|
|
@@ -16,34 +22,35 @@
|
|
|
16
22
|
"!**/*.map"
|
|
17
23
|
],
|
|
18
24
|
"scripts": {
|
|
19
|
-
"watch": "tsc -w",
|
|
25
|
+
"watch": "tsc -w --sourceMap",
|
|
20
26
|
"build": "tsc",
|
|
21
|
-
":serve": "
|
|
22
|
-
":build:core": "
|
|
23
|
-
":build:ui": "
|
|
24
|
-
":build:cortex": "
|
|
25
|
-
":build:libs": "
|
|
26
|
-
":build:lib:core": "
|
|
27
|
-
":build:lib:ui": "
|
|
28
|
-
":build:app": "
|
|
29
|
-
"serve:mono": "
|
|
30
|
-
"serve:host": "
|
|
31
|
-
"serve:sfe": "
|
|
32
|
-
"serve:demo": "
|
|
33
|
-
"make:sfe": "
|
|
27
|
+
":serve": "deno --allow-all --watch=src src/cli.ts serve --app playground:agent --devmode --port 3001 --ws ../jointhedots-core/packages/jointhedots-agent",
|
|
28
|
+
":build:core": "deno --allow-all --watch=src src/cli.ts make --buns jointhedots.core --devmode --ws ../jointhedots-core/packages/jointhedots-core",
|
|
29
|
+
":build:ui": "deno --allow-all --watch=src src/cli.ts make --buns jointhedots.ui --ws ../jointhedots-core/packages/jointhedots-ui",
|
|
30
|
+
":build:cortex": "deno --allow-all --watch=src src/cli.ts make --buns @jointhedots/cortex --devmode --ws ../jointhedots-core/packages/jointhedots-cortex",
|
|
31
|
+
":build:libs": "deno --allow-all --watch=src src/cli.ts make --libs @jointhedots/core,@jointhedots/ui --devmode --ws ../jointhedots-core",
|
|
32
|
+
":build:lib:core": "deno --allow-all --watch=src src/cli.ts make --libs @jointhedots/core --devmode --ws ../jointhedots-core/packages/jointhedots-core",
|
|
33
|
+
":build:lib:ui": "deno --allow-all --watch=src src/cli.ts make --libs @jointhedots/ui --devmode --ws ../jointhedots-core/packages/jointhedots-ui",
|
|
34
|
+
":build:app": "deno --allow-all --watch=src src/cli.ts make --apps playground:ui --ws ../jointhedots-core",
|
|
35
|
+
"serve:mono": "deno --allow-all --watch=src src/cli.ts serve --app playground:ui --devmode --port 3002 --ws ../jointhedots-core",
|
|
36
|
+
"serve:host": "deno --allow-all --watch=src src/cli.ts serve --app playground:ui:host --devmode --port 3002 --ws ../jointhedots-core",
|
|
37
|
+
"serve:sfe": "deno --allow-all --watch=src src/cli.ts serve --app sfe-webapp --devmode --ws ../sf-explorer-app",
|
|
38
|
+
"serve:demo": "deno --allow-all --watch=src src/cli.ts serve --app sfe-demo --devmode --ws ../sf-explorer-demo",
|
|
39
|
+
"make:sfe": "deno --allow-all --watch=src src/cli.ts make --libs @sf-explorer/app --devmode --ws ../sf-explorer-app",
|
|
34
40
|
"prepublishOnly": "node scripts/prepublish.mjs"
|
|
35
41
|
},
|
|
36
42
|
"dependencies": {
|
|
37
|
-
"@aws-sdk/client-s3": "^3.968.0",
|
|
38
43
|
"@jspm/core": "^2.1.0",
|
|
39
44
|
"@tailwindcss/postcss": "~4.1.3",
|
|
40
45
|
"@typescript/native-preview": "^7.0.0-dev.20260310.1",
|
|
46
|
+
"json-schema": "^0.4.0",
|
|
47
|
+
"vscode-uri": "^3.1.0",
|
|
48
|
+
"zod": "^4.3.6",
|
|
41
49
|
"dotenv": "~17.2.3",
|
|
42
50
|
"esbuild": "~0.27.2",
|
|
43
51
|
"esbuild-sass-plugin": "~3.6.0",
|
|
44
52
|
"express": "~5.2.1",
|
|
45
53
|
"mime": "~4.1.0",
|
|
46
|
-
"node-watch": "~0.7.4",
|
|
47
54
|
"postcss": "~8.5.6",
|
|
48
55
|
"sass": "~1.97.2",
|
|
49
56
|
"semver": "~7.7.3",
|
package/esm/commands/publish.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Path from 'node:path';
|
|
2
|
-
import {} from "yargs";
|
|
3
|
-
import { publish_aws_s3 } from '../publish/publish_aws_s3.js';
|
|
4
|
-
import { open_workspace } from "../workspace/workspace.js";
|
|
5
|
-
export function command_publish() {
|
|
6
|
-
return {
|
|
7
|
-
command: 'publish',
|
|
8
|
-
describe: 'publish resources to AWS S3',
|
|
9
|
-
builder: (yargs) => yargs
|
|
10
|
-
.option("app", {
|
|
11
|
-
type: "string",
|
|
12
|
-
required: true,
|
|
13
|
-
})
|
|
14
|
-
.option("bucket", {
|
|
15
|
-
type: "string",
|
|
16
|
-
required: true,
|
|
17
|
-
})
|
|
18
|
-
.option("region", {
|
|
19
|
-
type: "string",
|
|
20
|
-
default: "eu-north-1",
|
|
21
|
-
})
|
|
22
|
-
.option("dist", {
|
|
23
|
-
type: "string",
|
|
24
|
-
default: "./dist",
|
|
25
|
-
}),
|
|
26
|
-
handler: async (argv) => {
|
|
27
|
-
const outputDir = Path.resolve(argv.dist);
|
|
28
|
-
const ws = await open_workspace({
|
|
29
|
-
workspace_path: ".",
|
|
30
|
-
devmode: false,
|
|
31
|
-
});
|
|
32
|
-
await publish_aws_s3(argv.app, ws, argv.bucket, argv.region, outputDir);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=publish.js.map
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import Fs from "node:fs";
|
|
2
|
-
import Path from "node:path";
|
|
3
|
-
import * as AWS from "@aws-sdk/client-s3";
|
|
4
|
-
import MIME from "mime";
|
|
5
|
-
import { StorageFiles } from "../workspace/storage.js";
|
|
6
|
-
import { build_application } from "../builder/build-application.js";
|
|
7
|
-
import { Workspace } from "../workspace/workspace.js";
|
|
8
|
-
export async function publish_aws_s3(appname, ws, bucket, region, outputDir) {
|
|
9
|
-
const storage = new StorageFiles(ws.name, outputDir);
|
|
10
|
-
const app = ws.get_application(appname);
|
|
11
|
-
if (!app)
|
|
12
|
-
throw new Error(`Application '${appname}' not exists`);
|
|
13
|
-
console.time("build");
|
|
14
|
-
await build_application({
|
|
15
|
-
app,
|
|
16
|
-
storage,
|
|
17
|
-
version: "aws_s3",
|
|
18
|
-
devmode: false,
|
|
19
|
-
});
|
|
20
|
-
console.timeEnd("build");
|
|
21
|
-
console.time("load-files");
|
|
22
|
-
const files = [];
|
|
23
|
-
await collectFilesFromDirectory(outputDir, "", files);
|
|
24
|
-
console.timeEnd("load-files");
|
|
25
|
-
console.log(files.reduce((acc, x) => acc + x.data.length, 0) / (1034 * 1024), "Mi");
|
|
26
|
-
console.log(files.length, "files");
|
|
27
|
-
console.time("upload-aws-s3");
|
|
28
|
-
const s3 = new AWS.S3({ region: region });
|
|
29
|
-
await emitFilesToAmzS3(s3, bucket, files);
|
|
30
|
-
console.time("upload-aws-s3");
|
|
31
|
-
}
|
|
32
|
-
async function collectFilesFromDirectory(path, key, files) {
|
|
33
|
-
for (const fname of Fs.readdirSync(path)) {
|
|
34
|
-
const fpath = Path.join(path, fname);
|
|
35
|
-
const fkey = key ? `${key}/${fname}` : fname;
|
|
36
|
-
const fstat = Fs.statSync(fpath);
|
|
37
|
-
if (fstat.isFile()) {
|
|
38
|
-
files.push({
|
|
39
|
-
key: fkey,
|
|
40
|
-
data: Fs.readFileSync(fpath),
|
|
41
|
-
media: MIME.getType(fpath),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
else if (fstat.isDirectory()) {
|
|
45
|
-
await collectFilesFromDirectory(fpath, fkey, files);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async function emitFilesToAmzS3(s3, bucketS3, files) {
|
|
50
|
-
const heads = await Promise.all(files.map((item) => {
|
|
51
|
-
return s3.headObject({
|
|
52
|
-
Bucket: bucketS3,
|
|
53
|
-
Key: item.key,
|
|
54
|
-
}).then(res => res.Metadata, err => null);
|
|
55
|
-
}));
|
|
56
|
-
await Promise.all(files.map(async (item, i) => {
|
|
57
|
-
const head = heads[i];
|
|
58
|
-
await s3.putObject({
|
|
59
|
-
Bucket: bucketS3,
|
|
60
|
-
ACL: "public-read",
|
|
61
|
-
Key: item.key,
|
|
62
|
-
ContentType: item.media,
|
|
63
|
-
Body: item.data,
|
|
64
|
-
});
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=publish_aws_s3.js.map
|