create-yeow 0.2.22 → 0.2.24
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/package.json
CHANGED
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
|
-
import { readFileSync, mkdirSync, existsSync, statSync, readdirSync } from 'fs';
|
|
2
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync, readdirSync } from 'fs';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import AdmZip from 'adm-zip';
|
|
@@ -12,11 +12,11 @@ const entry = existsSync(resolve(root, 'src', 'index.ts')) ? 'src/index.ts' : 's
|
|
|
12
12
|
const outDir = resolve(root, 'dist', '.yeow');
|
|
13
13
|
mkdirSync(outDir, { recursive: true });
|
|
14
14
|
|
|
15
|
+
const apiVer = cfg.api || '1.18';
|
|
15
16
|
const isDev = process.env.YEOW_DEV === 'true';
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
esbuild.build({
|
|
18
|
+
async function main() {
|
|
19
|
+
await esbuild.build({
|
|
20
20
|
entryPoints: [resolve(root, entry)],
|
|
21
21
|
outfile: resolve(outDir, 'main.js'),
|
|
22
22
|
bundle: true,
|
|
@@ -27,11 +27,17 @@ if (isDev) {
|
|
|
27
27
|
conditions: ['import', 'browser'],
|
|
28
28
|
treeShaking: true,
|
|
29
29
|
minify: false,
|
|
30
|
-
sourcemap: 'linked',
|
|
31
|
-
})
|
|
32
|
-
const size = statSync(resolve(outDir, 'main.js')).size;
|
|
33
|
-
console.log(` ✓ Bundled (${(size / 1024).toFixed(1)} KB)`);
|
|
30
|
+
sourcemap: isDev ? 'linked' : false,
|
|
31
|
+
});
|
|
34
32
|
|
|
33
|
+
const size = statSync(resolve(outDir, 'main.js')).size;
|
|
34
|
+
console.log(` ✓ Bundled (${(size / 1024).toFixed(1)} KB)`);
|
|
35
|
+
|
|
36
|
+
const tmplJar = resolve(root, '.yeow', 'assets', 'yeow-template-0.1.0.jar');
|
|
37
|
+
const zip = new AdmZip(tmplJar);
|
|
38
|
+
zip.updateFile('plugin.yml', Buffer.from(`name: ${name}\nversion: ${version}\nmain: yeow.template.Bootstrap\napi-version: '${apiVer}'\ndepend:\n - Yeow-Runtime\n`));
|
|
39
|
+
|
|
40
|
+
if (isDev) {
|
|
35
41
|
const devInfo = {
|
|
36
42
|
name,
|
|
37
43
|
codeFile: resolve(outDir, 'main.js').replace(/\\/g, '/'),
|
|
@@ -39,40 +45,9 @@ if (isDev) {
|
|
|
39
45
|
};
|
|
40
46
|
writeFileSync(resolve(outDir, 'dev.json'), JSON.stringify(devInfo, null, 2));
|
|
41
47
|
console.log(` ✓ Dev info written`);
|
|
42
|
-
|
|
43
|
-
const apiVer = cfg.api || '1.18';
|
|
44
|
-
const tmplJar = resolve(root, '.yeow', 'assets', 'yeow-template-0.1.0.jar');
|
|
45
|
-
const zip = new AdmZip(tmplJar);
|
|
46
|
-
zip.updateFile('plugin.yml', Buffer.from(`name: ${name}\nversion: ${version}\nmain: yeow.template.Bootstrap\napi-version: '${apiVer}'\ndepend:\n - Yeow-Runtime\n`));
|
|
47
48
|
zip.addFile('.yeow/dev.json', readFileSync(resolve(outDir, 'dev.json')));
|
|
48
|
-
|
|
49
|
-
const outJar = resolve(root, 'dist', `${name}-${version}.jar`);
|
|
50
|
-
zip.writeZip(outJar);
|
|
51
|
-
console.log(` ✓ Dev JAR packaged ${outJar}\n`);
|
|
52
|
-
}).catch(e => { console.error(e); process.exit(1); }); else {
|
|
53
|
-
// Production mode: bundle code into JAR
|
|
54
|
-
esbuild.build({
|
|
55
|
-
entryPoints: [resolve(root, entry)],
|
|
56
|
-
outfile: resolve(outDir, 'main.js'),
|
|
57
|
-
bundle: true,
|
|
58
|
-
format: 'iife',
|
|
59
|
-
target: 'es2023',
|
|
60
|
-
platform: 'neutral',
|
|
61
|
-
mainFields: ['module', 'main'],
|
|
62
|
-
conditions: ['import', 'browser'],
|
|
63
|
-
treeShaking: true,
|
|
64
|
-
minify: false,
|
|
65
|
-
}).then(() => {
|
|
66
|
-
const size = statSync(resolve(outDir, 'main.js')).size;
|
|
67
|
-
console.log(` ✓ Bundled (${(size / 1024).toFixed(1)} KB)`);
|
|
68
|
-
|
|
69
|
-
const apiVer = cfg.api || '1.18';
|
|
70
|
-
const tmplJar = resolve(root, '.yeow', 'assets', 'yeow-template-0.1.0.jar');
|
|
71
|
-
const zip = new AdmZip(tmplJar);
|
|
72
|
-
zip.updateFile('plugin.yml', Buffer.from(`name: ${name}\nversion: ${version}\nmain: yeow.template.Bootstrap\napi-version: '${apiVer}'\ndepend:\n - Yeow-Runtime\n`));
|
|
49
|
+
} else {
|
|
73
50
|
zip.addFile('.yeow/main.js', readFileSync(resolve(outDir, 'main.js')));
|
|
74
|
-
zip.addFile('yeow.json', Buffer.from(JSON.stringify(cfg)));
|
|
75
|
-
|
|
76
51
|
const assetsDir = resolve(root, 'assets');
|
|
77
52
|
if (existsSync(assetsDir)) {
|
|
78
53
|
for (const f of readdirSync(assetsDir, { recursive: true })) {
|
|
@@ -83,9 +58,12 @@ if (isDev) {
|
|
|
83
58
|
}
|
|
84
59
|
console.log(' ✓ Assets included');
|
|
85
60
|
}
|
|
61
|
+
}
|
|
86
62
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
63
|
+
zip.addFile('yeow.json', Buffer.from(JSON.stringify(cfg)));
|
|
64
|
+
const outJar = resolve(root, 'dist', `${name}-${version}.jar`);
|
|
65
|
+
zip.writeZip(outJar);
|
|
66
|
+
console.log(` ✓ Packaged ${outJar}\n`);
|
|
91
67
|
}
|
|
68
|
+
|
|
69
|
+
main().catch(e => { console.error(e); process.exit(1); });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, copyFileSync, writeFileSync, readFileSync, createWriteStream, statSync, watch, readdirSync } from 'fs';
|
|
2
|
-
import { resolve, dirname } from 'path';
|
|
2
|
+
import { resolve, dirname, basename } from 'path';
|
|
3
3
|
import { spawn, execSync } from 'child_process';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import https from 'https';
|