@git.zone/tsbundle 2.0.9
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/assets/tsconfig.json +11 -0
- package/cli.js +4 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/index.d.ts +5 -0
- package/dist_ts/index.js +12 -0
- package/dist_ts/interfaces/index.d.ts +13 -0
- package/dist_ts/interfaces/index.js +2 -0
- package/dist_ts/mod_esbuild/index.child.d.ts +11 -0
- package/dist_ts/mod_esbuild/index.child.js +62 -0
- package/dist_ts/mod_esbuild/plugins.d.ts +3 -0
- package/dist_ts/mod_esbuild/plugins.js +4 -0
- package/dist_ts/mod_html/index.d.ts +10 -0
- package/dist_ts/mod_html/index.js +43 -0
- package/dist_ts/mod_html/plugins.d.ts +3 -0
- package/dist_ts/mod_html/plugins.js +4 -0
- package/dist_ts/mod_parcel/index.child.d.ts +11 -0
- package/dist_ts/mod_parcel/index.child.js +42 -0
- package/dist_ts/mod_parcel/plugins.d.ts +3 -0
- package/dist_ts/mod_parcel/plugins.js +4 -0
- package/dist_ts/mod_rollup/htmlhandler.d.ts +7 -0
- package/dist_ts/mod_rollup/htmlhandler.js +37 -0
- package/dist_ts/mod_rollup/index.child.d.ts +18 -0
- package/dist_ts/mod_rollup/index.child.js +128 -0
- package/dist_ts/mod_rollup/plugins.d.ts +10 -0
- package/dist_ts/mod_rollup/plugins.js +12 -0
- package/dist_ts/paths.d.ts +6 -0
- package/dist_ts/paths.js +8 -0
- package/dist_ts/plugins.d.ts +10 -0
- package/dist_ts/plugins.js +13 -0
- package/dist_ts/tsbundle.class.tsbundle.d.ts +4 -0
- package/dist_ts/tsbundle.class.tsbundle.js +36 -0
- package/dist_ts/tsbundle.class.tsbundleprocess.d.ts +18 -0
- package/dist_ts/tsbundle.class.tsbundleprocess.js +135 -0
- package/dist_ts/tsbundle.cli.d.ts +1 -0
- package/dist_ts/tsbundle.cli.js +36 -0
- package/dist_ts/tsbundle.htmlhandler.d.ts +7 -0
- package/dist_ts/tsbundle.htmlhandler.js +37 -0
- package/dist_ts/tsbundle.logging.d.ts +2 -0
- package/dist_ts/tsbundle.logging.js +14 -0
- package/dist_ts/tsbundle.paths.d.ts +5 -0
- package/dist_ts/tsbundle.paths.js +7 -0
- package/dist_ts/tsbundle.plugins.d.ts +21 -0
- package/dist_ts/tsbundle.plugins.js +25 -0
- package/license +19 -0
- package/npmextra.json +18 -0
- package/package.json +54 -0
- package/readme.md +78 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/index.ts +13 -0
- package/ts/interfaces/index.ts +14 -0
- package/ts/mod_esbuild/index.child.ts +82 -0
- package/ts/mod_esbuild/plugins.ts +7 -0
- package/ts/mod_html/index.ts +47 -0
- package/ts/mod_html/plugins.ts +7 -0
- package/ts/paths.ts +11 -0
- package/ts/plugins.ts +23 -0
- package/ts/tsbundle.class.tsbundle.ts +49 -0
- package/ts/tsbundle.cli.ts +55 -0
- package/ts/tsbundle.logging.ts +15 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import * as paths from '../paths.js';
|
|
3
|
+
|
|
4
|
+
export class HtmlHandler {
|
|
5
|
+
public defaultFromPath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
|
6
|
+
public defaultToPath: string = plugins.path.join(paths.distServeDir, 'index.html');
|
|
7
|
+
|
|
8
|
+
public async checkIfExists() {
|
|
9
|
+
return plugins.smartfile.fs.fileExists(this.defaultFromPath);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// copies the html
|
|
13
|
+
public async processHtml(optionsArg: {
|
|
14
|
+
from?: string;
|
|
15
|
+
to?: string;
|
|
16
|
+
minify?: boolean;
|
|
17
|
+
}) {
|
|
18
|
+
optionsArg = {
|
|
19
|
+
... {
|
|
20
|
+
from: this.defaultFromPath,
|
|
21
|
+
to: this.defaultToPath,
|
|
22
|
+
minify: false,
|
|
23
|
+
},
|
|
24
|
+
...optionsArg
|
|
25
|
+
}
|
|
26
|
+
if (await this.checkIfExists()) {
|
|
27
|
+
console.log(`${optionsArg.from} replaces file at ${optionsArg.to}`);
|
|
28
|
+
}
|
|
29
|
+
optionsArg.from = plugins.smartpath.transform.toAbsolute(optionsArg.from, paths.cwd) as string;
|
|
30
|
+
optionsArg.to = plugins.smartpath.transform.toAbsolute(optionsArg.to, paths.cwd) as string;
|
|
31
|
+
let fileString = plugins.smartfile.fs.toStringSync(optionsArg.from);
|
|
32
|
+
if (optionsArg.minify) {
|
|
33
|
+
fileString = plugins.htmlMinifier.minify(fileString, {
|
|
34
|
+
minifyCSS: true,
|
|
35
|
+
minifyJS: true,
|
|
36
|
+
sortAttributes: true,
|
|
37
|
+
sortClassName: true,
|
|
38
|
+
removeAttributeQuotes: true,
|
|
39
|
+
collapseWhitespace: true,
|
|
40
|
+
collapseInlineTagWhitespace: true,
|
|
41
|
+
removeComments: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
await plugins.smartfile.memory.toFs(fileString, optionsArg.to);
|
|
45
|
+
console.log(`html processing succeeded!`);
|
|
46
|
+
}
|
|
47
|
+
}
|
package/ts/paths.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
|
|
3
|
+
export const cwd = process.cwd();
|
|
4
|
+
export const packageDir = plugins.path.join(
|
|
5
|
+
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
|
6
|
+
'../'
|
|
7
|
+
);
|
|
8
|
+
export const htmlDir = plugins.path.join(cwd, './html');
|
|
9
|
+
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
|
10
|
+
export const assetsDir = plugins.path.join(packageDir, 'assets');
|
|
11
|
+
export const tsconfigPath = plugins.path.join(assetsDir, './tsconfig.json');
|
package/ts/plugins.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// node native
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export { path };
|
|
5
|
+
|
|
6
|
+
// pushrocks scope
|
|
7
|
+
import * as smartcli from '@push.rocks/smartcli';
|
|
8
|
+
import * as smartfile from '@push.rocks/smartfile';
|
|
9
|
+
import * as smartlog from '@push.rocks/smartlog';
|
|
10
|
+
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
|
11
|
+
import * as smartpath from '@push.rocks/smartpath';
|
|
12
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
13
|
+
import * as smartspawn from '@push.rocks/smartspawn';
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
smartcli,
|
|
17
|
+
smartfile,
|
|
18
|
+
smartlog,
|
|
19
|
+
smartlogDestinationLocal,
|
|
20
|
+
smartpath,
|
|
21
|
+
smartpromise,
|
|
22
|
+
smartspawn,
|
|
23
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import * as interfaces from './interfaces/index.js';
|
|
3
|
+
import { logger } from './tsbundle.logging.js';
|
|
4
|
+
|
|
5
|
+
export class TsBundle {
|
|
6
|
+
|
|
7
|
+
public async build(
|
|
8
|
+
cwdArg: string,
|
|
9
|
+
fromArg: string = './ts_web/index.ts',
|
|
10
|
+
toArg: string = './dist_bundle/bundle.js',
|
|
11
|
+
argvArg: interfaces.ICliOptions
|
|
12
|
+
) {
|
|
13
|
+
const done = plugins.smartpromise.defer();
|
|
14
|
+
const getBundlerPath = () => {
|
|
15
|
+
if (argvArg.bundler === 'esbuild') {
|
|
16
|
+
return './mod_esbuild/index.child.js'
|
|
17
|
+
}
|
|
18
|
+
return './mod_esbuild/index.child.js'
|
|
19
|
+
}
|
|
20
|
+
const transportOptions: interfaces.IEnvTransportOptions = {
|
|
21
|
+
cwd: cwdArg,
|
|
22
|
+
from: fromArg,
|
|
23
|
+
to: toArg,
|
|
24
|
+
mode: argvArg && argvArg.production ? 'production' : 'test',
|
|
25
|
+
argv: {
|
|
26
|
+
bundler: 'esbuild',
|
|
27
|
+
...argvArg
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
|
31
|
+
plugins.path.join(
|
|
32
|
+
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
|
33
|
+
getBundlerPath()
|
|
34
|
+
),
|
|
35
|
+
[],
|
|
36
|
+
{
|
|
37
|
+
env: {
|
|
38
|
+
...process.env,
|
|
39
|
+
transportOptions: JSON.stringify(transportOptions),
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
const childProcess = await threadsimple.start();
|
|
44
|
+
childProcess.on('exit', (status) => {
|
|
45
|
+
done.resolve();
|
|
46
|
+
});
|
|
47
|
+
await done.promise;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { TsBundle } from './tsbundle.class.tsbundle.js';
|
|
3
|
+
import { HtmlHandler } from './mod_html/index.js';
|
|
4
|
+
import { logger } from './tsbundle.logging.js';
|
|
5
|
+
|
|
6
|
+
export const runCli = async () => {
|
|
7
|
+
const tsBundleCli = new plugins.smartcli.Smartcli();
|
|
8
|
+
tsBundleCli.standardCommand().subscribe(async (argvArg) => {
|
|
9
|
+
const tsbundle = new TsBundle();
|
|
10
|
+
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
|
11
|
+
return;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
|
|
15
|
+
const tsbundle = new TsBundle();
|
|
16
|
+
await tsbundle.build(
|
|
17
|
+
process.cwd(),
|
|
18
|
+
'./ts_web/index.ts',
|
|
19
|
+
'./dist_bundle/bundle.js',
|
|
20
|
+
argvArg
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
tsBundleCli.addCommand('npm').subscribe(async (argvArg) => {
|
|
25
|
+
const tsbundle = new TsBundle();
|
|
26
|
+
const htmlHandler = new HtmlHandler();
|
|
27
|
+
await tsbundle.build(
|
|
28
|
+
process.cwd(),
|
|
29
|
+
'./ts/index.ts',
|
|
30
|
+
'./dist_bundle/bundle.js',
|
|
31
|
+
argvArg
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
|
|
36
|
+
const tsbundle = new TsBundle();
|
|
37
|
+
const htmlHandler = new HtmlHandler();
|
|
38
|
+
await tsbundle.build(
|
|
39
|
+
process.cwd(),
|
|
40
|
+
'./ts_web/index.ts',
|
|
41
|
+
'./dist_serve/bundle.js',
|
|
42
|
+
argvArg
|
|
43
|
+
);
|
|
44
|
+
const htmlFiles = await plugins.smartfile.fs.listFiles('./html', /\.html/);
|
|
45
|
+
for (const htmlFile of htmlFiles) {
|
|
46
|
+
await htmlHandler.processHtml({
|
|
47
|
+
from: `./html/${htmlFile}`,
|
|
48
|
+
to: `./dist_serve/${htmlFile}`,
|
|
49
|
+
minify: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
tsBundleCli.startParse();
|
|
55
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
|
|
3
|
+
export const logger = new plugins.smartlog.Smartlog({
|
|
4
|
+
logContext: {
|
|
5
|
+
company: 'Some Company',
|
|
6
|
+
companyunit: 'Some CompanyUnit',
|
|
7
|
+
containerName: 'Some Containername',
|
|
8
|
+
environment: 'local',
|
|
9
|
+
runtime: 'node',
|
|
10
|
+
zone: 'gitzone',
|
|
11
|
+
},
|
|
12
|
+
minimumLogLevel: 'silly',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|