Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
f33f985d3d | |||
ddae40ddb2 | |||
4256578bc6 | |||
1dd604d572 | |||
262fd6e718 | |||
d660550485 | |||
0842c2fdec | |||
20bf5dfc57 | |||
04a77f9eeb | |||
a97af3232a | |||
01953fdfec | |||
2b794967d2 | |||
eacda66c43 | |||
5f048712e1 | |||
6d6c851274 | |||
afc3141fb2 | |||
317487ffaa | |||
ac8d603060 | |||
c46621517b | |||
4b283ad6a3 | |||
6f3aab9232 | |||
de60087146 | |||
b1730c0cc6 | |||
b39c928b1e | |||
0a211e804e | |||
41a886cfcf | |||
62ad70ac6c | |||
455e33488d | |||
1af1908e1d | |||
31967ab846 | |||
93fda3944a | |||
d0ce17299a | |||
1b0fa5b465 | |||
7a6f9d9569 | |||
ebcf89520a | |||
ca6ef86c8c | |||
a98471e914 | |||
7755286aab | |||
8f17a3c92a | |||
65221425ca | |||
0bc8048ac5 | |||
65754d34bc | |||
c4a276ebf3 | |||
3db075b795 |
@ -1,5 +1,7 @@
|
|||||||
# gitzone ci_default
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: clone
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -38,19 +40,7 @@ snyk:
|
|||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
@ -60,12 +50,24 @@ testSTABLE:
|
|||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
@ -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
|
||||||
|
4
.snyk
Normal file
4
.snyk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.13.5
|
||||||
|
ignore: {}
|
||||||
|
patch: {}
|
3
cli.js
3
cli.js
@ -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();
|
||||||
|
@ -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();
|
||||||
|
3719
package-lock.json
generated
3719
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
46
package.json
46
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.26",
|
"version": "1.0.49",
|
||||||
"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.17",
|
||||||
"@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": "^11.13.8",
|
"@types/node": "^13.7.7",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.0.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.4.4",
|
"@babel/core": "^7.6.2",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||||
"@babel/plugin-proposal-decorators": "^7.4.4",
|
"@babel/plugin-proposal-decorators": "^7.6.0",
|
||||||
"@babel/plugin-transform-runtime": "^7.4.4",
|
"@babel/plugin-transform-runtime": "^7.6.2",
|
||||||
"@babel/preset-env": "^7.4.4",
|
"@babel/preset-env": "^7.6.2",
|
||||||
"@babel/runtime": "^7.4.4",
|
"@babel/runtime": "^7.6.2",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/smartcli": "^3.0.7",
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
"@pushrocks/smartfile": "^7.0.2",
|
"@pushrocks/smartfile": "^7.0.8",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
"@pushrocks/smartlog-destination-local": "^7.0.5",
|
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
||||||
"@types/html-minifier": "^3.5.3",
|
"@types/html-minifier": "^3.5.3",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"rollup": "^1.10.1",
|
"rollup": "^1.32.0",
|
||||||
"rollup-plugin-babel": "^4.3.2",
|
"rollup-plugin-babel": "^4.3.2",
|
||||||
"rollup-plugin-commonjs": "^9.3.4",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
"rollup-plugin-node-resolve": "^4.2.3",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
"rollup-plugin-sourcemaps": "^0.5.0",
|
||||||
"rollup-plugin-terser": "^5.0.0",
|
"rollup-plugin-terser": "^5.2.0",
|
||||||
"rollup-plugin-typescript2": "^0.21.0"
|
"rollup-plugin-typescript2": "^0.26.0",
|
||||||
|
"terser": "^4.6.4"
|
||||||
},
|
},
|
||||||
"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",
|
||||||
|
@ -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)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
[](https://maintainedby.lossless.com)
|
||||||
|
@ -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();
|
||||||
|
@ -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
|
||||||
|
};
|
||||||
|
@ -2,49 +2,18 @@ import * as plugins from './tsbundle.plugins';
|
|||||||
import { logger } from './tsbundle.logging';
|
import { logger } from './tsbundle.logging';
|
||||||
|
|
||||||
export class TsBundle {
|
export class TsBundle {
|
||||||
public optionsTest: plugins.rollup.RollupOptions = this.getBaseOptions();
|
|
||||||
public optionsProduction: plugins.rollup.RollupOptions = (() => {
|
|
||||||
const productionOptions = this.getBaseOptions();
|
|
||||||
productionOptions.plugins.push(plugins.rollupTerser());
|
|
||||||
return productionOptions;
|
|
||||||
})();
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a bundle for the test enviroment
|
|
||||||
*/
|
|
||||||
public async buildTest() {
|
|
||||||
// create a bundle
|
|
||||||
logger.log('info', `bundling for TEST!`);
|
|
||||||
const bundle = await plugins.rollup.rollup(this.optionsTest);
|
|
||||||
bundle.generate(this.optionsTest.output);
|
|
||||||
await bundle.write(this.optionsTest.output);
|
|
||||||
logger.log('ok', `Successfully bundled files!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a bundle for the production environment
|
|
||||||
*/
|
|
||||||
public async buildProduction() {
|
|
||||||
// create a bundle
|
|
||||||
logger.log('info', `bundling for PRODUCTION!`);
|
|
||||||
const bundle = await plugins.rollup.rollup(this.optionsProduction);
|
|
||||||
bundle.generate(this.optionsProduction.output);
|
|
||||||
await bundle.write(this.optionsProduction.output);
|
|
||||||
logger.log('ok', `Successfully bundled files!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the basic default options for rollup
|
* the basic default options for rollup
|
||||||
*/
|
*/
|
||||||
public getBaseOptions() {
|
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: `ts_web/index.ts`,
|
input: fromArg,
|
||||||
output: {
|
output: {
|
||||||
name: 'tsbundle',
|
name: 'tsbundle',
|
||||||
// file: 'dist_web/bundle.js',
|
file: toArg,
|
||||||
file: 'dist_web/bundle.js',
|
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
},
|
},
|
||||||
@ -64,7 +33,7 @@ export class TsBundle {
|
|||||||
experimentalDecorators: true,
|
experimentalDecorators: true,
|
||||||
inlineSourceMap: true,
|
inlineSourceMap: true,
|
||||||
noEmitOnError: true,
|
noEmitOnError: true,
|
||||||
lib: ['es2017', 'dom'],
|
lib: ['esnext', 'dom'],
|
||||||
target: 'es2017',
|
target: 'es2017',
|
||||||
noImplicitAny: false
|
noImplicitAny: false
|
||||||
}
|
}
|
||||||
@ -81,8 +50,8 @@ 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'],
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
@ -105,9 +74,53 @@ export class TsBundle {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
})
|
})*/
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
return baseOptions;
|
return baseOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
|
||||||
|
return this.getBaseOptions(fromArg, toArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
|
||||||
|
const productionOptions = this.getBaseOptions(fromArg, toArg);
|
||||||
|
productionOptions.plugins.push(plugins.rollupTerser({
|
||||||
|
compress: true,
|
||||||
|
mangle: true,
|
||||||
|
sourcemap: true
|
||||||
|
}));
|
||||||
|
return productionOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
// Nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a bundle for the test enviroment
|
||||||
|
*/
|
||||||
|
public async buildTest(fromArg: string, toArg: string) {
|
||||||
|
// create a bundle
|
||||||
|
logger.log('info', `bundling for TEST!`);
|
||||||
|
const buildOptions = this.getOptionsTest(fromArg, toArg);
|
||||||
|
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||||
|
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a bundle for the production environment
|
||||||
|
*/
|
||||||
|
public async buildProduction(fromArg: string, toArg: string) {
|
||||||
|
// create a bundle
|
||||||
|
logger.log('info', `bundling for PRODUCTION!`);
|
||||||
|
const buildOptions = this.getOptionsProduction(fromArg, toArg);
|
||||||
|
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||||
|
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,14 @@ export const runCli = async () => {
|
|||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
const htmlHandler = new HtmlHandler();
|
const htmlHandler = new HtmlHandler();
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case argvArg.production:
|
case argvArg.production || process.env.CI:
|
||||||
await tsbundle.buildProduction();
|
await tsbundle.buildProduction(argvArg.from, argvArg.to);
|
||||||
await htmlHandler.minifyHtml();
|
await htmlHandler.minifyHtml();
|
||||||
break;
|
break;
|
||||||
case argvArg.test:
|
case argvArg.test:
|
||||||
await tsbundle.buildTest();
|
|
||||||
await htmlHandler.copyHtml();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
logger.log('error', `Can not determine build target environement. Please specify via --production or --test`)
|
await tsbundle.buildTest(argvArg.from, argvArg.to);
|
||||||
|
await htmlHandler.copyHtml();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,16 +5,23 @@ export class HtmlHandler {
|
|||||||
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
||||||
public targetFilePath: string = plugins.path.join(paths.distWebDir, 'index.html');
|
public targetFilePath: string = plugins.path.join(paths.distWebDir, 'index.html');
|
||||||
|
|
||||||
|
public async checkIfExists() {
|
||||||
|
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
// copies the html
|
// copies the html
|
||||||
public async copyHtml() {
|
public async copyHtml() {
|
||||||
await plugins.smartfile.fs.copy(
|
if (!(await this.checkIfExists())) {
|
||||||
this.sourceFilePath,
|
return;
|
||||||
this.targetFilePath
|
}
|
||||||
);
|
await plugins.smartfile.fs.copy(this.sourceFilePath, this.targetFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies and minifies the html
|
// copies and minifies the html
|
||||||
public async minifyHtml() {
|
public async minifyHtml() {
|
||||||
|
if (!(await this.checkIfExists())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
|
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
|
||||||
const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
|
const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
|
||||||
minifyCSS: true,
|
minifyCSS: true,
|
||||||
@ -24,9 +31,8 @@ export class HtmlHandler {
|
|||||||
removeAttributeQuotes: true,
|
removeAttributeQuotes: true,
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
collapseInlineTagWhitespace: true,
|
collapseInlineTagWhitespace: true,
|
||||||
removeComments: true
|
removeComments: true
|
||||||
|
|
||||||
});
|
});
|
||||||
plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath);
|
plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export {
|
export { path };
|
||||||
path
|
|
||||||
};
|
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
import * as smartcli from '@pushrocks/smartcli';
|
||||||
|
Reference in New Issue
Block a user