Skip to content

Commit

Permalink
Merge branch 'dev' into plugin-work
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Jul 17, 2018
2 parents 88cce3f + 2b70ff4 commit be68cff
Show file tree
Hide file tree
Showing 72 changed files with 566 additions and 47,632 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ packages/*/public
!packages/core/test/patterns/public/.gitkeep
!packages/core/test/patterns/testDependencyGraph.json
lerna-debug.log
packages/edition-node-gulp/dependencyGraph.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ before_install:
- phantomjs --version

before_script:
- npm install -g lerna@2.9.0
- npm install -g lerna@3.0.0-beta.21
- npm run bootstrap
- lerna add @pattern-lab/engine-mustache
- lerna add @pattern-lab/engine-handlebars
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ The below assume a new directory and project is required.
```bash
mkdir new-project
cd new-project
npm init -y && npx -p @pattern-lab/cli -c 'patternlab init'
npm init -y && npx @pattern-lab/cli -c patternlab init
```
> If you get an error stating that `npx` is not installed, ensure you are on `npm 5.2.0` or later by running `npm -v` or install it globally with `npm install -g npx`. [Learn more about npx.](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b)
1. Follow the on-screen prompts to choose your Edition and a Starterkit should you want one.
1. Run `npm install` one last time to ensure any transient packages from the CLI are installed.
1. Open `package.json` and add the following to your `scripts` object
```diff
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "2.9.0",
"lerna": "3.0.0-beta.21",
"packages": [
"packages/*"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"devDependencies": {
"lerna": "2.9.0"
"lerna": "3.0.0-beta.21"
},
"scripts": {
"bootstrap": "lerna bootstrap --hoist tap --hoist eslin* --hoist husky --hoist prettier --hoist pretty-quick",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=false
save-exact=true
35 changes: 35 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,41 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.0.1-alpha.22"></a>

## [0.0.1-alpha.22](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)

**Note:** Version bump only for package @pattern-lab/cli

<a name="0.0.1-alpha.21"></a>

## [0.0.1-alpha.21](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)

### Bug Fixes

* **install:** add break statements to install edition command ([3b1813c](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/3b1813c))
* **install:** use process to find package.json ([200c7cb](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/200c7cb))

### Features

* **package:** add npmrc file ([55f5bc2](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/55f5bc2))
* **package:** pin all dependencies ([415698e](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/415698e))
* **package:** remove package-lock.json files ([5ab3995](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/5ab3995))

<a name="0.0.1-alpha.20"></a>

## [0.0.1-alpha.20](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-05)

### Bug Fixes

* **cli:** change whitespace to spaces per standard ([4556fc7](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/4556fc7))
* **tests:** change test command name similar to live-server until this passes CI ([5c39be1](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/5c39be1))

### Features

* **serve:** change calling method ([3b86a0d](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/3b86a0d))
* **tests:** use lerna run test at the monorepo level ([38a01b1](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/38a01b1))

<a name="0.0.1-alpha.19"></a>

## [0.0.1-alpha.19](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-05-19)
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/bin/cli-actions/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const init = options =>

if (edition) {
spinner.text = `⊙ patternlab → Installing edition: ${edition}`;
const newConf = yield installEdition(edition, patternlabConfig); // 3.1
const newConf = yield installEdition(
edition,
patternlabConfig,
projectDir
); // 3.1
patternlabConfig = Object.assign(patternlabConfig, newConf); // 3.2
spinner.succeed(`⊙ patternlab → Installed edition: ${edition}`);
}
Expand Down
47 changes: 31 additions & 16 deletions packages/cli/bin/install-edition.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,63 @@
'use strict';

const path = require('path');
const pkg = require('../package.json');
const EOL = require('os').EOL;
const {
checkAndInstallPackage,
copyAsync,
wrapAsync,
writeJsonAsync,
getJSONKey,
} = require('./utils');

const installEdition = (edition, config) =>
wrapAsync(function*() {
const installEdition = (edition, config, projectDir) => {
const pkg = require(path.resolve(projectDir, 'package.json'));

return wrapAsync(function*() {
/**
* 1. Trigger edition install
* 2. Copy over the mandatory edition files to sourceDir
* 3. Do custom post-install procedures for different core editions:
* 3.1 Copy gulpfile.js for edition-node-gulp
* 3. Copy dependencies defined in edition
* 4. Do custom post-install procedures for different core editions:
* 4.1 Copy gulpfile.js for edition-node-gulp
* 4.2 Copy scripts for edition-node
*/
const sourceDir = config.paths.source.root;
yield checkAndInstallPackage(edition); // 1
yield copyAsync(
path.resolve('./node_modules', edition, 'source', '_meta'),
path.resolve(sourceDir, '_meta')
); // 2
switch (edition) { // 3
// 3.1
pkg.dependencies = Object.assign(
{},
pkg.dependencies || {},
yield getJSONKey(edition, 'dependencies')
); // 3
switch (edition) { // 4
// 4.1
case '@pattern-lab/edition-node-gulp': {
yield copyAsync(
path.resolve('./node_modules', edition, 'gulpfile.js'),
path.resolve(sourceDir, '../', 'gulpfile.js')
);
break;
}
// 4.2
case '@pattern-lab/edition-node': {
const scriptsJSON = {
'pl:build': 'patternlab build --config ./patternlab-config.json',
'pl:help': 'patternlab --help',
'pl:install': 'patternlab install --config ./patternlab-config.json',
'pl:serve': 'patternlab serve --config ./patternlab-config.json',
'pl:version': 'patternlab --version',
};
pkg.scripts = Object.assign({}, pkg.scripts || {}, scriptsJSON);
yield writeJsonAsync('./package.json', pkg, { spaces: 2 });
pkg.scripts = Object.assign(
{},
pkg.scripts || {},
yield getJSONKey(edition, 'scripts')
);
break;
}
}
yield writeJsonAsync(path.resolve(projectDir, 'package.json'), pkg, {
spaces: 2,
EOL: EOL,
});
return config;
});
};

module.exports = installEdition;
16 changes: 16 additions & 0 deletions packages/cli/bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,21 @@ const noop = () => {};
const writeJsonAsync = (filePath, data) =>
wrapAsync(function*() {
yield fs.outputJSON(filePath, data, { spaces: 2 });

/**
* @func getJSONKey
* Installs package, then returns the value for the given JSON file's key within
* @param {string} packageName - the node_module to install / load
* @param {object} key - the key to find
* @param {object} fileName - the filePath of the JSON
*/
const getJSONKey = (packageName, key, fileName = 'package.json') =>
wrapAsync(function*() {
yield checkAndInstallPackage(packageName);
const jsonData = yield fs.readJson(
path.resolve('node_modules', packageName, fileName)
);
return jsonData[key];
});

module.exports = {
Expand All @@ -200,4 +215,5 @@ module.exports = {
wrapAsync,
checkAndInstallPackage,
noop,
getJSONKey,
};
Loading

0 comments on commit be68cff

Please sign in to comment.