@syncbridge/syncbuild 0.7.2 → 0.9.0
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/bin/spm.mjs +3 -0
- package/builder/extract-exports.js +0 -1
- package/bundle-package.js +8 -3
- package/cli.js +77 -0
- package/constants.js +1 -1
- package/package.json +3 -3
- package/types.d.ts +4 -5
- package/bin/syncbuild.mjs +0 -3
- package/syncbuild-cli.js +0 -32
- /package/{syncbuild-cli.d.ts → cli.d.ts} +0 -0
package/bin/spm.mjs
ADDED
|
@@ -15,7 +15,6 @@ export async function extractExports(context) {
|
|
|
15
15
|
metadata = await normalizeComponentMetadata(metadata);
|
|
16
16
|
else
|
|
17
17
|
metadata = await normalizeProcessorMetadata(metadata);
|
|
18
|
-
delete metadata.id;
|
|
19
18
|
const metadataDir = path.join(context.tmpDir, 'metadata');
|
|
20
19
|
fs.mkdirSync(metadataDir, { recursive: true });
|
|
21
20
|
fs.writeFileSync(path.join(metadataDir, `${k}.json`), JSON.stringify(metadata, undefined, 2));
|
package/bundle-package.js
CHANGED
|
@@ -20,13 +20,18 @@ export async function bundlePackage(config) {
|
|
|
20
20
|
types: './' +
|
|
21
21
|
path.join(`./typings`, context.entryPoint.replace(/\.js$/, '.d.ts')),
|
|
22
22
|
}, null, 2));
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
if (config.pack && fs.existsSync(context.tmpDir)) {
|
|
24
|
+
const zipFileName = path.join(context.outDir, context.outFile + '.zip');
|
|
25
25
|
const zip = new AdmZip();
|
|
26
26
|
zip.addLocalFolder(context.tmpDir);
|
|
27
27
|
zip.writeZip(zipFileName);
|
|
28
|
+
context.logger?.(`Generated bundle package: ${colors.magenta(path.basename(zipFileName))}`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const resultDir = path.join(context.outDir, context.outFile);
|
|
32
|
+
fs.renameSync(context.tmpDir, resultDir);
|
|
33
|
+
context.logger?.(`Generated bundle directory: ${colors.magenta(resultDir)}`);
|
|
28
34
|
}
|
|
29
|
-
context.logger?.(`Generated ${colors.magenta(path.basename(zipFileName))}`);
|
|
30
35
|
}
|
|
31
36
|
finally {
|
|
32
37
|
if (fs.existsSync(context.tmpDir))
|
package/cli.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as console from 'node:console';
|
|
2
|
+
import * as process from 'node:process';
|
|
3
|
+
import { SbError } from '@syncbridge/common';
|
|
4
|
+
import colors from 'ansi-colors';
|
|
5
|
+
import { program } from 'commander';
|
|
6
|
+
import { bundlePackage } from './bundle-package.js';
|
|
7
|
+
import { version } from './constants.js';
|
|
8
|
+
function addBuildOptions(cmd, options) {
|
|
9
|
+
cmd.option('-p, --package-dir <directory>', 'Directory of package');
|
|
10
|
+
if (!options?.noOut)
|
|
11
|
+
cmd.option('-o, --out <directory>', 'Output directory', 'dist');
|
|
12
|
+
cmd
|
|
13
|
+
.option('--temp-dir <directory>', 'Directory for temp files')
|
|
14
|
+
.option('--tsconfig <fileName>', 'tsconfig file name', 'tsconfig.json')
|
|
15
|
+
.option('--minify', 'Minify the output bundle', false)
|
|
16
|
+
.option('--minify-whitespace', 'Minify whitespace in the output bundle', false)
|
|
17
|
+
.option('--minify-identifiers', 'Minify identifiers in the output bundle', false)
|
|
18
|
+
.option('--minify-syntax', 'Minify syntax in the output bundle', false)
|
|
19
|
+
.option('--keep-names', 'If set true, keeps names of variables and functions in the output bundle', true);
|
|
20
|
+
return cmd;
|
|
21
|
+
}
|
|
22
|
+
function addPackOptions(cmd, options) {
|
|
23
|
+
addBuildOptions(cmd, options);
|
|
24
|
+
}
|
|
25
|
+
program
|
|
26
|
+
.version(version)
|
|
27
|
+
.description('SyncBridge® extension package builder and bundler tool');
|
|
28
|
+
const buildCommand = program.command('build').action(async (options) => {
|
|
29
|
+
if (options.color === false)
|
|
30
|
+
colors.enabled = false;
|
|
31
|
+
console.log(colors.yellow('**** SyncBuild v' + version + ' ****'));
|
|
32
|
+
bundlePackage({
|
|
33
|
+
pack: false,
|
|
34
|
+
packageDir: options.packageDir,
|
|
35
|
+
outDir: options.out,
|
|
36
|
+
tsconfig: options.tsconfig,
|
|
37
|
+
tempDir: options.tempDir,
|
|
38
|
+
minify: options.minify,
|
|
39
|
+
minifyWhitespace: options.minifyWhitespace,
|
|
40
|
+
minifyIdentifiers: options.minifyIdentifiers,
|
|
41
|
+
minifySyntax: options.minifySyntax,
|
|
42
|
+
keepNames: options.keepNames,
|
|
43
|
+
logger: console.log,
|
|
44
|
+
}).catch(e => {
|
|
45
|
+
if (e instanceof SbError)
|
|
46
|
+
console.error(colors.red(e.message));
|
|
47
|
+
else
|
|
48
|
+
console.error(e);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
addBuildOptions(buildCommand);
|
|
52
|
+
const packCommand = program.command('pack').action(async (options) => {
|
|
53
|
+
if (options.color === false)
|
|
54
|
+
colors.enabled = false;
|
|
55
|
+
console.log(colors.yellow('**** SyncBuild v' + version + ' ****'));
|
|
56
|
+
bundlePackage({
|
|
57
|
+
pack: true,
|
|
58
|
+
packageDir: options.packageDir,
|
|
59
|
+
outDir: options.out,
|
|
60
|
+
tsconfig: options.tsconfig,
|
|
61
|
+
tempDir: options.tempDir,
|
|
62
|
+
minify: options.minify,
|
|
63
|
+
minifyWhitespace: options.minifyWhitespace,
|
|
64
|
+
minifyIdentifiers: options.minifyIdentifiers,
|
|
65
|
+
minifySyntax: options.minifySyntax,
|
|
66
|
+
keepNames: options.keepNames,
|
|
67
|
+
logger: console.log,
|
|
68
|
+
}).catch(e => {
|
|
69
|
+
if (e instanceof SbError)
|
|
70
|
+
console.error(colors.red(e.message));
|
|
71
|
+
else
|
|
72
|
+
console.error(e);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
addPackOptions(packCommand);
|
|
76
|
+
program.option('--no-color', 'Disables colors in logs messages', false);
|
|
77
|
+
program.parse(process.argv);
|
package/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncbridge/syncbuild",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "SyncBridge Extension Package Builder",
|
|
5
5
|
"author": "Panates Inc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"typescript": "^6.0.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@syncbridge/common": "^0.
|
|
23
|
+
"@syncbridge/common": "^0.9.0"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"module": "./index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
35
|
"bin": {
|
|
36
|
-
"
|
|
36
|
+
"spm": "bin/spm.mjs"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=20.0"
|
package/types.d.ts
CHANGED
|
@@ -19,24 +19,24 @@ export interface PackageBuildConfig {
|
|
|
19
19
|
* List of external dependencies to exclude from the build.
|
|
20
20
|
*/
|
|
21
21
|
external?: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a zip file of the package
|
|
24
|
+
*/
|
|
25
|
+
pack?: boolean;
|
|
22
26
|
/**
|
|
23
27
|
* Minify the output bundle.
|
|
24
|
-
* Default: true
|
|
25
28
|
*/
|
|
26
29
|
minify?: boolean;
|
|
27
30
|
/**
|
|
28
31
|
* Minify whitespace in the output bundle.
|
|
29
|
-
* Default: true
|
|
30
32
|
*/
|
|
31
33
|
minifyWhitespace?: boolean;
|
|
32
34
|
/**
|
|
33
35
|
* Minify identifiers in the output bundle.
|
|
34
|
-
* Default: true
|
|
35
36
|
*/
|
|
36
37
|
minifyIdentifiers?: boolean;
|
|
37
38
|
/**
|
|
38
39
|
* Minify syntax in the output bundle.
|
|
39
|
-
* Default: true
|
|
40
40
|
*/
|
|
41
41
|
minifySyntax?: boolean;
|
|
42
42
|
/**
|
|
@@ -45,7 +45,6 @@ export interface PackageBuildConfig {
|
|
|
45
45
|
banner?: string;
|
|
46
46
|
/**
|
|
47
47
|
* Keep names of variables and functions in the output bundle.
|
|
48
|
-
* Default: false
|
|
49
48
|
*/
|
|
50
49
|
keepNames?: boolean;
|
|
51
50
|
/**
|
package/bin/syncbuild.mjs
DELETED
package/syncbuild-cli.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as console from 'node:console';
|
|
2
|
-
import * as process from 'node:process';
|
|
3
|
-
import { SbError } from '@syncbridge/common';
|
|
4
|
-
import colors from 'ansi-colors';
|
|
5
|
-
import { program } from 'commander';
|
|
6
|
-
import { bundlePackage } from './bundle-package.js';
|
|
7
|
-
import { version } from './constants.js';
|
|
8
|
-
program
|
|
9
|
-
.version(version)
|
|
10
|
-
.option('-o, --out <directory>', 'Output directory', 'dist')
|
|
11
|
-
.option('-p, --package-dir <directory>', 'Directory of package')
|
|
12
|
-
.option('--temp-dir <directory>', 'Directory for temp files')
|
|
13
|
-
.option('--tsconfig <fileName>', 'tsconfig file name', 'tsconfig.json')
|
|
14
|
-
.option('--no-color', 'Disables colors in logs messages')
|
|
15
|
-
.action(async (options) => {
|
|
16
|
-
if (!options.color)
|
|
17
|
-
colors.enabled = false;
|
|
18
|
-
console.log(colors.yellow('**** SyncBuild v' + version + ' ****'));
|
|
19
|
-
bundlePackage({
|
|
20
|
-
packageDir: options.packageDir,
|
|
21
|
-
outDir: options.out,
|
|
22
|
-
tsconfig: options.tsconfig,
|
|
23
|
-
tempDir: options.tempDir,
|
|
24
|
-
logger: console.log,
|
|
25
|
-
}).catch(e => {
|
|
26
|
-
if (e instanceof SbError)
|
|
27
|
-
console.error(colors.red(e.message));
|
|
28
|
-
else
|
|
29
|
-
console.error(e);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
program.parse(process.argv);
|
|
File without changes
|