Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Bergmann committed Jun 5, 2019
0 parents commit 049dafe
Show file tree
Hide file tree
Showing 47 changed files with 2,087 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/templates/
17 changes: 17 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "eslint:recommended",
"root": true,
"rules": {
"indent": ["error", 4],
"no-undef": 0,
"no-console": ["error", { "allow": ["log", "warn", "error", "info", "table"] }]
},
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
web-ui
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# VHUG BUILDING TASKS

## What is this script doing?

In charge of running the dev / build / release / deploy / newpattern toolchain for groundzero projects by providing a simple CLI.

*** This package is a dependencie of VHUG BASE, will not work as a standalone ***

## Installation

1) npm install:
```
npm install @vonheldenundgestalten/vhug-tasks --save-dev
```
2) get all coomand options by running from the terminal:
```
groundzero help
```
* for convinence, groundzero projects should also come with mapped npm commands to the CLI.
* if you need to overwrite some config files in your project, copy-paste the config you need from the "config-templates" folder to your project root folder and edit as you wish.
## Development
For development of the ***taskrunner***, you would want to:
1) clone the repo and install it.
2) clone the latest groundzero-pattern repo, install it and run within-it:
```
npm link path/to/taskrunner
````
3) this would map the taskrunner repo to run as a native node_modules package in the groundzero-pattern, giving you the ability to develope without the need to rebuild and quickly run the tasks against a sample groundzero project
25 changes: 25 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
console.log('using babel default')
module.exports = function (api) {
api.cache(true);

const presets = [
["@babel/env", {
// modules: false,
targets: {
"browsers": [
"defaults", //(> 0.5%, last 2 versions, Firefox ESR, not dead)
"ie 10",
"ie 11"
]
},
// for uglifyjs...
forceAllTransforms: process.env === "production"
}],
];
const plugins = [];

return {
presets,
plugins
};
}
63 changes: 63 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node
'use strict';

const minimist = require('minimist')
const error = require('./lib/error.js')
const criticalCss = require('./lib/critical-css.js').process
const args = minimist(process.argv.slice(2))

let cmd = args._[0] || 'help'

if (args.version || args.v) {
cmd = 'version'
}

if (args.help || args.h) {
cmd = 'help'
}

switch (cmd) {
case 'dev':
require('./cli/dev.js')
break

case 'build':
require('./cli/build')
break

case 'release':
require('./cli/release')
break

case 'deploy':
require('./cli/deploy')
break

case 'newpattern':
require('./cli/newpattern')
break

case 'version':
require('./lib/version')(args)
break

case 'update':
require('./lib/update')
break

case 'help':
require('./lib/help')(args)
break

case 'jest':
require('./cli/jest.js')
break

default:
error(`"${cmd}" is not a valid command!`, true)
break
}

module.exports = {
criticalCss
};
43 changes: 43 additions & 0 deletions cli/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node
'use strict';

const { spawn } = require('child_process');
const fs = require('fs');
// expose project root folder varialbe to load configs in npm
process.env.PROJECT_CWD = process.env.PWD;

// check if we have a webpack.dev config in project root
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/webpack.dev.js`, fs.constants.R_OK | fs.constants.W_OK);
process.env.WEBPACK_DEV_CONFIG = `${process.env.PROJECT_CWD}/webpack.dev.js`
console.error('use webpack.dev project config!');
} catch (err) {
console.error('use webpack.dev package config!');
process.env.WEBPACK_DEV_CONFIG = `./webpack.dev.js`
}
// check if we have a svg-sprite config in project root
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/svg-sprite.config.js`, fs.constants.R_OK | fs.constants.W_OK);
process.env.SPRITE_CONFIG = `${process.env.PROJECT_CWD}/svg-sprite.config.js`
console.error('use svg-sprite.config project config!');
} catch (err) {
console.error('use svg-sprite.config package config!');
process.env.SPRITE_CONFIG = `./svg-sprite.config.js`
}

const child = spawn('npm explore @vonheldenundgestalten/vhug-tasks -- npm run build', {
stdio: 'inherit',
env: process.env,
shell: true
});

if (child.stdin) {
process.stdin.pipe(child.stdin)
}

if (child.stdout) {
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
});
}

56 changes: 56 additions & 0 deletions cli/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env node
'use strict';

const { spawn } = require('child_process');
const minimist = require('minimist')
const args = minimist(process.argv.slice(2))
const fs = require('fs');
// expose project root folder varialbe to load configs in npm
process.env.PROJECT_CWD = process.env.PWD;

// check if we have a webpack.dev config in project root
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/webpack.dev.js`, fs.constants.R_OK | fs.constants.W_OK);
process.env.WEBPACK_DEV_CONFIG = `${process.env.PROJECT_CWD}/webpack.dev.js`
console.error('use webpack.dev project config!');
} catch (err) {
console.error('use webpack.dev package config!');
process.env.WEBPACK_DEV_CONFIG = `./webpack.dev.js`
}
// check if we have a svg-sprite config in project root
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/svg-sprite.config.js`, fs.constants.R_OK | fs.constants.W_OK);
process.env.SPRITE_CONFIG = `${process.env.PROJECT_CWD}/svg-sprite.config.js`
console.error('use svg-sprite.config project config!');
} catch (err) {
console.error('use svg-sprite.config package config!');
process.env.SPRITE_CONFIG = `./svg-sprite.config.js`
}

let options = '';
if (args.all) {
options = ':all'
} else {
if (args.stage) {
options = ':stage'
}
}
if (args.feature) {
options = ':feature' + options
}

const child = spawn(`npm explore @jvmn/groundzero-taskrunner -- npm run deploy${options}`, {
stdio: 'inherit',
env: process.env,
shell: true
});

if (child.stdin) {
process.stdin.pipe(child.stdin)
}

if (child.stdout) {
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
});
}
42 changes: 42 additions & 0 deletions cli/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node
'use strict';

const { spawn } = require('child_process');
const fs = require('fs');
// expose project root folder varialbe to load configs in npm
process.env.PROJECT_CWD = process.env.PWD;

// check if we have a webpack.dev config in project root
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/webpack.dev.js`, fs.constants.R_OK | fs.constants.W_OK);
process.env.WEBPACK_DEV_CONFIG = `${process.env.PROJECT_CWD}/webpack.dev.js`
console.error('use webpack.dev project config!');
} catch (err) {
console.error('use webpack.dev package config!');
process.env.WEBPACK_DEV_CONFIG = `./webpack.dev.js`
}
// check if we have a svg-sprite config in project root
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/svg-sprite.config.js`, fs.constants.R_OK | fs.constants.W_OK);
process.env.SPRITE_CONFIG = `${process.env.PROJECT_CWD}/svg-sprite.config.js`
console.error('use svg-sprite.config project config!');
} catch (err) {
console.error('use svg-sprite.config package config!');
process.env.SPRITE_CONFIG = `./svg-sprite.config.js`
}

const child = spawn('npm explore @jvmn/groundzero-taskrunner -- npm run dev', {
stdio: 'inherit',
env: process.env,
shell: true
});

if (child.stdin) {
process.stdin.pipe(child.stdin)
}

if (child.stdout) {
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
});
}
27 changes: 27 additions & 0 deletions cli/jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node
'use strict';

const { spawn } = require('child_process');

console.log("running jest");
// we expose the project path to correctly use it within the tasks
process.env.PROJECT_CWD = process.env.PWD;

let options = ' --';
options += ' --projects ' + process.env.PROJECT_CWD;

const child = spawn('npm explore @jvonheldenundgestalten/vhug-tasks -- npm run jest' + options, {
stdio: 'inherit',
env: process.env,
shell: true
});

if (child.stdin) {
process.stdin.pipe(child.stdin)
}

if (child.stdout) {
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
});
}
24 changes: 24 additions & 0 deletions cli/newpattern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
'use strict';

const { spawn } = require('child_process');

console.log("running newpattern");
// we expose the project path to correctly use it within the tasks
process.env.PROJECT_CWD = process.env.PWD;

const child = spawn('npm explore @vonheldenundgestalten/vhug-tasks -- npm run newpattern', {
stdio: 'inherit',
env: process.env,
shell: true
});

if (child.stdin) {
process.stdin.pipe(child.stdin)
}

if (child.stdout) {
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
});
}
Loading

0 comments on commit 049dafe

Please sign in to comment.