@git.zone/tsbundle 2.6.3 → 2.7.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/interfaces/index.d.ts +17 -0
- package/dist_ts/mod_custom/index.d.ts +33 -0
- package/dist_ts/mod_custom/index.js +167 -0
- package/dist_ts/mod_custom/plugins.d.ts +1 -0
- package/dist_ts/mod_custom/plugins.js +2 -0
- package/dist_ts/mod_init/index.d.ts +33 -0
- package/dist_ts/mod_init/index.js +336 -0
- package/dist_ts/mod_init/plugins.d.ts +3 -0
- package/dist_ts/mod_init/plugins.js +4 -0
- package/dist_ts/mod_output/index.d.ts +30 -0
- package/dist_ts/mod_output/index.js +103 -0
- package/dist_ts/mod_output/plugins.d.ts +1 -0
- package/dist_ts/mod_output/plugins.js +2 -0
- package/dist_ts/plugins.d.ts +3 -1
- package/dist_ts/plugins.js +4 -2
- package/dist_ts/tsbundle.cli.js +11 -41
- package/npmextra.json +11 -5
- package/package.json +12 -6
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/interfaces/index.ts +22 -0
- package/ts/mod_custom/index.ts +203 -0
- package/ts/mod_custom/plugins.ts +1 -0
- package/ts/mod_init/index.ts +377 -0
- package/ts/mod_init/plugins.ts +5 -0
- package/ts/mod_output/index.ts +113 -0
- package/ts/mod_output/plugins.ts +1 -0
- package/ts/plugins.ts +4 -0
- package/ts/tsbundle.cli.ts +11 -58
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as interfaces from '../interfaces/index.js';
|
|
2
|
+
export declare class Base64TsOutput {
|
|
3
|
+
private files;
|
|
4
|
+
private cwd;
|
|
5
|
+
constructor(cwd?: string);
|
|
6
|
+
/**
|
|
7
|
+
* Add a file with its content to the output
|
|
8
|
+
*/
|
|
9
|
+
addFile(filePath: string, content: Buffer | string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Add files matching a glob pattern
|
|
12
|
+
*/
|
|
13
|
+
addFilesFromGlob(pattern: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Generate TypeScript file content
|
|
16
|
+
*/
|
|
17
|
+
generateTypeScript(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Write the TypeScript file to disk
|
|
20
|
+
*/
|
|
21
|
+
writeToFile(outputPath: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get all collected files
|
|
24
|
+
*/
|
|
25
|
+
getFiles(): interfaces.IBase64File[];
|
|
26
|
+
/**
|
|
27
|
+
* Clear all collected files
|
|
28
|
+
*/
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import * as paths from '../paths.js';
|
|
3
|
+
import * as interfaces from '../interfaces/index.js';
|
|
4
|
+
export class Base64TsOutput {
|
|
5
|
+
files = [];
|
|
6
|
+
cwd;
|
|
7
|
+
constructor(cwd = paths.cwd) {
|
|
8
|
+
this.cwd = cwd;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Add a file with its content to the output
|
|
12
|
+
*/
|
|
13
|
+
addFile(filePath, content) {
|
|
14
|
+
const contentBuffer = typeof content === 'string' ? Buffer.from(content, 'utf-8') : content;
|
|
15
|
+
const contentBase64 = contentBuffer.toString('base64');
|
|
16
|
+
this.files.push({
|
|
17
|
+
path: filePath,
|
|
18
|
+
contentBase64,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add files matching a glob pattern
|
|
23
|
+
*/
|
|
24
|
+
async addFilesFromGlob(pattern) {
|
|
25
|
+
const absolutePattern = plugins.smartpath.transform.toAbsolute(pattern, this.cwd);
|
|
26
|
+
const patternDir = plugins.path.dirname(absolutePattern);
|
|
27
|
+
const patternBase = plugins.path.basename(absolutePattern);
|
|
28
|
+
// Check if it's a directory pattern or file pattern
|
|
29
|
+
const isGlobPattern = patternBase.includes('*');
|
|
30
|
+
if (isGlobPattern) {
|
|
31
|
+
// Handle glob patterns
|
|
32
|
+
const dirPath = patternDir.replace(/\/\*\*$/, '');
|
|
33
|
+
const dirExists = await plugins.fs.directory(dirPath).exists();
|
|
34
|
+
if (!dirExists) {
|
|
35
|
+
console.log(`Directory does not exist: ${dirPath}`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const isRecursive = pattern.includes('**');
|
|
39
|
+
let entries;
|
|
40
|
+
if (isRecursive) {
|
|
41
|
+
entries = await plugins.fs.directory(dirPath).recursive().list();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
entries = await plugins.fs.directory(dirPath).list();
|
|
45
|
+
}
|
|
46
|
+
// Filter by pattern if needed
|
|
47
|
+
const filePattern = patternBase.replace('*', '.*');
|
|
48
|
+
const regex = new RegExp(filePattern);
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
if (!entry.isDirectory && regex.test(entry.name)) {
|
|
51
|
+
const fullPath = plugins.path.join(dirPath, entry.path);
|
|
52
|
+
const relativePath = plugins.path.relative(this.cwd, fullPath);
|
|
53
|
+
const content = await plugins.fs.file(fullPath).read();
|
|
54
|
+
this.addFile(relativePath, content);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Handle single file path
|
|
60
|
+
const fileExists = await plugins.fs.file(absolutePattern).exists();
|
|
61
|
+
if (!fileExists) {
|
|
62
|
+
console.log(`File does not exist: ${absolutePattern}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const relativePath = plugins.path.relative(this.cwd, absolutePattern);
|
|
66
|
+
const content = await plugins.fs.file(absolutePattern).read();
|
|
67
|
+
this.addFile(relativePath, content);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generate TypeScript file content
|
|
72
|
+
*/
|
|
73
|
+
generateTypeScript() {
|
|
74
|
+
const filesJson = JSON.stringify(this.files, null, 2);
|
|
75
|
+
return `// Auto-generated by tsbundle - do not edit
|
|
76
|
+
export const files: { path: string; contentBase64: string }[] = ${filesJson};
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Write the TypeScript file to disk
|
|
81
|
+
*/
|
|
82
|
+
async writeToFile(outputPath) {
|
|
83
|
+
const absolutePath = plugins.smartpath.transform.toAbsolute(outputPath, this.cwd);
|
|
84
|
+
const outputDir = plugins.path.dirname(absolutePath);
|
|
85
|
+
await plugins.fs.directory(outputDir).create();
|
|
86
|
+
const content = this.generateTypeScript();
|
|
87
|
+
await plugins.fs.file(absolutePath).encoding('utf8').write(content);
|
|
88
|
+
console.log(`Generated base64ts output: ${outputPath}`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get all collected files
|
|
92
|
+
*/
|
|
93
|
+
getFiles() {
|
|
94
|
+
return this.files;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Clear all collected files
|
|
98
|
+
*/
|
|
99
|
+
clear() {
|
|
100
|
+
this.files = [];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2Rfb3V0cHV0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBQ3hDLE9BQU8sS0FBSyxLQUFLLE1BQU0sYUFBYSxDQUFDO0FBQ3JDLE9BQU8sS0FBSyxVQUFVLE1BQU0sd0JBQXdCLENBQUM7QUFFckQsTUFBTSxPQUFPLGNBQWM7SUFDakIsS0FBSyxHQUE2QixFQUFFLENBQUM7SUFDckMsR0FBRyxDQUFTO0lBRXBCLFlBQVksTUFBYyxLQUFLLENBQUMsR0FBRztRQUNqQyx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RUFBRSxDQUFDO0lBQ2xCLENBQUM7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../plugins.js';
|
package/dist_ts/plugins.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
export { path };
|
|
3
|
+
import * as npmextra from '@push.rocks/npmextra';
|
|
3
4
|
import * as smartcli from '@push.rocks/smartcli';
|
|
4
5
|
import * as smartfs from '@push.rocks/smartfs';
|
|
6
|
+
import * as smartinteract from '@push.rocks/smartinteract';
|
|
5
7
|
import * as smartlog from '@push.rocks/smartlog';
|
|
6
8
|
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
|
7
9
|
import * as smartpath from '@push.rocks/smartpath';
|
|
8
10
|
import * as smartpromise from '@push.rocks/smartpromise';
|
|
9
11
|
import * as smartspawn from '@push.rocks/smartspawn';
|
|
10
|
-
export { smartcli, smartfs, smartlog, smartlogDestinationLocal, smartpath, smartpromise, smartspawn, };
|
|
12
|
+
export { npmextra, smartcli, smartfs, smartinteract, smartlog, smartlogDestinationLocal, smartpath, smartpromise, smartspawn, };
|
|
11
13
|
export declare const fs: smartfs.SmartFs;
|
package/dist_ts/plugins.js
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
export { path };
|
|
4
4
|
// pushrocks scope
|
|
5
|
+
import * as npmextra from '@push.rocks/npmextra';
|
|
5
6
|
import * as smartcli from '@push.rocks/smartcli';
|
|
6
7
|
import * as smartfs from '@push.rocks/smartfs';
|
|
8
|
+
import * as smartinteract from '@push.rocks/smartinteract';
|
|
7
9
|
import * as smartlog from '@push.rocks/smartlog';
|
|
8
10
|
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
|
9
11
|
import * as smartpath from '@push.rocks/smartpath';
|
|
10
12
|
import * as smartpromise from '@push.rocks/smartpromise';
|
|
11
13
|
import * as smartspawn from '@push.rocks/smartspawn';
|
|
12
|
-
export { smartcli, smartfs, smartlog, smartlogDestinationLocal, smartpath, smartpromise, smartspawn, };
|
|
14
|
+
export { npmextra, smartcli, smartfs, smartinteract, smartlog, smartlogDestinationLocal, smartpath, smartpromise, smartspawn, };
|
|
13
15
|
// Create a shared SmartFs instance using Node provider
|
|
14
16
|
export const fs = new smartfs.SmartFs(new smartfs.SmartFsProviderNode());
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYztBQUNkLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFDO0FBRTdCLE9BQU8sRUFBRSxJQUFJLEVBQUUsQ0FBQztBQUVoQixrQkFBa0I7QUFDbEIsT0FBTyxLQUFLLFFBQVEsTUFBTSxzQkFBc0IsQ0FBQztBQUNqRCxPQUFPLEtBQUssUUFBUSxNQUFNLHNCQUFzQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxPQUFPLE1BQU0scUJBQXFCLENBQUM7QUFDL0MsT0FBTyxLQUFLLGFBQWEsTUFBTSwyQkFBMkIsQ0FBQztBQUMzRCxPQUFPLEtBQUssUUFBUSxNQUFNLHNCQUFzQixDQUFDO0FBQ2pELE9BQU8sS0FBSyx3QkFBd0IsTUFBTSx3Q0FBd0MsQ0FBQztBQUNuRixPQUFPLEtBQUssU0FBUyxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxZQUFZLE1BQU0sMEJBQTBCLENBQUM7QUFDekQsT0FBTyxLQUFLLFVBQVUsTUFBTSx3QkFBd0IsQ0FBQztBQUVyRCxPQUFPLEVBQ0wsUUFBUSxFQUNSLFFBQVEsRUFDUixPQUFPLEVBQ1AsYUFBYSxFQUNiLFFBQVEsRUFDUix3QkFBd0IsRUFDeEIsU0FBUyxFQUNULFlBQVksRUFDWixVQUFVLEdBQ1gsQ0FBQztBQUVGLHVEQUF1RDtBQUN2RCxNQUFNLENBQUMsTUFBTSxFQUFFLEdBQUcsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksT0FBTyxDQUFDLG1CQUFtQixFQUFFLENBQUMsQ0FBQyJ9
|
package/dist_ts/tsbundle.cli.js
CHANGED
|
@@ -1,50 +1,20 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { logger } from './tsbundle.logging.js';
|
|
5
|
-
import { AssetsHandler } from './mod_assets/index.js';
|
|
2
|
+
import { runCustomBundles } from './mod_custom/index.js';
|
|
3
|
+
import { runInit } from './mod_init/index.js';
|
|
6
4
|
export const runCli = async () => {
|
|
7
5
|
const tsBundleCli = new plugins.smartcli.Smartcli();
|
|
6
|
+
// Default command: run custom bundles from npmextra.json
|
|
8
7
|
tsBundleCli.standardCommand().subscribe(async (argvArg) => {
|
|
9
|
-
|
|
10
|
-
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
|
11
|
-
return;
|
|
8
|
+
await runCustomBundles();
|
|
12
9
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await
|
|
10
|
+
// Explicit custom command (same as default)
|
|
11
|
+
tsBundleCli.addCommand('custom').subscribe(async (argvArg) => {
|
|
12
|
+
await runCustomBundles();
|
|
16
13
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
await tsbundle.build(process.cwd(), './ts/index.ts', './dist_bundle/bundle.js', argvArg);
|
|
21
|
-
});
|
|
22
|
-
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
|
|
23
|
-
const tsbundle = new TsBundle();
|
|
24
|
-
// lets deal with the html
|
|
25
|
-
const htmlHandler = new HtmlHandler();
|
|
26
|
-
await tsbundle.build(process.cwd(), './ts_web/index.ts', './dist_serve/bundle.js', argvArg);
|
|
27
|
-
const htmlDirPath = plugins.path.join(process.cwd(), './html');
|
|
28
|
-
let htmlFiles = [];
|
|
29
|
-
const htmlDirExists = await plugins.fs.directory(htmlDirPath).exists();
|
|
30
|
-
if (htmlDirExists) {
|
|
31
|
-
const entries = await plugins.fs
|
|
32
|
-
.directory(htmlDirPath)
|
|
33
|
-
.filter(/\.html$/)
|
|
34
|
-
.list();
|
|
35
|
-
htmlFiles = entries.map((entry) => plugins.path.basename(entry.path));
|
|
36
|
-
}
|
|
37
|
-
for (const htmlFile of htmlFiles) {
|
|
38
|
-
await htmlHandler.processHtml({
|
|
39
|
-
from: `./html/${htmlFile}`,
|
|
40
|
-
to: `./dist_serve/${htmlFile}`,
|
|
41
|
-
minify: true,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// lets deal with the assets
|
|
45
|
-
const assetsHandler = new AssetsHandler();
|
|
46
|
-
await assetsHandler.processAssets();
|
|
14
|
+
// Interactive init wizard
|
|
15
|
+
tsBundleCli.addCommand('init').subscribe(async (argvArg) => {
|
|
16
|
+
await runInit();
|
|
47
17
|
});
|
|
48
18
|
tsBundleCli.startParse();
|
|
49
19
|
};
|
|
50
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHNidW5kbGUuY2xpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdHNidW5kbGUuY2xpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBQ3hDLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3pELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUU5QyxNQUFNLENBQUMsTUFBTSxNQUFNLEdBQUcsS0FBSyxJQUFJLEVBQUU7SUFDL0IsTUFBTSxXQUFXLEdBQUcsSUFBSSxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFDO0lBRXBELHlEQUF5RDtJQUN6RCxXQUFXLENBQUMsZUFBZSxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsRUFBRTtRQUN4RCxNQUFNLGdCQUFnQixFQUFFLENBQUM7SUFDM0IsQ0FBQyxDQUFDLENBQUM7SUFFSCw0Q0FBNEM7SUFDNUMsV0FBVyxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsQ0FBQyxTQUFTLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxFQUFFO1FBQzNELE1BQU0sZ0JBQWdCLEVBQUUsQ0FBQztJQUMzQixDQUFDLENBQUMsQ0FBQztJQUVILDBCQUEwQjtJQUMxQixXQUFXLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxDQUFDLFNBQVMsQ0FBQyxLQUFLLEVBQUUsT0FBTyxFQUFFLEVBQUU7UUFDekQsTUFBTSxPQUFPLEVBQUUsQ0FBQztJQUNsQixDQUFDLENBQUMsQ0FBQztJQUVILFdBQVcsQ0FBQyxVQUFVLEVBQUUsQ0FBQztBQUMzQixDQUFDLENBQUMifQ==
|
package/npmextra.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"@git.zone/cli": {
|
|
3
3
|
"projectType": "npm",
|
|
4
4
|
"module": {
|
|
5
5
|
"githost": "gitlab.com",
|
|
@@ -9,10 +9,16 @@
|
|
|
9
9
|
"npmPackagename": "@git.zone/tsbundle",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"projectDomain": "git.zone"
|
|
12
|
+
},
|
|
13
|
+
"release": {
|
|
14
|
+
"registries": [
|
|
15
|
+
"https://verdaccio.lossless.one",
|
|
16
|
+
"https://registry.npmjs.org"
|
|
17
|
+
],
|
|
18
|
+
"accessLevel": "public"
|
|
12
19
|
}
|
|
13
20
|
},
|
|
14
|
-
"
|
|
15
|
-
"npmGlobalTools": []
|
|
16
|
-
"npmAccessLevel": "public"
|
|
21
|
+
"@ship.zone/szci": {
|
|
22
|
+
"npmGlobalTools": []
|
|
17
23
|
}
|
|
18
|
-
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git.zone/tsbundle",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"author": "Lossless GmbH",
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "npm run build && (tstest test/ --verbose)",
|
|
13
|
+
"build": "(tsbuild --web --allowimplicitany)",
|
|
14
|
+
"buildDocs": "tsdoc"
|
|
15
|
+
},
|
|
11
16
|
"bin": {
|
|
12
17
|
"tsbundle": "cli.js"
|
|
13
18
|
},
|
|
@@ -19,7 +24,9 @@
|
|
|
19
24
|
},
|
|
20
25
|
"dependencies": {
|
|
21
26
|
"@push.rocks/early": "^4.0.4",
|
|
27
|
+
"@push.rocks/npmextra": "^5.1.3",
|
|
22
28
|
"@push.rocks/smartcli": "^4.0.19",
|
|
29
|
+
"@push.rocks/smartinteract": "^2.0.16",
|
|
23
30
|
"@push.rocks/smartdelay": "^3.0.5",
|
|
24
31
|
"@push.rocks/smartfs": "^1.1.3",
|
|
25
32
|
"@push.rocks/smartlog": "^3.1.8",
|
|
@@ -49,6 +56,7 @@
|
|
|
49
56
|
"browserslist": [
|
|
50
57
|
"last 1 chrome versions"
|
|
51
58
|
],
|
|
59
|
+
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
|
|
52
60
|
"repository": {
|
|
53
61
|
"type": "git",
|
|
54
62
|
"url": "https://gitlab.com/gitzone/tsbundle.git"
|
|
@@ -57,9 +65,7 @@
|
|
|
57
65
|
"url": "https://gitlab.com/gitzone/tsbundle/issues"
|
|
58
66
|
},
|
|
59
67
|
"homepage": "https://gitlab.com/gitzone/tsbundle#readme",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"build": "(tsbuild --web --allowimplicitany)",
|
|
63
|
-
"buildDocs": "tsdoc"
|
|
68
|
+
"pnpm": {
|
|
69
|
+
"overrides": {}
|
|
64
70
|
}
|
|
65
|
-
}
|
|
71
|
+
}
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/interfaces/index.ts
CHANGED
|
@@ -12,3 +12,25 @@ export interface IEnvTransportOptions {
|
|
|
12
12
|
mode: 'test' | 'production';
|
|
13
13
|
argv: ICliOptions;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
// Custom bundle configuration types
|
|
17
|
+
export type TOutputMode = 'bundle' | 'base64ts';
|
|
18
|
+
export type TBundler = 'esbuild' | 'rolldown' | 'rspack';
|
|
19
|
+
|
|
20
|
+
export interface IBundleConfig {
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
outputMode?: TOutputMode;
|
|
24
|
+
bundler?: TBundler;
|
|
25
|
+
production?: boolean;
|
|
26
|
+
includeFiles?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ITsbundleConfig {
|
|
30
|
+
bundles: IBundleConfig[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IBase64File {
|
|
34
|
+
path: string;
|
|
35
|
+
contentBase64: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import * as paths from '../paths.js';
|
|
3
|
+
import * as interfaces from '../interfaces/index.js';
|
|
4
|
+
import { TsBundle } from '../tsbundle.class.tsbundle.js';
|
|
5
|
+
import { HtmlHandler } from '../mod_html/index.js';
|
|
6
|
+
import { Base64TsOutput } from '../mod_output/index.js';
|
|
7
|
+
|
|
8
|
+
const TEMP_DIR = '.nogit/tsbundle-temp';
|
|
9
|
+
|
|
10
|
+
export class CustomBundleHandler {
|
|
11
|
+
private cwd: string;
|
|
12
|
+
private config: interfaces.ITsbundleConfig;
|
|
13
|
+
|
|
14
|
+
constructor(cwd: string = paths.cwd) {
|
|
15
|
+
this.cwd = cwd;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Load configuration from npmextra.json
|
|
20
|
+
*/
|
|
21
|
+
public async loadConfig(): Promise<boolean> {
|
|
22
|
+
const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
|
|
23
|
+
this.config = npmextraInstance.dataFor<interfaces.ITsbundleConfig>('@git.zone/tsbundle', {
|
|
24
|
+
bundles: [],
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (!this.config.bundles || this.config.bundles.length === 0) {
|
|
28
|
+
console.log('No bundle configuration found.');
|
|
29
|
+
console.log('Run `tsbundle init` to create one.');
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(`Found ${this.config.bundles.length} bundle configuration(s)`);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Process all configured bundles
|
|
39
|
+
*/
|
|
40
|
+
public async processAllBundles(): Promise<void> {
|
|
41
|
+
for (let i = 0; i < this.config.bundles.length; i++) {
|
|
42
|
+
const bundleConfig = this.config.bundles[i];
|
|
43
|
+
console.log(`\nProcessing bundle ${i + 1}/${this.config.bundles.length}: ${bundleConfig.from} -> ${bundleConfig.to}`);
|
|
44
|
+
await this.processSingleBundle(bundleConfig);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Process a single bundle configuration
|
|
50
|
+
*/
|
|
51
|
+
private async processSingleBundle(bundleConfig: interfaces.IBundleConfig): Promise<void> {
|
|
52
|
+
const outputMode = bundleConfig.outputMode || 'bundle';
|
|
53
|
+
const bundler = bundleConfig.bundler || 'esbuild';
|
|
54
|
+
|
|
55
|
+
// Determine temp output path
|
|
56
|
+
const tempDir = plugins.path.join(this.cwd, TEMP_DIR);
|
|
57
|
+
const tempBundlePath = plugins.path.join(tempDir, `bundle-${Date.now()}.js`);
|
|
58
|
+
|
|
59
|
+
// Ensure temp directory exists
|
|
60
|
+
await plugins.fs.directory(tempDir).create();
|
|
61
|
+
|
|
62
|
+
// Build the bundle to temp location
|
|
63
|
+
const tsbundle = new TsBundle();
|
|
64
|
+
await tsbundle.build(
|
|
65
|
+
this.cwd,
|
|
66
|
+
bundleConfig.from,
|
|
67
|
+
tempBundlePath,
|
|
68
|
+
{
|
|
69
|
+
bundler,
|
|
70
|
+
production: bundleConfig.production || false,
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (outputMode === 'base64ts') {
|
|
75
|
+
await this.handleBase64TsOutput(bundleConfig, tempBundlePath);
|
|
76
|
+
} else {
|
|
77
|
+
await this.handleBundleOutput(bundleConfig, tempBundlePath);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Clean up temp file
|
|
81
|
+
const tempFileExists = await plugins.fs.file(tempBundlePath).exists();
|
|
82
|
+
if (tempFileExists) {
|
|
83
|
+
await plugins.fs.file(tempBundlePath).delete();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Handle base64ts output mode
|
|
89
|
+
*/
|
|
90
|
+
private async handleBase64TsOutput(
|
|
91
|
+
bundleConfig: interfaces.IBundleConfig,
|
|
92
|
+
tempBundlePath: string
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
const base64Output = new Base64TsOutput(this.cwd);
|
|
95
|
+
|
|
96
|
+
// Add the bundle itself
|
|
97
|
+
const bundleContent = await plugins.fs.file(tempBundlePath).read();
|
|
98
|
+
base64Output.addFile('bundle.js', bundleContent);
|
|
99
|
+
|
|
100
|
+
// Add included files
|
|
101
|
+
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
|
|
102
|
+
for (const pattern of bundleConfig.includeFiles) {
|
|
103
|
+
await base64Output.addFilesFromGlob(pattern);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Write the TypeScript output
|
|
108
|
+
await base64Output.writeToFile(bundleConfig.to);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Handle standard bundle output mode
|
|
113
|
+
*/
|
|
114
|
+
private async handleBundleOutput(
|
|
115
|
+
bundleConfig: interfaces.IBundleConfig,
|
|
116
|
+
tempBundlePath: string
|
|
117
|
+
): Promise<void> {
|
|
118
|
+
// Move bundle to final destination
|
|
119
|
+
const toPath = plugins.smartpath.transform.toAbsolute(bundleConfig.to, this.cwd) as string;
|
|
120
|
+
const toDir = plugins.path.dirname(toPath);
|
|
121
|
+
await plugins.fs.directory(toDir).create();
|
|
122
|
+
|
|
123
|
+
const bundleContent = await plugins.fs.file(tempBundlePath).read();
|
|
124
|
+
await plugins.fs.file(toPath).write(bundleContent);
|
|
125
|
+
console.log(`Bundle written to: ${bundleConfig.to}`);
|
|
126
|
+
|
|
127
|
+
// Process included files (copy them)
|
|
128
|
+
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
|
|
129
|
+
const htmlHandler = new HtmlHandler();
|
|
130
|
+
const outputDir = plugins.path.dirname(toPath);
|
|
131
|
+
|
|
132
|
+
for (const pattern of bundleConfig.includeFiles) {
|
|
133
|
+
await this.copyIncludedFiles(pattern, outputDir);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Copy files matching a pattern to the output directory
|
|
140
|
+
*/
|
|
141
|
+
private async copyIncludedFiles(pattern: string, outputDir: string): Promise<void> {
|
|
142
|
+
const absolutePattern = plugins.smartpath.transform.toAbsolute(pattern, this.cwd) as string;
|
|
143
|
+
const patternDir = plugins.path.dirname(absolutePattern);
|
|
144
|
+
const patternBase = plugins.path.basename(absolutePattern);
|
|
145
|
+
const isGlobPattern = patternBase.includes('*');
|
|
146
|
+
|
|
147
|
+
if (isGlobPattern) {
|
|
148
|
+
const dirPath = patternDir.replace(/\/\*\*$/, '');
|
|
149
|
+
const dirExists = await plugins.fs.directory(dirPath).exists();
|
|
150
|
+
if (!dirExists) {
|
|
151
|
+
console.log(`Directory does not exist: ${dirPath}`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const isRecursive = pattern.includes('**');
|
|
156
|
+
let entries;
|
|
157
|
+
if (isRecursive) {
|
|
158
|
+
entries = await plugins.fs.directory(dirPath).recursive().list();
|
|
159
|
+
} else {
|
|
160
|
+
entries = await plugins.fs.directory(dirPath).list();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const filePattern = patternBase.replace('*', '.*');
|
|
164
|
+
const regex = new RegExp(filePattern);
|
|
165
|
+
|
|
166
|
+
for (const entry of entries) {
|
|
167
|
+
if (!entry.isDirectory && regex.test(entry.name)) {
|
|
168
|
+
const fullPath = plugins.path.join(dirPath, entry.path);
|
|
169
|
+
const relativePath = plugins.path.relative(this.cwd, fullPath);
|
|
170
|
+
const destPath = plugins.path.join(outputDir, plugins.path.basename(entry.path));
|
|
171
|
+
await plugins.fs.directory(plugins.path.dirname(destPath)).create();
|
|
172
|
+
await plugins.fs.file(fullPath).copy(destPath);
|
|
173
|
+
console.log(`Copied: ${relativePath} -> ${destPath}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
const fileExists = await plugins.fs.file(absolutePattern).exists();
|
|
178
|
+
if (!fileExists) {
|
|
179
|
+
console.log(`File does not exist: ${absolutePattern}`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const fileName = plugins.path.basename(absolutePattern);
|
|
183
|
+
const destPath = plugins.path.join(outputDir, fileName);
|
|
184
|
+
await plugins.fs.file(absolutePattern).copy(destPath);
|
|
185
|
+
console.log(`Copied: ${pattern} -> ${destPath}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Run the custom bundle command
|
|
192
|
+
*/
|
|
193
|
+
export async function runCustomBundles(): Promise<void> {
|
|
194
|
+
const handler = new CustomBundleHandler();
|
|
195
|
+
const hasConfig = await handler.loadConfig();
|
|
196
|
+
|
|
197
|
+
if (!hasConfig) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
await handler.processAllBundles();
|
|
202
|
+
console.log('\nCustom bundle processing complete!');
|
|
203
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../plugins.js';
|