Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad5e0c1afc | |||
| cb5d827420 | |||
| 5a5f6c6944 | |||
| 54ac7e7188 | |||
| 5f0507b2c7 | |||
| ecfd7600e2 | |||
| 9cf173293d | |||
| 3a53fffe3d | |||
| 8f129527d9 | |||
| 5d9052018e | |||
| 12c5655251 | |||
| 801cab9001 | |||
| 971cb685a7 | |||
| 0900d1a605 | |||
| f0fb99c8ae | |||
| 6d88adcd1e | |||
| 4349571112 | |||
| b3080023ab | |||
| 8b6ae043a2 | |||
| 54f84ba114 | |||
| e40d6477fd |
67
changelog.md
67
changelog.md
@@ -1,5 +1,72 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-03-24 - 2.9.3 - fix(config)
|
||||||
|
migrate configuration loading and init output from npmextra.json to smartconfig.json
|
||||||
|
|
||||||
|
- replace @push.rocks/npmextra with @push.rocks/smartconfig
|
||||||
|
- load project configuration via Smartconfig in the custom module
|
||||||
|
- update init wizard to read from and write to smartconfig.json and adjust user-facing messages accordingly
|
||||||
|
|
||||||
|
## 2026-03-11 - 2.9.2 - fix(mod_esbuild)
|
||||||
|
preserve function and class names in esbuild output by enabling keepNames in both dev and prod configs
|
||||||
|
|
||||||
|
- Added keepNames: true to esbuild options in ts/mod_esbuild/index.child.ts for the non-minified/dev build
|
||||||
|
- Added keepNames: true to esbuild options in ts/mod_esbuild/index.child.ts for the minified/production build to improve stack traces, debugging, and runtime reflection
|
||||||
|
|
||||||
|
## 2026-03-05 - 2.9.1 - fix(mod_custom)
|
||||||
|
use absolute smartfs entry.path instead of joining with dirPath when building fullPath
|
||||||
|
|
||||||
|
- entry.path is already absolute (from smartfs); avoid joining it with dirPath which produced incorrect paths
|
||||||
|
- Fixes file copy path construction so plugins.fs.file(fullPath).copy(destPath) uses the correct source path
|
||||||
|
|
||||||
|
## 2026-02-24 - 2.9.0 - feat(exports)
|
||||||
|
expose mod_custom, mod_output and interfaces from entry; make processSingleBundle public
|
||||||
|
|
||||||
|
- Exported ./mod_custom, ./mod_output and ./interfaces from ts/index.ts to expose these modules in the public API.
|
||||||
|
- Changed processSingleBundle in ts/mod_custom/index.ts from private to public to allow programmatic invocation.
|
||||||
|
- Non-breaking API expansion; recommend a minor version bump.
|
||||||
|
|
||||||
|
## 2026-02-24 - 2.8.4 - fix()
|
||||||
|
no changes — empty diff, nothing to commit
|
||||||
|
|
||||||
|
- Diff contained no modifications; no release required
|
||||||
|
|
||||||
|
## 2026-01-23 - 2.8.3 - fix(mod_output)
|
||||||
|
use pattern base dir when computing relative paths for files to serve
|
||||||
|
|
||||||
|
- Compute relativePath using the pattern base directory (dirPath) instead of this.cwd to ensure correct web-serving paths for absolute or relative entry.path values.
|
||||||
|
- File changed: ts/mod_output/index.ts — replaces plugins.path.relative(this.cwd, fullPath) with plugins.path.relative(dirPath, fullPath) and adds clarifying comment.
|
||||||
|
|
||||||
|
## 2026-01-23 - 2.8.2 - fix(mod_output)
|
||||||
|
resolve absolute and relative entry.path correctly when adding files
|
||||||
|
|
||||||
|
- Add check for plugins.path.isAbsolute(entry.path) to avoid incorrectly joining absolute paths with dirPath
|
||||||
|
- Use entry.path directly when it's absolute, otherwise join with dirPath
|
||||||
|
- Ensures correct relativePath calculation and prevents invalid file reads
|
||||||
|
|
||||||
|
## 2026-01-12 - 2.8.1 - fix(readme)
|
||||||
|
document maxLineLength option for base64ts output and add example and tip
|
||||||
|
|
||||||
|
- Add documented `maxLineLength` configuration option (number, default 0 = unlimited) for `base64ts` output.
|
||||||
|
- Include example config showing `maxLineLength: 200`.
|
||||||
|
- Add a tip recommending setting `maxLineLength` to split long base64 strings when using AI tools with line-length limits.
|
||||||
|
|
||||||
|
## 2026-01-12 - 2.8.0 - feat(tsbundle)
|
||||||
|
add configurable maxLineLength for base64ts output and improve build/error handling in child builds
|
||||||
|
|
||||||
|
- Add optional maxLineLength?: number to IBundleConfig to control max characters per line for base64ts output (0 or undefined = unlimited).
|
||||||
|
- Support splitting base64 strings when maxLineLength is specified; generateTypeScript(maxLineLength?) and writeToFile(outputPath, maxLineLength?) updated to accept and apply this setting.
|
||||||
|
- Pass bundleConfig.maxLineLength through in mod_custom so base64ts output respects bundle configuration.
|
||||||
|
- Wrap TsBundle.build in mod_custom with try/catch to log failures and skip output handling when build fails.
|
||||||
|
- tsbundle.class now rejects the bundle promise when the child process exits with a non-zero status.
|
||||||
|
- mod_esbuild child process now awaits builds, exits with appropriate success/failure codes, and formats esbuild errors for clearer console output.
|
||||||
|
|
||||||
|
## 2026-01-12 - 2.7.4 - fix(deps)
|
||||||
|
bump @push.rocks/smartcli dependency to ^4.0.20
|
||||||
|
|
||||||
|
- @push.rocks/smartcli: ^4.0.19 → ^4.0.20
|
||||||
|
- Patch-level dependency update with no breaking changes
|
||||||
|
|
||||||
## 2026-01-12 - 2.7.3 - fix(mod_output)
|
## 2026-01-12 - 2.7.3 - fix(mod_output)
|
||||||
wrap long base64 file contents and format generated TypeScript output to avoid extremely long lines
|
wrap long base64 file contents and format generated TypeScript output to avoid extremely long lines
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tsbundle",
|
"name": "@git.zone/tsbundle",
|
||||||
"version": "2.7.3",
|
"version": "2.9.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects",
|
"description": "a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -24,11 +24,11 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/early": "^4.0.4",
|
"@push.rocks/early": "^4.0.4",
|
||||||
"@push.rocks/npmextra": "^5.1.3",
|
"@push.rocks/smartconfig": "^6.0.0",
|
||||||
"@push.rocks/smartcli": "^4.0.19",
|
"@push.rocks/smartcli": "^4.0.20",
|
||||||
"@push.rocks/smartinteract": "^2.0.16",
|
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartfs": "^1.1.3",
|
"@push.rocks/smartfs": "^1.1.3",
|
||||||
|
"@push.rocks/smartinteract": "^2.0.16",
|
||||||
"@push.rocks/smartlog": "^3.1.8",
|
"@push.rocks/smartlog": "^3.1.8",
|
||||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||||
"@push.rocks/smartpath": "^6.0.0",
|
"@push.rocks/smartpath": "^6.0.0",
|
||||||
|
|||||||
62
pnpm-lock.yaml
generated
62
pnpm-lock.yaml
generated
@@ -11,12 +11,12 @@ importers:
|
|||||||
'@push.rocks/early':
|
'@push.rocks/early':
|
||||||
specifier: ^4.0.4
|
specifier: ^4.0.4
|
||||||
version: 4.0.4
|
version: 4.0.4
|
||||||
'@push.rocks/npmextra':
|
|
||||||
specifier: ^5.1.3
|
|
||||||
version: 5.3.3
|
|
||||||
'@push.rocks/smartcli':
|
'@push.rocks/smartcli':
|
||||||
specifier: ^4.0.19
|
specifier: ^4.0.20
|
||||||
version: 4.0.19
|
version: 4.0.20
|
||||||
|
'@push.rocks/smartconfig':
|
||||||
|
specifier: ^6.0.0
|
||||||
|
version: 6.0.0
|
||||||
'@push.rocks/smartdelay':
|
'@push.rocks/smartdelay':
|
||||||
specifier: ^3.0.5
|
specifier: ^3.0.5
|
||||||
version: 3.0.5
|
version: 3.0.5
|
||||||
@@ -886,9 +886,6 @@ packages:
|
|||||||
'@push.rocks/mongodump@1.1.0':
|
'@push.rocks/mongodump@1.1.0':
|
||||||
resolution: {integrity: sha512-kW0ZUGyf1e4nwloVwBQjNId+MzgTcNS834C+RxH21i1NqyOubbpWZtJtPP+K+s35nSJRyCTy3ICfBMdDBTAm2w==}
|
resolution: {integrity: sha512-kW0ZUGyf1e4nwloVwBQjNId+MzgTcNS834C+RxH21i1NqyOubbpWZtJtPP+K+s35nSJRyCTy3ICfBMdDBTAm2w==}
|
||||||
|
|
||||||
'@push.rocks/npmextra@5.3.3':
|
|
||||||
resolution: {integrity: sha512-snLpSHwaQ5OXlZzF1KX/FY71W5LwajjBzor82Vue0smjEPnSeUPY5/JcVdMwtdprdJe13pc/EQQuIiL/zw4/yg==}
|
|
||||||
|
|
||||||
'@push.rocks/qenv@6.1.3':
|
'@push.rocks/qenv@6.1.3':
|
||||||
resolution: {integrity: sha512-+z2hsAU/7CIgpYLFqvda8cn9rUBMHqLdQLjsFfRn5jPoD7dJ5rFlpkbhfM4Ws8mHMniwWaxGKo+q/YBhtzRBLg==}
|
resolution: {integrity: sha512-+z2hsAU/7CIgpYLFqvda8cn9rUBMHqLdQLjsFfRn5jPoD7dJ5rFlpkbhfM4Ws8mHMniwWaxGKo+q/YBhtzRBLg==}
|
||||||
|
|
||||||
@@ -913,12 +910,15 @@ packages:
|
|||||||
'@push.rocks/smartchok@1.1.1':
|
'@push.rocks/smartchok@1.1.1':
|
||||||
resolution: {integrity: sha512-WmNigGmn1muBJMANVuJb4F8x3TzgYrnn6YZm6ixTsG+0WFbYevivEwp+J4S7npobLHsR7ynf+Ky8LxRYmsL50A==}
|
resolution: {integrity: sha512-WmNigGmn1muBJMANVuJb4F8x3TzgYrnn6YZm6ixTsG+0WFbYevivEwp+J4S7npobLHsR7ynf+Ky8LxRYmsL50A==}
|
||||||
|
|
||||||
'@push.rocks/smartcli@4.0.19':
|
'@push.rocks/smartcli@4.0.20':
|
||||||
resolution: {integrity: sha512-s1jZSgDZWi/az26AY4TJ2HPuG1qZzGC5R9fKWaECLmwnSpk6y9JXL5dnJAUohcdu50kdXCWEcRmLfYxOt81vEA==}
|
resolution: {integrity: sha512-gCo4ItvsPj8WoVAJw/6vkuoGA5FtIoACux2ktcCeH0nrFe7/xGR6waJ1aZcYAi7QN4gi52TlsgwuKz7BzXqhmQ==}
|
||||||
|
|
||||||
'@push.rocks/smartclickhouse@2.0.17':
|
'@push.rocks/smartclickhouse@2.0.17':
|
||||||
resolution: {integrity: sha512-IYO8Obor/Ruam2KQ2B/+5uQ+rL0exU5KZoSgOc3jkkrfjn+zZenN2xoV8lVqavAtxZVfG7MfxFrcv6I7I9ZMmA==}
|
resolution: {integrity: sha512-IYO8Obor/Ruam2KQ2B/+5uQ+rL0exU5KZoSgOc3jkkrfjn+zZenN2xoV8lVqavAtxZVfG7MfxFrcv6I7I9ZMmA==}
|
||||||
|
|
||||||
|
'@push.rocks/smartconfig@6.0.0':
|
||||||
|
resolution: {integrity: sha512-ohXwJdbDXV2budErnZKWBOz01YkjP6gJsZ7QM9+6Wsh+r7O1CVT3JpV+mD8xJWy5tZRHI+3B9L8z0+WkIDtKzw==}
|
||||||
|
|
||||||
'@push.rocks/smartcrypto@2.0.4':
|
'@push.rocks/smartcrypto@2.0.4':
|
||||||
resolution: {integrity: sha512-1+/5bsjyataf5uUkUNnnVXGRAt+gHVk1KDzozjTqgqJxHvQk1d9fVDohL6CxUhUucTPtu5VR5xNBiV8YCDuGyw==}
|
resolution: {integrity: sha512-1+/5bsjyataf5uUkUNnnVXGRAt+gHVk1KDzozjTqgqJxHvQk1d9fVDohL6CxUhUucTPtu5VR5xNBiV8YCDuGyw==}
|
||||||
|
|
||||||
@@ -4853,7 +4853,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@git.zone/tspublish': 1.10.3
|
'@git.zone/tspublish': 1.10.3
|
||||||
'@push.rocks/early': 4.0.4
|
'@push.rocks/early': 4.0.4
|
||||||
'@push.rocks/smartcli': 4.0.19
|
'@push.rocks/smartcli': 4.0.20
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartfile': 11.2.7
|
'@push.rocks/smartfile': 11.2.7
|
||||||
'@push.rocks/smartlog': 3.1.10
|
'@push.rocks/smartlog': 3.1.10
|
||||||
@@ -4872,7 +4872,7 @@ snapshots:
|
|||||||
'@git.zone/tsbundle@2.5.2':
|
'@git.zone/tsbundle@2.5.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/early': 4.0.4
|
'@push.rocks/early': 4.0.4
|
||||||
'@push.rocks/smartcli': 4.0.19
|
'@push.rocks/smartcli': 4.0.20
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartfile': 11.2.7
|
'@push.rocks/smartfile': 11.2.7
|
||||||
'@push.rocks/smartlog': 3.1.10
|
'@push.rocks/smartlog': 3.1.10
|
||||||
@@ -4893,7 +4893,7 @@ snapshots:
|
|||||||
'@git.zone/tspublish@1.10.3':
|
'@git.zone/tspublish@1.10.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/consolecolor': 2.0.3
|
'@push.rocks/consolecolor': 2.0.3
|
||||||
'@push.rocks/smartcli': 4.0.19
|
'@push.rocks/smartcli': 4.0.20
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartfile': 11.2.7
|
'@push.rocks/smartfile': 11.2.7
|
||||||
'@push.rocks/smartlog': 3.1.10
|
'@push.rocks/smartlog': 3.1.10
|
||||||
@@ -5319,23 +5319,6 @@ snapshots:
|
|||||||
- snappy
|
- snappy
|
||||||
- socks
|
- socks
|
||||||
|
|
||||||
'@push.rocks/npmextra@5.3.3':
|
|
||||||
dependencies:
|
|
||||||
'@push.rocks/qenv': 6.1.3
|
|
||||||
'@push.rocks/smartfile': 11.2.7
|
|
||||||
'@push.rocks/smartjson': 5.2.0
|
|
||||||
'@push.rocks/smartlog': 3.1.10
|
|
||||||
'@push.rocks/smartpath': 6.0.0
|
|
||||||
'@push.rocks/smartpromise': 4.2.3
|
|
||||||
'@push.rocks/smartrx': 3.0.10
|
|
||||||
'@push.rocks/taskbuffer': 3.4.0
|
|
||||||
'@tsclass/tsclass': 9.3.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@nuxt/kit'
|
|
||||||
- react
|
|
||||||
- supports-color
|
|
||||||
- vue
|
|
||||||
|
|
||||||
'@push.rocks/qenv@6.1.3':
|
'@push.rocks/qenv@6.1.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@api.global/typedrequest': 3.1.10
|
'@api.global/typedrequest': 3.1.10
|
||||||
@@ -5428,7 +5411,7 @@ snapshots:
|
|||||||
chokidar: 4.0.3
|
chokidar: 4.0.3
|
||||||
picomatch: 4.0.3
|
picomatch: 4.0.3
|
||||||
|
|
||||||
'@push.rocks/smartcli@4.0.19':
|
'@push.rocks/smartcli@4.0.20':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.2.2
|
'@push.rocks/lik': 6.2.2
|
||||||
'@push.rocks/smartlog': 3.1.10
|
'@push.rocks/smartlog': 3.1.10
|
||||||
@@ -5446,6 +5429,23 @@ snapshots:
|
|||||||
'@push.rocks/smarturl': 3.1.0
|
'@push.rocks/smarturl': 3.1.0
|
||||||
'@push.rocks/webrequest': 3.0.37
|
'@push.rocks/webrequest': 3.0.37
|
||||||
|
|
||||||
|
'@push.rocks/smartconfig@6.0.0':
|
||||||
|
dependencies:
|
||||||
|
'@push.rocks/qenv': 6.1.3
|
||||||
|
'@push.rocks/smartfile': 11.2.7
|
||||||
|
'@push.rocks/smartjson': 5.2.0
|
||||||
|
'@push.rocks/smartlog': 3.1.10
|
||||||
|
'@push.rocks/smartpath': 6.0.0
|
||||||
|
'@push.rocks/smartpromise': 4.2.3
|
||||||
|
'@push.rocks/smartrx': 3.0.10
|
||||||
|
'@push.rocks/taskbuffer': 3.4.0
|
||||||
|
'@tsclass/tsclass': 9.3.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@nuxt/kit'
|
||||||
|
- react
|
||||||
|
- supports-color
|
||||||
|
- vue
|
||||||
|
|
||||||
'@push.rocks/smartcrypto@2.0.4':
|
'@push.rocks/smartcrypto@2.0.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/smartpromise': 4.2.3
|
'@push.rocks/smartpromise': 4.2.3
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ tsbundle uses `npmextra.json` for configuration. Here's an example:
|
|||||||
| `bundler` | `"esbuild"` \| `"rolldown"` \| `"rspack"` | `"esbuild"` | Which bundler to use |
|
| `bundler` | `"esbuild"` \| `"rolldown"` \| `"rspack"` | `"esbuild"` | Which bundler to use |
|
||||||
| `production` | `boolean` | `false` | Enable minification |
|
| `production` | `boolean` | `false` | Enable minification |
|
||||||
| `includeFiles` | `string[]` | `[]` | Glob patterns for additional files (HTML, assets) |
|
| `includeFiles` | `string[]` | `[]` | Glob patterns for additional files (HTML, assets) |
|
||||||
|
| `maxLineLength` | `number` | `0` (unlimited) | For `base64ts` mode: max chars per line in output |
|
||||||
|
|
||||||
### Output Modes
|
### Output Modes
|
||||||
|
|
||||||
@@ -108,6 +109,8 @@ export const files: { path: string; contentBase64: string }[] = [
|
|||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Tip:** If you're working with AI tools that have line length limitations, set `maxLineLength` (e.g., `200`) to split long base64 strings across multiple lines.
|
||||||
|
|
||||||
## Available Bundlers 🔧
|
## Available Bundlers 🔧
|
||||||
|
|
||||||
tsbundle supports three modern bundlers:
|
tsbundle supports three modern bundlers:
|
||||||
@@ -241,7 +244,8 @@ Config:
|
|||||||
"outputMode": "base64ts",
|
"outputMode": "base64ts",
|
||||||
"bundler": "esbuild",
|
"bundler": "esbuild",
|
||||||
"production": true,
|
"production": true,
|
||||||
"includeFiles": ["./html/index.html"]
|
"includeFiles": ["./html/index.html"],
|
||||||
|
"maxLineLength": 200
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsbundle',
|
name: '@git.zone/tsbundle',
|
||||||
version: '2.7.3',
|
version: '2.9.3',
|
||||||
description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
|
description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,4 +11,7 @@ early.stop();
|
|||||||
export * from './tsbundle.class.tsbundle.js';
|
export * from './tsbundle.class.tsbundle.js';
|
||||||
export * from './mod_assets/index.js';
|
export * from './mod_assets/index.js';
|
||||||
export * from './mod_html/index.js';
|
export * from './mod_html/index.js';
|
||||||
|
export * from './mod_custom/index.js';
|
||||||
|
export * from './mod_output/index.js';
|
||||||
|
export * from './interfaces/index.js';
|
||||||
export { runCli };
|
export { runCli };
|
||||||
|
|||||||
@@ -17,13 +17,16 @@ export interface IEnvTransportOptions {
|
|||||||
export type TOutputMode = 'bundle' | 'base64ts';
|
export type TOutputMode = 'bundle' | 'base64ts';
|
||||||
export type TBundler = 'esbuild' | 'rolldown' | 'rspack';
|
export type TBundler = 'esbuild' | 'rolldown' | 'rspack';
|
||||||
|
|
||||||
|
export type TIncludeFile = string | { from: string; to: string };
|
||||||
|
|
||||||
export interface IBundleConfig {
|
export interface IBundleConfig {
|
||||||
from: string;
|
from: string;
|
||||||
to: string;
|
to: string;
|
||||||
outputMode?: TOutputMode;
|
outputMode?: TOutputMode;
|
||||||
bundler?: TBundler;
|
bundler?: TBundler;
|
||||||
production?: boolean;
|
production?: boolean;
|
||||||
includeFiles?: string[];
|
includeFiles?: TIncludeFile[];
|
||||||
|
maxLineLength?: number; // For base64ts output: max chars per line. 0 or undefined = unlimited (default)
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITsbundleConfig {
|
export interface ITsbundleConfig {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class CustomBundleHandler {
|
|||||||
* Load configuration from npmextra.json
|
* Load configuration from npmextra.json
|
||||||
*/
|
*/
|
||||||
public async loadConfig(): Promise<boolean> {
|
public async loadConfig(): Promise<boolean> {
|
||||||
const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
|
const npmextraInstance = new plugins.npmextra.Smartconfig(this.cwd);
|
||||||
this.config = npmextraInstance.dataFor<interfaces.ITsbundleConfig>('@git.zone/tsbundle', {
|
this.config = npmextraInstance.dataFor<interfaces.ITsbundleConfig>('@git.zone/tsbundle', {
|
||||||
bundles: [],
|
bundles: [],
|
||||||
});
|
});
|
||||||
@@ -48,7 +48,7 @@ export class CustomBundleHandler {
|
|||||||
/**
|
/**
|
||||||
* Process a single bundle configuration
|
* Process a single bundle configuration
|
||||||
*/
|
*/
|
||||||
private async processSingleBundle(bundleConfig: interfaces.IBundleConfig): Promise<void> {
|
public async processSingleBundle(bundleConfig: interfaces.IBundleConfig): Promise<void> {
|
||||||
const outputMode = bundleConfig.outputMode || 'bundle';
|
const outputMode = bundleConfig.outputMode || 'bundle';
|
||||||
const bundler = bundleConfig.bundler || 'esbuild';
|
const bundler = bundleConfig.bundler || 'esbuild';
|
||||||
|
|
||||||
@@ -61,15 +61,21 @@ export class CustomBundleHandler {
|
|||||||
|
|
||||||
// Build the bundle to temp location
|
// Build the bundle to temp location
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
await tsbundle.build(
|
try {
|
||||||
this.cwd,
|
await tsbundle.build(
|
||||||
bundleConfig.from,
|
this.cwd,
|
||||||
tempBundlePath,
|
bundleConfig.from,
|
||||||
{
|
tempBundlePath,
|
||||||
bundler,
|
{
|
||||||
production: bundleConfig.production || false,
|
bundler,
|
||||||
}
|
production: bundleConfig.production || false,
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error(`\n\x1b[31m❌ Bundle failed: ${bundleConfig.from} -> ${bundleConfig.to}\x1b[0m`);
|
||||||
|
// Don't re-print error details - they were already shown by the child process
|
||||||
|
return; // Skip output handling since build failed
|
||||||
|
}
|
||||||
|
|
||||||
if (outputMode === 'base64ts') {
|
if (outputMode === 'base64ts') {
|
||||||
await this.handleBase64TsOutput(bundleConfig, tempBundlePath);
|
await this.handleBase64TsOutput(bundleConfig, tempBundlePath);
|
||||||
@@ -99,13 +105,17 @@ export class CustomBundleHandler {
|
|||||||
|
|
||||||
// Add included files
|
// Add included files
|
||||||
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
|
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
|
||||||
for (const pattern of bundleConfig.includeFiles) {
|
for (const entry of bundleConfig.includeFiles) {
|
||||||
await base64Output.addFilesFromGlob(pattern);
|
if (typeof entry === 'string') {
|
||||||
|
await base64Output.addFilesFromGlob(entry);
|
||||||
|
} else {
|
||||||
|
await base64Output.addFileWithServePath(entry.from, entry.to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the TypeScript output
|
// Write the TypeScript output
|
||||||
await base64Output.writeToFile(bundleConfig.to);
|
await base64Output.writeToFile(bundleConfig.to, bundleConfig.maxLineLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,7 +139,8 @@ export class CustomBundleHandler {
|
|||||||
const htmlHandler = new HtmlHandler();
|
const htmlHandler = new HtmlHandler();
|
||||||
const outputDir = plugins.path.dirname(toPath);
|
const outputDir = plugins.path.dirname(toPath);
|
||||||
|
|
||||||
for (const pattern of bundleConfig.includeFiles) {
|
for (const entry of bundleConfig.includeFiles) {
|
||||||
|
const pattern = typeof entry === 'string' ? entry : entry.from;
|
||||||
await this.copyIncludedFiles(pattern, outputDir);
|
await this.copyIncludedFiles(pattern, outputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,7 +176,8 @@ export class CustomBundleHandler {
|
|||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (!entry.isDirectory && regex.test(entry.name)) {
|
if (!entry.isDirectory && regex.test(entry.name)) {
|
||||||
const fullPath = plugins.path.join(dirPath, entry.path);
|
// entry.path is already absolute from smartfs
|
||||||
|
const fullPath = entry.path;
|
||||||
const relativePath = plugins.path.relative(this.cwd, fullPath);
|
const relativePath = plugins.path.relative(this.cwd, fullPath);
|
||||||
const destPath = plugins.path.join(outputDir, plugins.path.basename(entry.path));
|
const destPath = plugins.path.join(outputDir, plugins.path.basename(entry.path));
|
||||||
await plugins.fs.directory(plugins.path.dirname(destPath)).create();
|
await plugins.fs.directory(plugins.path.dirname(destPath)).create();
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export class TsBundleProcess {
|
|||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
target: 'es2022',
|
target: 'es2022',
|
||||||
|
keepNames: true,
|
||||||
entryNames: plugins.path.parse(toArg).name,
|
entryNames: plugins.path.parse(toArg).name,
|
||||||
outdir: plugins.path.parse(toArg).dir,
|
outdir: plugins.path.parse(toArg).dir,
|
||||||
splitting: false,
|
splitting: false,
|
||||||
@@ -67,6 +68,7 @@ export class TsBundleProcess {
|
|||||||
format: 'esm',
|
format: 'esm',
|
||||||
target: 'es2022',
|
target: 'es2022',
|
||||||
minify: true,
|
minify: true,
|
||||||
|
keepNames: true,
|
||||||
entryNames: plugins.path.parse(toArg).name,
|
entryNames: plugins.path.parse(toArg).name,
|
||||||
outdir: plugins.path.parse(toArg).dir,
|
outdir: plugins.path.parse(toArg).dir,
|
||||||
tsconfig: paths.tsconfigPath,
|
tsconfig: paths.tsconfigPath,
|
||||||
@@ -79,41 +81,65 @@ export class TsBundleProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
console.log('running spawned compilation process');
|
try {
|
||||||
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
|
console.log('running spawned compilation process');
|
||||||
process.env.transportOptions,
|
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
|
||||||
);
|
process.env.transportOptions,
|
||||||
console.log('=======> ESBUILD');
|
|
||||||
console.log(transportOptions);
|
|
||||||
process.chdir(transportOptions.cwd);
|
|
||||||
console.log(`switched to ${process.cwd()}`);
|
|
||||||
const tsbundleProcessInstance = new TsBundleProcess();
|
|
||||||
if (transportOptions.mode === 'test') {
|
|
||||||
console.log('building for test:');
|
|
||||||
tsbundleProcessInstance.buildTest(
|
|
||||||
plugins.smartpath.transform.makeAbsolute(
|
|
||||||
transportOptions.from,
|
|
||||||
process.cwd(),
|
|
||||||
),
|
|
||||||
plugins.smartpath.transform.makeAbsolute(
|
|
||||||
transportOptions.to,
|
|
||||||
process.cwd(),
|
|
||||||
),
|
|
||||||
transportOptions.argv,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.log('building for production:');
|
|
||||||
tsbundleProcessInstance.buildProduction(
|
|
||||||
plugins.smartpath.transform.makeAbsolute(
|
|
||||||
transportOptions.from,
|
|
||||||
process.cwd(),
|
|
||||||
),
|
|
||||||
plugins.smartpath.transform.makeAbsolute(
|
|
||||||
transportOptions.to,
|
|
||||||
process.cwd(),
|
|
||||||
),
|
|
||||||
transportOptions.argv,
|
|
||||||
);
|
);
|
||||||
|
console.log('=======> ESBUILD');
|
||||||
|
console.log(transportOptions);
|
||||||
|
process.chdir(transportOptions.cwd);
|
||||||
|
console.log(`switched to ${process.cwd()}`);
|
||||||
|
const tsbundleProcessInstance = new TsBundleProcess();
|
||||||
|
if (transportOptions.mode === 'test') {
|
||||||
|
console.log('building for test:');
|
||||||
|
await tsbundleProcessInstance.buildTest(
|
||||||
|
plugins.smartpath.transform.makeAbsolute(
|
||||||
|
transportOptions.from,
|
||||||
|
process.cwd(),
|
||||||
|
),
|
||||||
|
plugins.smartpath.transform.makeAbsolute(
|
||||||
|
transportOptions.to,
|
||||||
|
process.cwd(),
|
||||||
|
),
|
||||||
|
transportOptions.argv,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log('building for production:');
|
||||||
|
await tsbundleProcessInstance.buildProduction(
|
||||||
|
plugins.smartpath.transform.makeAbsolute(
|
||||||
|
transportOptions.from,
|
||||||
|
process.cwd(),
|
||||||
|
),
|
||||||
|
plugins.smartpath.transform.makeAbsolute(
|
||||||
|
transportOptions.to,
|
||||||
|
process.cwd(),
|
||||||
|
),
|
||||||
|
transportOptions.argv,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('\n\x1b[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m');
|
||||||
|
console.error('\x1b[31m❌ BUILD FAILED\x1b[0m');
|
||||||
|
console.error('\x1b[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
|
||||||
|
|
||||||
|
if (error.errors && Array.isArray(error.errors)) {
|
||||||
|
// esbuild errors - format them nicely
|
||||||
|
console.error(`Found ${error.errors.length} error(s):\n`);
|
||||||
|
for (const err of error.errors) {
|
||||||
|
const file = err.location?.file || 'unknown';
|
||||||
|
const line = err.location?.line || '?';
|
||||||
|
const column = err.location?.column || '?';
|
||||||
|
console.error(` \x1b[36m${file}\x1b[0m:\x1b[33m${line}\x1b[0m:\x1b[33m${column}\x1b[0m`);
|
||||||
|
console.error(` ${err.text}\n`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error(error.message || error);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error('\x1b[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,20 +36,20 @@ const PRESETS: Record<string, { description: string; config: interfaces.IBundleC
|
|||||||
|
|
||||||
export class InitHandler {
|
export class InitHandler {
|
||||||
private cwd: string;
|
private cwd: string;
|
||||||
private npmextraPath: string;
|
private smartconfigPath: string;
|
||||||
|
|
||||||
constructor(cwd: string = paths.cwd) {
|
constructor(cwd: string = paths.cwd) {
|
||||||
this.cwd = cwd;
|
this.cwd = cwd;
|
||||||
this.npmextraPath = plugins.path.join(this.cwd, 'npmextra.json');
|
this.smartconfigPath = plugins.path.join(this.cwd, 'smartconfig.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load existing npmextra.json or create empty config
|
* Load existing npmextra.json or create empty config
|
||||||
*/
|
*/
|
||||||
private async loadExistingConfig(): Promise<any> {
|
private async loadExistingConfig(): Promise<any> {
|
||||||
const fileExists = await plugins.fs.file(this.npmextraPath).exists();
|
const fileExists = await plugins.fs.file(this.smartconfigPath).exists();
|
||||||
if (fileExists) {
|
if (fileExists) {
|
||||||
const content = (await plugins.fs.file(this.npmextraPath).encoding('utf8').read()) as string;
|
const content = (await plugins.fs.file(this.smartconfigPath).encoding('utf8').read()) as string;
|
||||||
try {
|
try {
|
||||||
return JSON.parse(content);
|
return JSON.parse(content);
|
||||||
} catch {
|
} catch {
|
||||||
@@ -64,8 +64,8 @@ export class InitHandler {
|
|||||||
*/
|
*/
|
||||||
private async saveConfig(config: any): Promise<void> {
|
private async saveConfig(config: any): Promise<void> {
|
||||||
const content = JSON.stringify(config, null, 2);
|
const content = JSON.stringify(config, null, 2);
|
||||||
await plugins.fs.file(this.npmextraPath).encoding('utf8').write(content);
|
await plugins.fs.file(this.smartconfigPath).encoding('utf8').write(content);
|
||||||
console.log(`\n✅ Configuration saved to npmextra.json`);
|
console.log(`\n✅ Configuration saved to smartconfig.json`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,15 +73,15 @@ export class InitHandler {
|
|||||||
*/
|
*/
|
||||||
public async runWizard(): Promise<void> {
|
public async runWizard(): Promise<void> {
|
||||||
console.log('\n🚀 tsbundle configuration wizard\n');
|
console.log('\n🚀 tsbundle configuration wizard\n');
|
||||||
console.log('This wizard will help you configure bundle settings in npmextra.json.\n');
|
console.log('This wizard will help you configure bundle settings in smartconfig.json.\n');
|
||||||
|
|
||||||
const npmextraJson = await this.loadExistingConfig();
|
const smartconfigJson = await this.loadExistingConfig();
|
||||||
|
|
||||||
if (!npmextraJson['@git.zone/tsbundle']) {
|
if (!smartconfigJson['@git.zone/tsbundle']) {
|
||||||
npmextraJson['@git.zone/tsbundle'] = { bundles: [] };
|
smartconfigJson['@git.zone/tsbundle'] = { bundles: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingBundles = npmextraJson['@git.zone/tsbundle'].bundles || [];
|
const existingBundles = smartconfigJson['@git.zone/tsbundle'].bundles || [];
|
||||||
|
|
||||||
if (existingBundles.length > 0) {
|
if (existingBundles.length > 0) {
|
||||||
console.log(`Found ${existingBundles.length} existing bundle configuration(s):\n`);
|
console.log(`Found ${existingBundles.length} existing bundle configuration(s):\n`);
|
||||||
@@ -95,7 +95,7 @@ export class InitHandler {
|
|||||||
while (addMore) {
|
while (addMore) {
|
||||||
const bundle = await this.configureSingleBundle();
|
const bundle = await this.configureSingleBundle();
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
npmextraJson['@git.zone/tsbundle'].bundles.push(bundle);
|
smartconfigJson['@git.zone/tsbundle'].bundles.push(bundle);
|
||||||
console.log(`\n✅ Bundle configuration added!`);
|
console.log(`\n✅ Bundle configuration added!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,10 +112,10 @@ export class InitHandler {
|
|||||||
addMore = answers.getAnswerFor('addAnother');
|
addMore = answers.getAnswerFor('addAnother');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.saveConfig(npmextraJson);
|
await this.saveConfig(smartconfigJson);
|
||||||
|
|
||||||
console.log('\n📋 Final configuration:\n');
|
console.log('\n📋 Final configuration:\n');
|
||||||
const bundles = npmextraJson['@git.zone/tsbundle'].bundles;
|
const bundles = smartconfigJson['@git.zone/tsbundle'].bundles;
|
||||||
bundles.forEach((bundle: interfaces.IBundleConfig, i: number) => {
|
bundles.forEach((bundle: interfaces.IBundleConfig, i: number) => {
|
||||||
console.log(` Bundle ${i + 1}:`);
|
console.log(` Bundle ${i + 1}:`);
|
||||||
console.log(` From: ${bundle.from}`);
|
console.log(` From: ${bundle.from}`);
|
||||||
@@ -123,7 +123,8 @@ export class InitHandler {
|
|||||||
console.log(` Mode: ${bundle.outputMode || 'bundle'}`);
|
console.log(` Mode: ${bundle.outputMode || 'bundle'}`);
|
||||||
console.log(` Bundler: ${bundle.bundler || 'esbuild'}`);
|
console.log(` Bundler: ${bundle.bundler || 'esbuild'}`);
|
||||||
if (bundle.includeFiles && bundle.includeFiles.length > 0) {
|
if (bundle.includeFiles && bundle.includeFiles.length > 0) {
|
||||||
console.log(` Include: ${bundle.includeFiles.join(', ')}`);
|
const display = bundle.includeFiles.map(f => typeof f === 'string' ? f : `${f.from} -> ${f.to}`);
|
||||||
|
console.log(` Include: ${display.join(', ')}`);
|
||||||
}
|
}
|
||||||
console.log('');
|
console.log('');
|
||||||
});
|
});
|
||||||
@@ -168,7 +169,8 @@ export class InitHandler {
|
|||||||
console.log(` Mode: ${preset.config.outputMode}`);
|
console.log(` Mode: ${preset.config.outputMode}`);
|
||||||
console.log(` Bundler: ${preset.config.bundler}`);
|
console.log(` Bundler: ${preset.config.bundler}`);
|
||||||
if (preset.config.includeFiles && preset.config.includeFiles.length > 0) {
|
if (preset.config.includeFiles && preset.config.includeFiles.length > 0) {
|
||||||
console.log(` Include: ${preset.config.includeFiles.join(', ')}`);
|
const display = preset.config.includeFiles.map(f => typeof f === 'string' ? f : `${f.from} -> ${f.to}`);
|
||||||
|
console.log(` Include: ${display.join(', ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmInteract = new plugins.smartinteract.SmartInteract();
|
const confirmInteract = new plugins.smartinteract.SmartInteract();
|
||||||
@@ -293,14 +295,14 @@ export class InitHandler {
|
|||||||
/**
|
/**
|
||||||
* Configure files to include
|
* Configure files to include
|
||||||
*/
|
*/
|
||||||
private async configureIncludeFiles(prefill?: string[]): Promise<string[]> {
|
private async configureIncludeFiles(prefill?: interfaces.TIncludeFile[]): Promise<interfaces.TIncludeFile[]> {
|
||||||
const includeFiles: string[] = [];
|
const includeFiles: interfaces.TIncludeFile[] = [];
|
||||||
let addMore = true;
|
let addMore = true;
|
||||||
|
|
||||||
// If we have prefilled values, show them first
|
// If we have prefilled values, show them first
|
||||||
if (prefill && prefill.length > 0) {
|
if (prefill && prefill.length > 0) {
|
||||||
console.log('\nPre-configured include patterns:');
|
console.log('\nPre-configured include patterns:');
|
||||||
prefill.forEach((p) => console.log(` - ${p}`));
|
prefill.forEach((p) => console.log(` - ${typeof p === 'string' ? p : `${p.from} -> ${p.to}`}`));
|
||||||
|
|
||||||
const keepInteract = new plugins.smartinteract.SmartInteract();
|
const keepInteract = new plugins.smartinteract.SmartInteract();
|
||||||
keepInteract.addQuestions([
|
keepInteract.addQuestions([
|
||||||
|
|||||||
@@ -22,6 +22,20 @@ export class Base64TsOutput {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a file with a custom serve path
|
||||||
|
*/
|
||||||
|
public async addFileWithServePath(fromPath: string, servePath: string): Promise<void> {
|
||||||
|
const absolutePath = plugins.smartpath.transform.toAbsolute(fromPath, this.cwd) as string;
|
||||||
|
const fileExists = await plugins.fs.file(absolutePath).exists();
|
||||||
|
if (!fileExists) {
|
||||||
|
console.log(`File does not exist: ${absolutePath}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const content = await plugins.fs.file(absolutePath).read();
|
||||||
|
this.addFile(servePath, content);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add files matching a glob pattern
|
* Add files matching a glob pattern
|
||||||
*/
|
*/
|
||||||
@@ -56,8 +70,12 @@ export class Base64TsOutput {
|
|||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (!entry.isDirectory && regex.test(entry.name)) {
|
if (!entry.isDirectory && regex.test(entry.name)) {
|
||||||
const fullPath = plugins.path.join(dirPath, entry.path);
|
// entry.path may be absolute or relative - handle both cases
|
||||||
const relativePath = plugins.path.relative(this.cwd, fullPath);
|
const fullPath = plugins.path.isAbsolute(entry.path)
|
||||||
|
? entry.path
|
||||||
|
: plugins.path.join(dirPath, entry.path);
|
||||||
|
// Use path relative to pattern's base dir (not cwd) for web serving
|
||||||
|
const relativePath = plugins.path.relative(dirPath, fullPath);
|
||||||
const content = await plugins.fs.file(fullPath).read();
|
const content = await plugins.fs.file(fullPath).read();
|
||||||
this.addFile(relativePath, content);
|
this.addFile(relativePath, content);
|
||||||
}
|
}
|
||||||
@@ -77,18 +95,26 @@ export class Base64TsOutput {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate TypeScript file content
|
* Generate TypeScript file content
|
||||||
|
* @param maxLineLength - Max chars per line for base64 strings. 0 or undefined = unlimited (default)
|
||||||
*/
|
*/
|
||||||
public generateTypeScript(): string {
|
public generateTypeScript(maxLineLength?: number): string {
|
||||||
const MAX_LINE_LENGTH = 200;
|
// Default behavior: no line splitting (unlimited)
|
||||||
|
if (!maxLineLength || maxLineLength <= 0) {
|
||||||
|
const filesJson = JSON.stringify(this.files, null, 2);
|
||||||
|
return `// Auto-generated by tsbundle - do not edit
|
||||||
|
export const files: { path: string; contentBase64: string }[] = ${filesJson};
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split base64 strings into chunks when maxLineLength is specified
|
||||||
const formatBase64 = (base64: string): string => {
|
const formatBase64 = (base64: string): string => {
|
||||||
if (base64.length <= MAX_LINE_LENGTH) {
|
if (base64.length <= maxLineLength) {
|
||||||
return `"${base64}"`;
|
return `"${base64}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunks: string[] = [];
|
const chunks: string[] = [];
|
||||||
for (let i = 0; i < base64.length; i += MAX_LINE_LENGTH) {
|
for (let i = 0; i < base64.length; i += maxLineLength) {
|
||||||
chunks.push(base64.slice(i, i + MAX_LINE_LENGTH));
|
chunks.push(base64.slice(i, i + maxLineLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
return `"" +\n "${chunks.join('" +\n "')}"`;
|
return `"" +\n "${chunks.join('" +\n "')}"`;
|
||||||
@@ -110,12 +136,14 @@ ${filesFormatted}
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the TypeScript file to disk
|
* Write the TypeScript file to disk
|
||||||
|
* @param outputPath - Output file path
|
||||||
|
* @param maxLineLength - Max chars per line for base64 strings. 0 or undefined = unlimited (default)
|
||||||
*/
|
*/
|
||||||
public async writeToFile(outputPath: string): Promise<void> {
|
public async writeToFile(outputPath: string, maxLineLength?: number): Promise<void> {
|
||||||
const absolutePath = plugins.smartpath.transform.toAbsolute(outputPath, this.cwd) as string;
|
const absolutePath = plugins.smartpath.transform.toAbsolute(outputPath, this.cwd) as string;
|
||||||
const outputDir = plugins.path.dirname(absolutePath);
|
const outputDir = plugins.path.dirname(absolutePath);
|
||||||
await plugins.fs.directory(outputDir).create();
|
await plugins.fs.directory(outputDir).create();
|
||||||
const content = this.generateTypeScript();
|
const content = this.generateTypeScript(maxLineLength);
|
||||||
await plugins.fs.file(absolutePath).encoding('utf8').write(content);
|
await plugins.fs.file(absolutePath).encoding('utf8').write(content);
|
||||||
console.log(`Generated base64ts output: ${outputPath}`);
|
console.log(`Generated base64ts output: ${outputPath}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import * as path from 'path';
|
|||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as npmextra from '@push.rocks/npmextra';
|
import * as npmextra from '@push.rocks/smartconfig';
|
||||||
import * as smartcli from '@push.rocks/smartcli';
|
import * as smartcli from '@push.rocks/smartcli';
|
||||||
import * as smartfs from '@push.rocks/smartfs';
|
import * as smartfs from '@push.rocks/smartfs';
|
||||||
import * as smartinteract from '@push.rocks/smartinteract';
|
import * as smartinteract from '@push.rocks/smartinteract';
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ export class TsBundle {
|
|||||||
);
|
);
|
||||||
const childProcess = await threadsimple.start();
|
const childProcess = await threadsimple.start();
|
||||||
childProcess.on('exit', (status) => {
|
childProcess.on('exit', (status) => {
|
||||||
done.resolve();
|
if (status !== 0) {
|
||||||
|
done.reject(new Error(`Bundle build failed with exit code ${status}`));
|
||||||
|
} else {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
await done.promise;
|
await done.promise;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user