Compare commits

...

36 Commits

Author SHA1 Message Date
f5340e7109 1.0.53 2020-03-13 14:53:15 +00:00
71c917b32f fix(core): update 2020-03-13 14:53:15 +00:00
ac3ef390e8 1.0.52 2020-03-09 15:04:37 +00:00
7ca9c52cc7 fix(core): update 2020-03-09 15:04:36 +00:00
0c702029f2 1.0.51 2020-03-09 14:36:56 +00:00
dddd3ead1c fix(core): update 2020-03-09 14:36:55 +00:00
bad5690d99 1.0.50 2020-03-02 10:10:30 +00:00
a8fb7aac7f fix(core): update 2020-03-02 10:10:29 +00:00
f33f985d3d 1.0.49 2020-03-02 09:42:45 +00:00
ddae40ddb2 fix(core): update 2020-03-02 09:42:44 +00:00
4256578bc6 1.0.48 2020-03-02 09:37:04 +00:00
1dd604d572 fix(core): update 2020-03-02 09:37:04 +00:00
262fd6e718 1.0.47 2019-10-12 15:56:44 +02:00
d660550485 fix(core): update 2019-10-12 15:56:44 +02:00
0842c2fdec 1.0.46 2019-10-12 15:55:37 +02:00
20bf5dfc57 fix(core): update 2019-10-12 15:55:37 +02:00
04a77f9eeb 1.0.45 2019-10-06 23:34:05 +02:00
a97af3232a fix(core): update 2019-10-06 23:34:04 +02:00
01953fdfec 1.0.44 2019-10-06 01:21:33 +02:00
2b794967d2 fix(core): update 2019-10-06 01:21:32 +02:00
eacda66c43 1.0.43 2019-10-05 22:59:53 +02:00
5f048712e1 fix(core): update 2019-10-05 22:59:52 +02:00
6d6c851274 1.0.42 2019-10-05 21:26:24 +02:00
afc3141fb2 fix(core): update 2019-10-05 21:26:24 +02:00
317487ffaa 1.0.41 2019-10-05 21:25:45 +02:00
ac8d603060 fix(core): update 2019-10-05 21:25:44 +02:00
c46621517b 1.0.40 2019-08-26 16:33:09 +02:00
4b283ad6a3 fix(core): update 2019-08-26 16:33:08 +02:00
6f3aab9232 1.0.39 2019-08-26 16:32:26 +02:00
de60087146 fix(core): update 2019-08-26 16:32:26 +02:00
b1730c0cc6 1.0.38 2019-08-25 16:35:22 +02:00
b39c928b1e fix(core): update 2019-08-25 16:35:22 +02:00
0a211e804e 1.0.37 2019-07-19 12:09:00 +02:00
41a886cfcf fix(core): update 2019-07-19 12:09:00 +02:00
62ad70ac6c 1.0.36 2019-07-19 10:52:28 +02:00
455e33488d fix(core): update 2019-07-19 10:52:27 +02:00
13 changed files with 1344 additions and 1431 deletions

View File

@ -1,5 +1,7 @@
# gitzone ci_default # gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
variables:
GIT_STRATEGY: clone
cache: cache:
paths: paths:
@ -38,17 +40,17 @@ snyk:
# test stage # test stage
# ==================== # ====================
testLTS: testStable:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install lts - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv - priv
testBuild: testBuild:
stage: test stage: test
@ -98,7 +100,9 @@ trigger:
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-dbase:npmci
services:
- docker:18-dind
stage: metadata stage: metadata
script: script:
- npmci command npm install -g @gitzone/tsdoc - npmci command npm install -g @gitzone/tsdoc

3
cli.js
View File

@ -1,3 +1,4 @@
#!/usr/bin/env node #!/usr/bin/env node
process.env.CLI_CALL = 'true'; process.env.CLI_CALL = 'true';
require('./dist/index'); const cliTool = require('./dist/index');
cliTool.runCli();

