Skip to content

Commit

Permalink
Merge pull request #7 from jvmn/feature/2.0.0-rc1
Browse files Browse the repository at this point in the history
Feature/2.0.0 rc1
  • Loading branch information
xeyefex authored Jan 12, 2021
2 parents e0310dd + 227bec4 commit 6ca5a47
Show file tree
Hide file tree
Showing 16 changed files with 4,130 additions and 3,736 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,21 @@ For development of the ***taskrunner***, you would want to:
```
**path**: to get full path run `pwd` in terminal

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
3) this would map the taskrunner repo to run as a native node_modules package in the groundzero-pattern, giving you the ability to develop without the need to rebuild and quickly run the tasks against a sample groundzero project

## Publish on npm

Run:
1) changelog
````
npm run pkg:release
````
2) publish
````
npm run pkg:publish
````

If you need to publish a next/rc or other tags run:
```
npm publish --access public --tag TAGNAME
```
4 changes: 4 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ case 'deploy':
require('./cli/deploy')
break

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

case 'newpattern':
require('./cli/newpattern')
break
Expand Down
8 changes: 3 additions & 5 deletions cli/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ try {
let options = ''
if (args.all) {
options = ':all'
} else {
if (args.stage) {
options = ':stage'
}
} else if (args.stage) {
options = ':stage'
}
if (args.feature) {
options = ':feature' + options
Expand All @@ -47,7 +45,7 @@ const child = spawn(`npm explore @jvmn/groundzero-taskrunner-webpack -- npm run
})

child.on('error', err => {
error(`CLI Build -> ${err}`, true)
error(`CLI Deploy -> ${err}`, true)
})

if (child.stdin) {
Expand Down
59 changes: 59 additions & 0 deletions cli/rsync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/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')
const error = require('../lib/error')
// 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.log('-> using webpack.dev project config!')
} catch (err) {
console.log('-> using 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.json`, fs.constants.R_OK | fs.constants.W_OK)
process.env.SPRITE_CONFIG = `${process.env.PROJECT_CWD}/svg-sprite.config.json`
console.log('-> using svg-sprite.config project config!')
} catch (err) {
console.log('-> using svg-sprite.config package config!')
process.env.SPRITE_CONFIG = `./svg-sprite.config.json`
}

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-webpack -- npm run rsync${options}`, {
stdio: 'inherit',
env: process.env,
shell: true
})

child.on('error', err => {
error(`CLI Rsync -> ${err}`, true)
})

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

if (child.stdout) {
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`)
})
}
6 changes: 6 additions & 0 deletions config-templates/fractal.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
*/

