@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.
Files changed (113) hide show
  1. package/esm/builder/build-app-bundle.d.ts +28 -0
  2. package/esm/builder/build-app-bundle.js +4 -7
  3. package/esm/builder/build-app-host.d.ts +28 -0
  4. package/esm/builder/build-app-host.js +0 -1
  5. package/esm/builder/build-application.d.ts +47 -0
  6. package/esm/builder/build-application.js +3 -5
  7. package/esm/builder/build-library.d.ts +20 -0
  8. package/esm/builder/build-library.js +1 -2
  9. package/esm/builder/build-target.d.ts +27 -0
  10. package/esm/builder/build-target.js +3 -4
  11. package/esm/builder/helpers/emit-bundle-manifest.d.ts +9 -0
  12. package/esm/builder/helpers/emit-bundle-manifest.js +1 -2
  13. package/esm/builder/helpers/emit-components-dts.d.ts +9 -0
  14. package/esm/builder/helpers/emit-components-dts.js +1 -2
  15. package/esm/builder/helpers/emit-esmodules.d.ts +61 -0
  16. package/esm/builder/helpers/emit-esmodules.js +5 -6
  17. package/esm/builder/helpers/emit-package-manifest.d.ts +9 -0
  18. package/esm/builder/helpers/emit-package-manifest.js +0 -1
  19. package/esm/builder/helpers/emit-static-assets.d.ts +14 -0
  20. package/esm/builder/helpers/emit-static-assets.js +1 -2
  21. package/esm/builder/helpers/emit-typescript-definition.d.ts +35 -0
  22. package/esm/builder/helpers/emit-typescript-definition.js +6 -7
  23. package/esm/builder/helpers/path-helpers.d.ts +9 -0
  24. package/esm/builder/helpers/path-helpers.js +0 -1
  25. package/esm/builder/helpers/task.d.ts +8 -0
  26. package/esm/builder/helpers/task.js +0 -1
  27. package/esm/cli.d.ts +2 -0
  28. package/esm/cli.js +1 -4
  29. package/esm/commands/init.d.ts +2 -0
  30. package/esm/commands/init.js +0 -1
  31. package/esm/commands/install.d.ts +5 -0
  32. package/esm/commands/install.js +4 -5
  33. package/esm/commands/make.d.ts +16 -0
  34. package/esm/commands/make.js +5 -5
  35. package/esm/commands/run.d.ts +8 -0
  36. package/esm/commands/run.js +6 -7
  37. package/esm/commands/serve.d.ts +9 -0
  38. package/esm/commands/serve.js +3 -4
  39. package/esm/core/commands/interface.d.ts +26 -0
  40. package/esm/core/commands/interface.js +21 -0
  41. package/esm/core/components/components.d.ts +73 -0
  42. package/esm/core/components/components.js +2 -0
  43. package/esm/core/components/helpers.d.ts +7 -0
  44. package/esm/core/components/helpers.js +68 -0
  45. package/esm/core/components/manifold.d.ts +77 -0
  46. package/esm/core/components/manifold.js +442 -0
  47. package/esm/core/components/mod.d.ts +4 -0
  48. package/esm/core/components/mod.js +4 -0
  49. package/esm/core/components/provider.d.ts +42 -0
  50. package/esm/core/components/provider.js +127 -0
  51. package/esm/core/logging/mod.d.ts +53 -0
  52. package/esm/core/logging/mod.js +142 -0
  53. package/esm/core/logging/trace.d.ts +51 -0
  54. package/esm/core/logging/trace.js +17 -0
  55. package/esm/core/mod-browser.d.ts +1 -0
  56. package/esm/core/mod-browser.js +1 -0
  57. package/esm/core/mod-node.d.ts +1 -0
  58. package/esm/core/mod-node.js +1 -0
  59. package/esm/core/mod.d.ts +5 -0
  60. package/esm/core/mod.js +5 -0
  61. package/esm/core/schema/helpers.d.ts +36 -0
  62. package/esm/core/schema/helpers.js +163 -0
  63. package/esm/core/schema/mod.d.ts +3 -0
  64. package/esm/core/schema/mod.js +3 -0
  65. package/esm/core/schema/schema.d.ts +376 -0
  66. package/esm/core/schema/schema.js +234 -0
  67. package/esm/core/schema/zod.d.ts +44 -0
  68. package/esm/core/schema/zod.js +127 -0
  69. package/esm/core/services/mod.d.ts +5 -0
  70. package/esm/core/services/mod.js +5 -0
  71. package/esm/core/services/service-accessor.d.ts +17 -0
  72. package/esm/core/services/service-accessor.js +20 -0
  73. package/esm/core/services/service-definitions.d.ts +37 -0
  74. package/esm/core/services/service-definitions.js +44 -0
  75. package/esm/core/services/service-points.d.ts +40 -0
  76. package/esm/core/services/service-points.js +164 -0
  77. package/esm/core/services/service-specification.d.ts +52 -0
  78. package/esm/core/services/service-specification.js +59 -0
  79. package/esm/core/services/settings.d.ts +29 -0
  80. package/esm/core/services/settings.js +123 -0
  81. package/esm/utils/file.d.ts +39 -0
  82. package/esm/utils/file.js +3 -4
  83. package/esm/utils/graph-ordering.d.ts +21 -0
  84. package/esm/utils/graph-ordering.js +0 -1
  85. package/esm/utils/normalized-name.d.ts +17 -0
  86. package/esm/utils/normalized-name.js +0 -1
  87. package/esm/workspace/component.d.ts +70 -0
  88. package/esm/workspace/component.js +0 -1
  89. package/esm/workspace/helpers/config-loader.d.ts +37 -0
  90. package/esm/workspace/helpers/config-loader.js +4 -5
  91. package/esm/workspace/helpers/create-manifests.d.ts +13 -0
  92. package/esm/workspace/helpers/create-manifests.js +1 -2
  93. package/esm/workspace/helpers/discover-workspace.d.ts +4 -0
  94. package/esm/workspace/helpers/discover-workspace.js +130 -134
  95. package/esm/workspace/helpers/lockfile.d.ts +5 -0
  96. package/esm/workspace/helpers/lockfile.js +0 -1
  97. package/esm/workspace/helpers/logger.d.ts +65 -0
  98. package/esm/workspace/helpers/logger.js +0 -1
  99. package/esm/workspace/helpers/package-npm.d.ts +1 -0
  100. package/esm/workspace/helpers/package-npm.js +0 -1
  101. package/esm/workspace/mod.d.ts +1 -0
  102. package/esm/workspace/mod.js +1 -0
  103. package/esm/workspace/packager.d.ts +5 -0
  104. package/esm/workspace/packager.js +1 -2
  105. package/esm/workspace/packagers/packager-standard.d.ts +7 -0
  106. package/esm/workspace/packagers/packager-standard.js +48 -24
  107. package/esm/workspace/storage.d.ts +59 -0
  108. package/esm/workspace/storage.js +19 -15
  109. package/esm/workspace/workspace.d.ts +161 -0
  110. package/esm/workspace/workspace.js +25 -17
  111. package/package.json +25 -18
  112. package/esm/commands/publish.js +0 -36
  113. 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, makeNormalizedName, NameStyle } from "../utils/normalized-name.js";
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
- search_directories = null;
32
- constructor(name, path, descriptor, workspace, installed) {
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 ? makeNormalizedName(id, NameStyle.OBJECT) : computeNameHashID(id);
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 bundle of this.bundles) {
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 bundle of this.bundles) {
128
- if (bundle.alias === id)
129
- return bundle;
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.1.18",
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": "node --enable-source-maps --watch-path=esm esm/cli serve --app playground:agent --devmode --port 3001 --ws ../jointhedots-core/packages/jointhedots-agent",
22
- ":build:core": "node --enable-source-maps --watch-path=esm esm/cli make --buns jointhedots.core --devmode --ws ../jointhedots-core/packages/jointhedots-core",
23
- ":build:ui": "node --enable-source-maps --watch-path=esm esm/cli make --buns jointhedots.ui --ws ../jointhedots-core/packages/jointhedots-ui",
24
- ":build:cortex": "node --enable-source-maps --watch-path=esm esm/cli make --buns @jointhedots/cortex --devmode --ws ../jointhedots-core/packages/jointhedots-cortex",
25
- ":build:libs": "node --enable-source-maps --watch-path=esm esm/cli make --libs @jointhedots/core,@jointhedots/ui --devmode --ws ../jointhedots-core",
26
- ":build:lib:core": "node --enable-source-maps --watch-path=esm esm/cli make --libs @jointhedots/core --devmode --ws ../jointhedots-core/packages/jointhedots-core",
27
- ":build:lib:ui": "node --enable-source-maps --watch-path=esm esm/cli make --libs @jointhedots/ui --devmode --ws ../jointhedots-core/packages/jointhedots-ui",
28
- ":build:app": "node --enable-source-maps --watch-path=esm esm/cli make --apps playground:ui --ws ../jointhedots-core",
29
- "serve:mono": "node --enable-source-maps --watch-path=esm esm/cli serve --app playground:ui --devmode --port 3002 --ws ../jointhedots-core",
30
- "serve:host": "node --enable-source-maps --watch-path=esm esm/cli serve --app playground:ui:host --devmode --port 3002 --ws ../jointhedots-core",
31
- "serve:sfe": "node --enable-source-maps --watch-path=esm esm/cli serve --app sfe-demo --devmode --ws ../sf-explorer-app",
32
- "serve:demo": "node --enable-source-maps --watch-path=esm esm/cli serve --app sfe-demo --devmode --ws ../sf-explorer-demo",
33
- "make:sfe": "node --enable-source-maps --watch-path=esm esm/cli make --libs @sf-explorer/app --devmode --ws ../sf-explorer-app",
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",
@@ -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