@elaraai/e3-cloud-cli 1.0.91 → 1.0.92

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.
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Running a solution's source module for its default export, as e3's CLI
7
+ * loads a package for `e3 workspace deploy --from-source`: what `e3-cloud app`
8
+ * builds an app from, and `e3-cloud files deploy` its declarations.
9
+ *
10
+ * esbuild bundles the entry (multi-file TypeScript and TSX, with the nearest
11
+ * tsconfig.json), leaving every `@elaraai/*` import to the project's own
12
+ * packages; the bundle is imported from under the project's `node_modules`,
13
+ * so what it builds is of the modules the project's code imports.
14
+ */
15
+ import { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs';
16
+ import { createRequire } from 'node:module';
17
+ import { dirname, join, parse, resolve } from 'node:path';
18
+ import { pathToFileURL } from 'node:url';
19
+ /** Whether a tsconfig.json is in a directory or one above it. */
20
+ function hasTsconfig(from) {
21
+ for (let dir = from;; dir = dirname(dir)) {
22
+ if (existsSync(join(dir, 'tsconfig.json')))
23
+ return true;
24
+ if (dir === parse(dir).root)
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * A source's entry, resolved, and a package of its project's.
30
+ *
31
+ * @param file - The source
32
+ * @param entry - The package the project must have, e.g. `@elaraai/e3-cloud-ui`
33
+ * @param why - What it is needed for, completing "… is built with the version its source imports"
34
+ * @returns The source's absolute path, and the package's entry, as the source's project resolves it
35
+ * @throws {Error} When the source does not exist, or its project lacks the package
36
+ */
37
+ export function resolveSource(file, entry, why) {
38
+ const path = resolve(file);
39
+ if (!existsSync(path))
40
+ throw new Error(`${file} does not exist`);
41
+ try {
42
+ return { path, entryPath: createRequire(path).resolve(entry) };
43
+ }
44
+ catch {
45
+ throw new Error(`${file}'s project has no ${entry}: ${why} with the version its source imports (npm install ${entry})`);
46
+ }
47
+ }
48
+ /** esbuild's options for a source: one ES module, every `@elaraai/*` import left to the project. */
49
+ function bundleOptions(path) {
50
+ return {
51
+ entryPoints: [path],
52
+ bundle: true,
53
+ platform: 'node',
54
+ format: 'esm',
55
+ write: false,
56
+ external: ['@elaraai/*'],
57
+ logLevel: 'silent',
58
+ // Without a tsconfig.json to say so, TSX is east-ui's
59
+ ...(!hasTsconfig(dirname(path)) && { jsx: 'automatic', jsxImportSource: '@elaraai/east-ui' }),
60
+ };
61
+ }
62
+ /**
63
+ * Runs a source module and answers its default export.
64
+ *
65
+ * @param file - The source, as the user named it (for messages)
66
+ * @param path - Its absolute path ({@link resolveSource})
67
+ * @returns Its default export
68
+ * @throws {Error} When it does not bundle or does not run
69
+ */
70
+ export async function sourceDefaultExport(file, path) {
71
+ const esbuild = await import('esbuild');
72
+ const result = await esbuild.build(bundleOptions(path)).catch((err) => {
73
+ throw new Error(`${file} does not bundle: ${err instanceof Error ? err.message : String(err)}`);
74
+ });
75
+ const code = result.outputFiles?.[0]?.text;
76
+ if (code === undefined)
77
+ throw new Error(`esbuild produced no output for ${file}`);
78
+ // Under the project's node_modules, so its @elaraai/* imports resolve to the project's packages
79
+ const cache = join(dirname(path), 'node_modules', '.cache', 'e3-cloud');
80
+ mkdirSync(cache, { recursive: true });
81
+ const bundle = join(cache, `source-${process.pid}-${Date.now()}.mjs`);
82
+ try {
83
+ writeFileSync(bundle, code);
84
+ const module = await import(`${pathToFileURL(bundle).href}?t=${Date.now()}`);
85
+ return module.default;
86
+ }
87
+ catch (err) {
88
+ throw new Error(`${file} did not run: ${err instanceof Error ? err.message : String(err)}`);
89
+ }
90
+ finally {
91
+ try {
92
+ unlinkSync(bundle);
93
+ }
94
+ catch {
95
+ // Ignore cleanup errors
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * Imports a package by the entry a source's project resolves it to.
101
+ *
102
+ * @param entryPath - The entry ({@link resolveSource})
103
+ * @returns The module
104
+ */
105
+ export async function importEntry(entryPath) {
106
+ return await import(pathToFileURL(entryPath).href);
107
+ }
108
+ //# sourceMappingURL=source-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-module.js","sourceRoot":"","sources":["../../src/source-module.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,iEAAiE;AACjE,SAAS,WAAW,CAAC,IAAY;IAC/B,KAAK,IAAI,GAAG,GAAG,IAAI,GAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1C,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACxD,IAAI,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;IAC5C,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iBAAiB,CAAC,CAAC;IACjE,IAAI,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,q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QAAQ,EAAE,UAAU,CAAC,CAAC;IACxE,SAAS,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,UAAU,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtE,IAAI,CAAC;QACH,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,CAA0B,CAAC;QACtG,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iBAAiB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9F,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,UAAU,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAI,SAAiB;IACpD,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,CAAM,CAAC;AAC1D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elaraai/e3-cloud-cli",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "type": "module",
5
5
  "description": "CLI for e3 cloud management",
6
6
  "license": "BUSL-1.1",
@@ -9,19 +9,22 @@
9
9
  },
10
10
  "main": "dist/src/cli.js",
11
11
  "dependencies": {
12
- "@elaraai/e3-api-client": "1.0.91",
13
- "@elaraai/e3-types": "1.0.91",
12
+ "@aws-sdk/client-s3": "^3.966.0",
13
+ "@elaraai/e3-api-client": "1.0.92",
14
+ "@elaraai/e3-core": "1.0.92",
15
+ "@elaraai/e3-types": "1.0.92",
14
16
  "commander": "^12.0.0",
15
17
  "esbuild": "^0.27.2",
16
- "@elaraai/e3-cloud-client": "1.0.91",
17
- "@elaraai/e3-cloud-types": "1.0.91",
18
- "@elaraai/e3-cloud-ui": "1.0.91"
18
+ "@elaraai/e3-cloud-client": "1.0.92",
19
+ "@elaraai/e3-cloud-types": "1.0.92",
20
+ "@elaraai/e3-cloud-files": "1.0.92",
21
+ "@elaraai/e3-cloud-ui": "1.0.92"
19
22
  },
20
23
  "peerDependencies": {
21
- "@elaraai/east": "1.0.91"
24
+ "@elaraai/east": "1.0.92"
22
25
  },
23
26
  "files": [
24
- "dist/src",
27
+ "dist/src/**/*",
25
28
  "!dist/src/**/*.spec.*",
26
29
  "README.md",
27
30
  "LICENSE.md"