module.exports = {
mandelbrot: {},
server: {
// syncOptions: {
// open: 'local', // the browser
// }
},
hooks: {
'components': {
'engine': {
Expand Down
120 changes: 79 additions & 41 deletions fractal-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const getPackageJsonPath = () => `${process.env.PROJECT_CWD}/package.json`
const getProjectConfig = () => `${process.env.PROJECT_CWD}/project.config.js`
const packageJson = require(getPackageJsonPath())
const config = require(getProjectConfig())
const _ = require('lodash')

/**
* Prevent Bluebird warnings like "a promise was created in a handler but was not returned from it"
Expand Down Expand Up @@ -60,27 +61,6 @@ fractal.components.set('default.context', {
*/
fractal.components.set('default.preview', '@preview-all')

/**
* Fractal server config
*/

fractal.web.set('server', {
sync: true,
port: 3000,
watch: true,
logLevel: 'debug',
syncOptions: {
open: 'local', // the browser
// browser: ['google chrome'],
notify: true,
watchOptions: {
ignored: ['/**/*.scss'],
ignoreInitial: true,
files: [],
}
}
})

/**
* set title of pattern lib in the web view navigation bar (doesn't need to be changed)
*/
Expand All @@ -91,23 +71,6 @@ fractal.components.set('label', 'Patterns')
* set theme configs
*/

// create a new instance with custom config options
const groundzeroTheme = require('@frctl/mandelbrot')({
skin: "white",
styles: ['default', '/theme-overrides/assets/css/theme-overrides.css'],
scripts: [
"/theme-overrides/assets/js/polyfills.min.js",
"default",
]
})

// specify a static directory to hold the theme override css
const mount = path.join(process.env.PROJECT_CWD, 'theme-overrides')
groundzeroTheme.addStatic(mount, 'theme-overrides')
groundzeroTheme.addLoadPath(mount + '/views')

fractal.web.theme(groundzeroTheme)

/**
* CLI Command to compile all components and check on errors
* $ fractal check-erros
Expand All @@ -126,10 +89,49 @@ fractal.cli.command('check-errors', function (opts, done) {
done()
})

/**
* Fractal server config defaults
*/
let fractalServerConfig = {
sync: true,
port: 3000,
watch: true,
logLevel: 'debug',
syncOptions: {
notify: true,
watchOptions: {
ignored: ['/**/*.scss'],
ignoreInitial: true,
files: [],
}
}
}

let mandelbrotDefaults = {
skin: "white",
styles: ['default', '/theme-overrides/assets/css/theme-overrides.css'],
scripts: [
"/theme-overrides/assets/js/polyfills.min.js",
"default",
]
}

// check if we have a fractal.hooks in project root
try {
fs.accessSync(`${process.env.PROJECT_CWD}/fractal.hooks.js`, fs.constants.R_OK | fs.constants.W_OK)
const hooks = require(`${process.env.PROJECT_CWD}/fractal.hooks.js`).hooks
const config = require(`${process.env.PROJECT_CWD}/fractal.hooks.js`)

if (config.server) {
fractalServerConfig = _.defaultsDeep(config.server, fractalServerConfig)
console.error('found Fractal server config in project!')
}

if (config.mandelbrot) {
mandelbrotDefaults = _.defaultsDeep(config.mandelbrot, mandelbrotDefaults)
console.error('found Fractal mandelbrot config in project!')
}

const hooks = config.hooks
// scan and execute fractal hooks to overwrite our defaults
Object.keys(hooks).forEach(type => {
// get the type of hook
Expand All @@ -146,7 +148,43 @@ try {
}
})
})
console.error('found hooks in project!')
console.error('found Fractal hooks in project!')
} catch (err) {
console.error('no hooks found in project!', err)
}
}

/*
* Configure the theme
*/

const mandelbrot = require('@frctl/mandelbrot')

// create a new instance with custom config options
const groundzeroTheme = mandelbrot(mandelbrotDefaults)

// specify a static directory to hold the theme override css
const mountPath = path.join(process.env.PROJECT_CWD, 'theme-overrides')

/*
* Specify the static assets directory that contains the custom stylesheet.
*/

groundzeroTheme.addStatic(mountPath, 'theme-overrides')

/*
* Specify a template directory to override any view templates
*/

groundzeroTheme.addLoadPath(mountPath + '/views')

/**
* Set Fractal web-ui theme
*/

fractal.web.theme(groundzeroTheme)

/**
* Set Fractal server
*/

fractal.web.set('server', fractalServerConfig)
2 changes: 1 addition & 1 deletion lib/critical-css.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const sass = require('node-sass')
const sass = require('sass')
const autoprefixer = require('autoprefixer')
const postcss = require('postcss')
const csso = require('csso')
Expand Down
12 changes: 10 additions & 2 deletions lib/newpattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,18 @@ function template (file, data) {
}

function openTemplateFile(template) {
let inputFilePath = path.join(__dirname, 'templates/' + template)
// First look if template exists in /newpattern/ folder otherwise use taskrunner defaults
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/newpattern/${ template }`, fs.constants.R_OK | fs.constants.W_OK)
inputFilePath = `${ process.env.PROJECT_CWD }/newpattern/${ template }`
console.log(`${ template } -> using\x1b[4m project\x1b[0m template!`)
} catch (err) {
console.log(`${ template } -> using\x1b[4m taskrunner\x1b[0m template!`)
}
return new Promise(function (resolve, reject) {
try {
const inputFile = path.join(__dirname, 'templates/' + template)
fs.readFile(inputFile, (err, file) => {
fs.readFile(inputFilePath, (err, file) => {
if (err) {
console.error(err)
reject(err)
Expand Down
3 changes: 1 addition & 2 deletions lib/templates/pattern.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ module.exports = {
label: '<%= filename %>',
status: 'wip',
context: {
themes: ['bildung', 'holding', 'gesundheit'],
tag: 'div',
tag: 'section',
modifiers: [],
states: [],
xclasses: [],
Expand Down
Loading

0 comments on commit 6ca5a47

Please sign in to comment.