View File

@ -1,4 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
process.env.CLI_CALL = 'true'; process.env.CLI_CALL = 'true';
require('@gitzone/tsrun'); require('@gitzone/tsrun');
require('./ts/index'); const cliTool = require('./ts/index');
cliTool.runCli();

2604
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tsbundle", "name": "@gitzone/tsbundle",
"version": "1.0.35", "version": "1.0.53",
"private": false, "private": false,
"description": "a bundler using rollup for painless bundling of web projects", "description": "a bundler using rollup for painless bundling of web projects",
"main": "dist/index.js", "main": "dist/index.js",
@ -16,41 +16,43 @@
"tsbundle": "cli.js" "tsbundle": "cli.js"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.11", "@gitzone/tsbuild": "^2.1.20",
"@gitzone/tsrun": "^1.2.6", "@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^12.6.6", "tslint": "^6.1.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.4.4", "@babel/core": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.4.4", "@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.4.4", "@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.4.4", "@babel/preset-env": "^7.8.7",
"@babel/runtime": "^7.4.4", "@babel/runtime": "^7.8.7",
"@pushrocks/early": "^3.0.3", "@pushrocks/early": "^3.0.3",
"@pushrocks/smartcli": "^3.0.7", "@pushrocks/smartcli": "^3.0.9",
"@pushrocks/smartfile": "^7.0.2", "@pushrocks/smartfile": "^7.0.9",
"@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog": "^2.0.21",
"@pushrocks/smartlog-destination-local": "^8.0.2", "@pushrocks/smartlog-destination-local": "^8.0.2",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-typescript": "^4.0.0",
"@types/html-minifier": "^3.5.3", "@types/html-minifier": "^3.5.3",
"@types/node": "^13.9.1",
"html-minifier": "^4.0.0", "html-minifier": "^4.0.0",
"rollup": "^1.10.1", "rollup": "^2.0.6",
"rollup-plugin-babel": "^4.3.2", "rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.0.1", "rollup-plugin-sourcemaps": "^0.5.0",
"rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-terser": "^5.3.0",
"rollup-plugin-sourcemaps": "^0.4.2", "terser": "^4.6.6"
"rollup-plugin-terser": "^5.0.0",
"rollup-plugin-typescript2": "^0.22.0"
}, },
"files": [ "files": [
"ts/*", "ts/*",
"ts_web/*", "ts_web/*",
"dist/*", "dist/*",
"dist_web/*", "dist_web/*",
"dist_ts_web/*",
"assets/*", "assets/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",

View File

@ -30,6 +30,6 @@ tsbundle will bundle modern JavaScript websites in an Google Bot conformant way
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com) [![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -2,8 +2,7 @@ import { expect, tap } from '@pushrocks/tapbundle';
import * as tsbundle from '../ts/index'; import * as tsbundle from '../ts/index';
tap.test('first test', async () => { tap.test('first test', async () => {
tsbundle; await tsbundle.runCli();
console.log('hi');
}); });
tap.start(); tap.start();

View File

@ -7,6 +7,9 @@ import { logger } from './tsbundle.logging';
import { runCli } from './tsbundle.cli'; import { runCli } from './tsbundle.cli';
early.stop(); early.stop();
if (process.env.CLI_CALL) { // lets make this usable programmatically
runCli(); export * from './tsbundle.class.tsbundle';
} export * from './tsbundle.htmlhandler';
export {
runCli
};

View File

@ -6,6 +6,9 @@ export class TsBundle {
* the basic default options for rollup * the basic default options for rollup
*/ */
public getBaseOptions(fromArg: string = `ts_web/index.ts`, toArg: string = 'dist_web/bundle.js') { public getBaseOptions(fromArg: string = `ts_web/index.ts`, toArg: string = 'dist_web/bundle.js') {
logger.log('info', `from: ${fromArg}`);
logger.log('info', `to: ${toArg}`);
const baseOptions: plugins.rollup.RollupOptions = { const baseOptions: plugins.rollup.RollupOptions = {
input: fromArg, input: fromArg,
output: { output: {
@ -22,19 +25,14 @@ export class TsBundle {
plugins: [ plugins: [
// Compile TypeScript files // Compile TypeScript files
plugins.rollupTypescript({ plugins.rollupTypescript({
useTsconfigDeclarationDir: true, declaration: false,
tsconfigOverride: { emitDecoratorMetadata: true,
compilerOptions: { experimentalDecorators: true,
declaration: true, inlineSourceMap: true,
emitDecoratorMetadata: true, noEmitOnError: true,
experimentalDecorators: true, lib: ['esnext', 'dom'],
inlineSourceMap: true, noImplicitAny: false,
noEmitOnError: true, target: 'es2018'
lib: ['es2017', 'dom'],
target: 'es2017',
noImplicitAny: false
}
}
}), }),
// Allow node_modules resolution, so you can use 'external' to control // Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle // which external modules to include in the bundle
@ -47,7 +45,7 @@ export class TsBundle {
}), }),
// Resolve source maps to the original source // Resolve source maps to the original source
plugins.rollupSourceMaps(), plugins.rollupSourceMaps()
/*plugins.rollupBabel({ /*plugins.rollupBabel({
runtimeHelpers: true, runtimeHelpers: true,
extensions: ['.js', '.jsx', '.ts', '.tsx'], extensions: ['.js', '.jsx', '.ts', '.tsx'],
@ -78,16 +76,22 @@ export class TsBundle {
} }
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions { public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
return this.getBaseOptions(); return this.getBaseOptions(fromArg, toArg);
} }
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions { public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
const productionOptions = this.getBaseOptions(); const productionOptions = this.getBaseOptions(fromArg, toArg);
productionOptions.plugins.push(plugins.rollupTerser()); productionOptions.plugins.push(plugins.rollupTerser({
compress: true,
mangle: true,
sourcemap: true
}));
return productionOptions; return productionOptions;
} }
constructor() {} constructor() {
// Nothing here
}
/** /**
* creates a bundle for the test enviroment * creates a bundle for the test enviroment
@ -95,9 +99,10 @@ export class TsBundle {
public async buildTest(fromArg: string, toArg: string) { public async buildTest(fromArg: string, toArg: string) {
// create a bundle // create a bundle
logger.log('info', `bundling for TEST!`); logger.log('info', `bundling for TEST!`);
const bundle = await plugins.rollup.rollup(this.getOptionsTest(fromArg, toArg)); const buildOptions = this.getOptionsTest(fromArg, toArg);
bundle.generate(this.getOptionsTest(fromArg, toArg).output); const bundle = await plugins.rollup.rollup(buildOptions);
await bundle.write(this.getOptionsTest(fromArg, toArg).output); bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
logger.log('ok', `Successfully bundled files!`); logger.log('ok', `Successfully bundled files!`);
} }
@ -107,9 +112,10 @@ export class TsBundle {
public async buildProduction(fromArg: string, toArg: string) { public async buildProduction(fromArg: string, toArg: string) {
// create a bundle // create a bundle
logger.log('info', `bundling for PRODUCTION!`); logger.log('info', `bundling for PRODUCTION!`);
const bundle = await plugins.rollup.rollup(this.getOptionsProduction(fromArg, toArg)); const buildOptions = this.getOptionsProduction(fromArg, toArg);
bundle.generate(this.getOptionsProduction(fromArg, toArg).output); const bundle = await plugins.rollup.rollup(buildOptions);
await bundle.write(this.getOptionsProduction(fromArg, toArg).output); bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
logger.log('ok', `Successfully bundled files!`); logger.log('ok', `Successfully bundled files!`);
} }
} }

View File

@ -10,18 +10,32 @@ export const runCli = async () => {
const htmlHandler = new HtmlHandler(); const htmlHandler = new HtmlHandler();
switch (true) { switch (true) {
case argvArg.production || process.env.CI: case argvArg.production || process.env.CI:
await tsbundle.buildProduction(null, null); await tsbundle.buildProduction(argvArg.from, argvArg.to);
await htmlHandler.minifyHtml(); await htmlHandler.minifyHtml();
break; break;
case argvArg.test: case argvArg.test:
default: default:
await tsbundle.buildTest(null, null); await tsbundle.buildTest(argvArg.from, argvArg.to);
await htmlHandler.copyHtml(); await htmlHandler.copyHtml();
return; return;
} }
}); });
tsBundleCli.addCommand('element').subscribe(async argvArg => {
const tsbundle = new TsBundle();
// const htmlHandler = new HtmlHandler();
switch (true) {
case argvArg.production || process.env.CI:
await tsbundle.buildProduction('./ts_web/index.ts', './dist_ts_web/bundle.js');
// await htmlHandler.minifyHtml();
break;
case argvArg.test:
default:
await tsbundle.buildTest('./ts_web/index.ts', './dist_ts_web/bundle.js');
// await htmlHandler.copyHtml();
return;
}
});
tsBundleCli.startParse(); tsBundleCli.startParse();
}; };

View File

@ -10,15 +10,15 @@ export class HtmlHandler {
} }
// copies the html // copies the html
public async copyHtml() { public async copyHtml(targetPathArg = this.targetFilePath) {
if (!(await this.checkIfExists())) { if (!(await this.checkIfExists())) {
return; return;
} }
await plugins.smartfile.fs.copy(this.sourceFilePath, this.targetFilePath); await plugins.smartfile.fs.copy(this.sourceFilePath, targetPathArg);
} }
// copies and minifies the html // copies and minifies the html
public async minifyHtml() { public async minifyHtml(targetPathArg = this.targetFilePath) {
if (!(await this.checkIfExists())) { if (!(await this.checkIfExists())) {
return; return;
} }
@ -33,6 +33,6 @@ export class HtmlHandler {
collapseInlineTagWhitespace: true, collapseInlineTagWhitespace: true,
removeComments: true removeComments: true
}); });
plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath); plugins.smartfile.memory.toFsSync(minifiedHtml, targetPathArg);
} }
} }

View File

@ -4,3 +4,4 @@ export const cwd = process.cwd();
export const packageDir = plugins.path.join(__dirname, '../'); export const packageDir = plugins.path.join(__dirname, '../');
export const htmlDir = plugins.path.join(cwd, './html'); export const htmlDir = plugins.path.join(cwd, './html');
export const distWebDir = plugins.path.join(cwd, './dist_web'); export const distWebDir = plugins.path.join(cwd, './dist_web');
export const assetsDir = plugins.path.join(packageDir, 'assets');

View File

@ -14,11 +14,11 @@ export { smartcli, smartfile, smartlog, smartlogDestinationLocal };
// third party scope // third party scope
import * as rollup from 'rollup'; import * as rollup from 'rollup';
import rollupBabel from 'rollup-plugin-babel'; import rollupBabel from 'rollup-plugin-babel';
import rollupCommonjs from 'rollup-plugin-commonjs'; import rollupCommonjs from '@rollup/plugin-commonjs';
import rollupResolve from 'rollup-plugin-node-resolve'; import rollupResolve from '@rollup/plugin-node-resolve';
import rollupSourceMaps from 'rollup-plugin-sourcemaps'; import rollupSourceMaps from 'rollup-plugin-sourcemaps';
import { terser as rollupTerser } from 'rollup-plugin-terser'; import { terser as rollupTerser } from 'rollup-plugin-terser';
import rollupTypescript from 'rollup-plugin-typescript2'; import rollupTypescript from '@rollup/plugin-typescript';
import * as htmlMinifier from 'html-minifier'; import * as htmlMinifier from 'html-minifier';