@travetto/pack 3.1.0-rc.4 → 3.1.0-rc.5
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/README.md +5 -9
- package/package.json +3 -3
- package/support/bin/config.ts +9 -9
- package/support/bin/operation.ts +3 -38
- package/support/pack.base.ts +1 -2
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ mkdir -p $DIST
|
|
|
167
167
|
|
|
168
168
|
echo "Writing .env.js"
|
|
169
169
|
|
|
170
|
-
echo "process.env.TRV_MANIFEST = '
|
|
170
|
+
echo "process.env.TRV_MANIFEST = 'manifest.json';" > $DIST/.env.js
|
|
171
171
|
echo "process.env.TRV_MODULE = '$MOD';" >> $DIST/.env.js
|
|
172
172
|
echo "process.env.TRV_CLI_IPC = '';" >> $DIST/.env.js
|
|
173
173
|
|
|
@@ -175,7 +175,7 @@ echo "process.env.TRV_CLI_IPC = '';" >> $DIST/.env.js
|
|
|
175
175
|
|
|
176
176
|
echo "Writing package.json"
|
|
177
177
|
|
|
178
|
-
echo "{\"type\":\"commonjs\"}" > $DIST/package.json
|
|
178
|
+
echo "{\"type\":\"commonjs\",\"main\":\"todo-app.js\"}" > $DIST/package.json
|
|
179
179
|
|
|
180
180
|
# Writing entry scripts todo-app.sh args=(run:rest)
|
|
181
181
|
|
|
@@ -199,17 +199,13 @@ chmod 755 $DIST/todo-app.cmd
|
|
|
199
199
|
|
|
200
200
|
echo "Copying over resources"
|
|
201
201
|
|
|
202
|
-
mkdir -p $DIST/node_modules/$MOD
|
|
203
|
-
cp $TRV_OUT/node_modules/$MOD/package.json $DIST/node_modules/$MOD/package.json
|
|
204
|
-
mkdir -p $DIST/node_modules/@travetto/manifest
|
|
205
|
-
cp $TRV_OUT/node_modules/@travetto/manifest/package.json $DIST/node_modules/@travetto/manifest/package.json
|
|
206
202
|
cp -r -p $ROOT/resources $DIST/resources
|
|
207
203
|
|
|
208
|
-
# Writing Manifest
|
|
204
|
+
# Writing Manifest manifest.json
|
|
209
205
|
|
|
210
|
-
echo "Writing Manifest
|
|
206
|
+
echo "Writing Manifest manifest.json"
|
|
211
207
|
|
|
212
|
-
TRV_MODULE=$MOD npx trv manifest $DIST/
|
|
208
|
+
TRV_MODULE=$MOD npx trv manifest $DIST/manifest.json prod
|
|
213
209
|
|
|
214
210
|
# Bundling Output minify=true sourcemap=false entryPoint=@travetto/cli/support/entry.cli
|
|
215
211
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "3.1.0-rc.
|
|
3
|
+
"version": "3.1.0-rc.5",
|
|
4
4
|
"description": "Code packing utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"travetto",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"@rollup/plugin-json": "^6.0.0",
|
|
29
29
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
30
30
|
"@rollup/plugin-terser": "^0.4.0",
|
|
31
|
-
"@travetto/base": "^3.1.0-rc.
|
|
31
|
+
"@travetto/base": "^3.1.0-rc.1",
|
|
32
32
|
"rollup": "^3.17.2",
|
|
33
33
|
"rollup-plugin-sourcemaps": "^0.6.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.1.0-rc.
|
|
36
|
+
"@travetto/cli": "^3.1.0-rc.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/support/bin/config.ts
CHANGED
|
@@ -6,17 +6,17 @@ import type terser from '@rollup/plugin-terser';
|
|
|
6
6
|
import { Env } from '@travetto/base';
|
|
7
7
|
import { ManifestModule, ManifestModuleUtil, Package, path, RootIndex } from '@travetto/manifest';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
try { ${doImport('./.env.js')} } catch {}
|
|
15
|
-
`;
|
|
9
|
+
const makeIntro = (doImport: (name: string) => string, ...extra: string[]): string => [
|
|
10
|
+
`try { globalThis.crypto = ${doImport('crypto')}; } catch {}`,
|
|
11
|
+
`try { ${doImport('./.env.js')} } catch {}`,
|
|
12
|
+
...extra
|
|
13
|
+
].map(x => x.trim()).join('\n');
|
|
16
14
|
|
|
17
15
|
const INTRO = {
|
|
18
|
-
commonjs:
|
|
19
|
-
|
|
16
|
+
commonjs: makeIntro(
|
|
17
|
+
v => `require('${v}')`,
|
|
18
|
+
__importStar.toString().replace(/function([^(]+)/, 'function __importStar'),
|
|
19
|
+
),
|
|
20
20
|
module: makeIntro(v => `await import('${v}')`)
|
|
21
21
|
};
|
|
22
22
|
|
package/support/bin/operation.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { cliTpl } from '@travetto/cli';
|
|
|
7
7
|
import { CommonPackConfig } from './types';
|
|
8
8
|
import { PackUtil } from './util';
|
|
9
9
|
import { ActiveShellCommand, ShellCommands } from './shell';
|
|
10
|
-
import { RUNTIME_MODULES } from './config';
|
|
11
10
|
|
|
12
11
|
async function writeRawFile(file: string, contents: string, mode?: string): Promise<void> {
|
|
13
12
|
await fs.writeFile(file, contents, { encoding: 'utf8', mode });
|
|
@@ -121,7 +120,7 @@ export class PackOperation {
|
|
|
121
120
|
static async * writeEnv(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
122
121
|
const file = '.env.js';
|
|
123
122
|
const env = {
|
|
124
|
-
TRV_MANIFEST:
|
|
123
|
+
TRV_MANIFEST: 'manifest.json',
|
|
125
124
|
TRV_MODULE: cfg.module,
|
|
126
125
|
TRV_CLI_IPC: ''
|
|
127
126
|
};
|
|
@@ -185,31 +184,13 @@ export class PackOperation {
|
|
|
185
184
|
dest: path.resolve(cfg.workspace, 'resources')
|
|
186
185
|
};
|
|
187
186
|
|
|
188
|
-
const copyFiles = [
|
|
189
|
-
RootIndex.manifest.modules[RootIndex.mainModule.name],
|
|
190
|
-
RootIndex.manifest.modules['@travetto/manifest']
|
|
191
|
-
].map(mod => ({
|
|
192
|
-
src: path.resolve(RootIndex.outputRoot, mod.outputFolder, 'package.json'),
|
|
193
|
-
dest: path.resolve(cfg.workspace, mod.outputFolder, 'package.json'),
|
|
194
|
-
destFolder: path.resolve(cfg.workspace, mod.outputFolder)
|
|
195
|
-
}));
|
|
196
|
-
|
|
197
187
|
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Copying over resources' }}`);
|
|
198
188
|
|
|
199
189
|
if (cfg.ejectFile) {
|
|
200
|
-
yield* copyFiles.flatMap(mod => [
|
|
201
|
-
ActiveShellCommand.mkdir(path.dirname(mod.dest)),
|
|
202
|
-
ActiveShellCommand.copy(mod.src, mod.dest)
|
|
203
|
-
]);
|
|
204
190
|
if (resources.count) {
|
|
205
191
|
yield ActiveShellCommand.copyRecursive(resources.src, path.resolve(cfg.workspace, 'resources'));
|
|
206
192
|
}
|
|
207
193
|
} else {
|
|
208
|
-
for (const { src, dest, destFolder } of copyFiles) {
|
|
209
|
-
await fs.mkdir(destFolder, { recursive: true });
|
|
210
|
-
await fs.copyFile(src, dest);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
194
|
if (resources.count) {
|
|
214
195
|
await fs.mkdir(path.dirname(resources.dest), { recursive: true });
|
|
215
196
|
await PackUtil.copyRecursive(resources.src, resources.dest);
|
|
@@ -221,11 +202,11 @@ export class PackOperation {
|
|
|
221
202
|
* Produce the output manifest, only including prod dependencies
|
|
222
203
|
*/
|
|
223
204
|
static async * writeManifest(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
224
|
-
const out = path.resolve(cfg.workspace, '
|
|
205
|
+
const out = path.resolve(cfg.workspace, 'manifest.json');
|
|
225
206
|
const cmd = ['npx', 'trv', 'manifest', out, 'prod'];
|
|
226
207
|
const env = { TRV_MODULE: cfg.module };
|
|
227
208
|
|
|
228
|
-
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Writing Manifest' }} ${{ path:
|
|
209
|
+
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Writing Manifest' }} ${{ path: 'manifest.json' }}`);
|
|
229
210
|
|
|
230
211
|
if (cfg.ejectFile) {
|
|
231
212
|
yield [...Object.entries(env).map(([k, v]) => `${k}=${v}`), ...cmd];
|
|
@@ -234,22 +215,6 @@ export class PackOperation {
|
|
|
234
215
|
}
|
|
235
216
|
}
|
|
236
217
|
|
|
237
|
-
/**
|
|
238
|
-
* Duplicate node_modules
|
|
239
|
-
*/
|
|
240
|
-
static async * duplicateNodeModules(cfg: CommonPackConfig): AsyncIterable<string[]> {
|
|
241
|
-
const src = path.resolve(cfg.workspace, 'node_modules');
|
|
242
|
-
const dest = path.resolve(cfg.workspace, RUNTIME_MODULES);
|
|
243
|
-
|
|
244
|
-
yield* PackOperation.title(cfg, cliTpl`${{ title: 'Creating a Copy of Node Modules' }} ${{ path: path.join('node_modules') }}`);
|
|
245
|
-
|
|
246
|
-
if (cfg.ejectFile) {
|
|
247
|
-
yield ActiveShellCommand.copyRecursive(src, dest);
|
|
248
|
-
} else {
|
|
249
|
-
await PackUtil.copyRecursive(src, dest);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
218
|
/**
|
|
254
219
|
* Generate ZIP file for workspace
|
|
255
220
|
*/
|
package/support/pack.base.ts
CHANGED
|
@@ -69,7 +69,6 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
69
69
|
PackOperation.writeEntryScript,
|
|
70
70
|
PackOperation.copyResources,
|
|
71
71
|
PackOperation.writeManifest,
|
|
72
|
-
PackOperation.duplicateNodeModules,
|
|
73
72
|
PackOperation.bundle,
|
|
74
73
|
];
|
|
75
74
|
}
|
|
@@ -102,7 +101,7 @@ export abstract class BasePackCommand implements CliCommandShape {
|
|
|
102
101
|
|
|
103
102
|
async main(args: string[] = []): Promise<void> {
|
|
104
103
|
this.entryArguments = [...args, ...this.#unknownArgs ?? []];
|
|
105
|
-
this.module ||= RootIndex.
|
|
104
|
+
this.module ||= RootIndex.mainModuleName;
|
|
106
105
|
this.mainName ??= path.basename(this.module);
|
|
107
106
|
|
|
108
107
|
const stream = this.runOperations();
|