Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
0a211e804e | |||
41a886cfcf | |||
62ad70ac6c | |||
455e33488d | |||
1af1908e1d | |||
31967ab846 | |||
93fda3944a | |||
d0ce17299a | |||
1b0fa5b465 | |||
7a6f9d9569 | |||
ebcf89520a | |||
ca6ef86c8c | |||
a98471e914 | |||
7755286aab |
@ -1,5 +1,5 @@
|
|||||||
# gitzone ci_default
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -49,14 +49,14 @@ testLTS:
|
|||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -65,7 +65,7 @@ testSTABLE:
|
|||||||
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
|
||||||
|
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: {}
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.29",
|
"version": "1.0.37",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.29",
|
"version": "1.0.37",
|
||||||
"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",
|
||||||
|
@ -10,3 +10,6 @@ early.stop();
|
|||||||
if (process.env.CLI_CALL) {
|
if (process.env.CLI_CALL) {
|
||||||
runCli();
|
runCli();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lets make this usable programmatically
|
||||||
|
export * from './tsbundle.class.tsbundle';
|
||||||
|
@ -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
|
||||||
},
|
},
|
||||||
@ -82,7 +51,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'],
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
@ -105,9 +74,49 @@ 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());
|
||||||
|
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);
|
||||||
|
await bundle.write(buildOptions.output);
|
||||||
|
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);
|
||||||
|
await bundle.write(buildOptions.output);
|
||||||
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,19 @@ 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) || process.env.CI:
|
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:
|
||||||
default:
|
default:
|
||||||
await tsbundle.buildTest();
|
await tsbundle.buildTest(argvArg.from, argvArg.to);
|
||||||
await htmlHandler.copyHtml();
|
await htmlHandler.copyHtml();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tsBundleCli.startParse();
|
tsBundleCli.startParse();
|
||||||
};
|
};
|
||||||
|
@ -5,24 +5,21 @@ 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 () {
|
public async checkIfExists() {
|
||||||
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies the html
|
// copies the html
|
||||||
public async copyHtml() {
|
public async copyHtml() {
|
||||||
if (!(await this.checkIfExists)) {
|
if (!(await this.checkIfExists())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await plugins.smartfile.fs.copy(
|
await plugins.smartfile.fs.copy(this.sourceFilePath, this.targetFilePath);
|
||||||
this.sourceFilePath,
|
|
||||||
this.targetFilePath
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies and minifies the html
|
// copies and minifies the html
|
||||||
public async minifyHtml() {
|
public async minifyHtml() {
|
||||||
if (!(await this.checkIfExists)) {
|
if (!(await this.checkIfExists())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
|
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
|
||||||
@ -34,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