Skip to content

Commit

Permalink
Merge pull request pattern-lab#884 from pattern-lab/fix/883-install-e…
Browse files Browse the repository at this point in the history
…dition-dependencies

Fix/883 install edition dependencies
  • Loading branch information
bmuenzenmeyer authored Jul 9, 2018
2 parents c40f4d9 + 3ecbb3e commit 7232cd4
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 36 deletions.
9 changes: 9 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
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/cli@0.0.1-alpha.21...@pattern-lab/cli@0.0.1-alpha.22) (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/cli@0.0.1-alpha.20...@pattern-lab/cli@0.0.1-alpha.21) (2018-07-06)

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
45 changes: 29 additions & 16 deletions packages/cli/bin/install-edition.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
'use strict';

const path = require('path');
const pkg = require(path.resolve(process.cwd(), '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;
10 changes: 10 additions & 0 deletions packages/cli/bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ const checkAndInstallPackage = (packageName, url) =>
*/
const noop = () => {};

const getJSONKey = (packageName, key, fileName = 'package.json') =>
wrapAsync(function*() {
yield checkAndInstallPackage(packageName);
const packageJSON = yield fs.readJson(
path.resolve('node_modules', packageName, fileName)
);
return packageJSON[key];
});

module.exports = {
copyWithPattern,
copyAsync: fs.copy,
Expand All @@ -189,4 +198,5 @@ module.exports = {
wrapAsync,
checkAndInstallPackage,
noop,
getJSONKey,
};
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@pattern-lab/cli",
"description": "Command-line interface (CLI) for the @pattern-lab/core.",
"version": "0.0.1-alpha.21",
"version": "0.0.1-alpha.22",
"bin": {
"patternlab": "bin/patternlab.js"
},
"author": {
"name": "Raphael Okon"
},
"dependencies": {
"@pattern-lab/core": "^3.0.0-alpha.15",
"@pattern-lab/live-server": "^1.3.3-alpha.5",
"@pattern-lab/core": "^3.0.0-alpha.16",
"@pattern-lab/live-server": "^1.3.3-alpha.6",
"archiver": "2.1.1",
"chalk": "2.4.1",
"commander": "2.15.1",
Expand Down
9 changes: 9 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="3.0.0-alpha.16"></a>
# [3.0.0-alpha.16](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.15...@pattern-lab/core@3.0.0-alpha.16) (2018-07-06)

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





<a name="3.0.0-alpha.15"></a>
# [3.0.0-alpha.15](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.14...@pattern-lab/core@3.0.0-alpha.15) (2018-07-06)

Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@pattern-lab/core",
"description": "Create atomic design systems with Pattern Lab. This is the core API and orchestrator of the ecosystem.",
"version": "3.0.0-alpha.15",
"version": "3.0.0-alpha.16",
"main": "./src/index.js",
"dependencies": {
"@pattern-lab/engine-mustache": "^2.0.0-alpha.8",
"@pattern-lab/live-server": "^1.3.3-alpha.5",
"@pattern-lab/live-server": "^1.3.3-alpha.6",
"chalk": "1.1.3",
"chokidar": "1.7.0",
"dive": "0.5.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/development-edition-engine-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.1.1-alpha.4"></a>
## [0.1.1-alpha.4](https://github.com/pattern-lab/edition-node-gulp/compare/@pattern-lab/engine-react-testing-tree@0.1.1-alpha.3...@pattern-lab/engine-react-testing-tree@0.1.1-alpha.4) (2018-07-06)

**Note:** Version bump only for package @pattern-lab/engine-react-testing-tree





<a name="0.1.1-alpha.3"></a>
## [0.1.1-alpha.3](https://github.com/pattern-lab/edition-node-gulp/compare/@pattern-lab/engine-react-testing-tree@0.1.1-alpha.2...@pattern-lab/engine-react-testing-tree@0.1.1-alpha.3) (2018-07-06)

Expand Down
4 changes: 2 additions & 2 deletions packages/development-edition-engine-react/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@pattern-lab/engine-react-testing-tree",
"description": "The tree of components we use to test, develop and validate the React engine",
"version": "0.1.1-alpha.3",
"version": "0.1.1-alpha.4",
"private": true,
"main": "gulpfile.js",
"dependencies": {
"@pattern-lab/core": "^3.0.0-alpha.15",
"@pattern-lab/core": "^3.0.0-alpha.16",
"@pattern-lab/engine-mustache": "^2.0.0-alpha.8",
"@pattern-lab/engine-react": "^0.2.1-alpha.5",
"@pattern-lab/uikit-workshop": "^1.0.0-alpha.7",
Expand Down
9 changes: 9 additions & 0 deletions packages/edition-node-gulp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="2.0.0-alpha.14"></a>
# [2.0.0-alpha.14](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node-gulp/compare/@pattern-lab/edition-node-gulp@2.0.0-alpha.13...@pattern-lab/edition-node-gulp@2.0.0-alpha.14) (2018-07-06)

**Note:** Version bump only for package @pattern-lab/edition-node-gulp





<a name="2.0.0-alpha.13"></a>
# [2.0.0-alpha.13](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node-gulp/compare/@pattern-lab/edition-node-gulp@2.0.0-alpha.12...@pattern-lab/edition-node-gulp@2.0.0-alpha.13) (2018-07-06)

Expand Down
6 changes: 3 additions & 3 deletions packages/edition-node-gulp/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@pattern-lab/edition-node-gulp",
"description": "The gulp wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.",
"version": "2.0.0-alpha.13",
"version": "2.0.0-alpha.14",
"main": "gulpfile.js",
"dependencies": {
"@pattern-lab/cli": "^0.0.1-alpha.21",
"@pattern-lab/core": "^3.0.0-alpha.15",
"@pattern-lab/cli": "^0.0.1-alpha.22",
"@pattern-lab/core": "^3.0.0-alpha.16",
"@pattern-lab/engine-mustache": "^2.0.0-alpha.8",
"@pattern-lab/uikit-workshop": "^1.0.0-alpha.7",
"gulp": "3.9.1",
Expand Down
9 changes: 9 additions & 0 deletions packages/edition-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="1.0.0-alpha.12"></a>
# [1.0.0-alpha.12](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node/compare/@pattern-lab/edition-node@1.0.0-alpha.11...@pattern-lab/edition-node@1.0.0-alpha.12) (2018-07-06)

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





<a name="1.0.0-alpha.11"></a>
# [1.0.0-alpha.11](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node/compare/@pattern-lab/edition-node@1.0.0-alpha.10...@pattern-lab/edition-node@1.0.0-alpha.11) (2018-07-06)

Expand Down
16 changes: 8 additions & 8 deletions packages/edition-node/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@pattern-lab/edition-node",
"description": "A pure wrapper around patternlab-node core, the default pattern engine, and supporting frontend assets.",
"version": "1.0.0-alpha.11",
"version": "1.0.0-alpha.12",
"main": "patternlab-config.json",
"dependencies": {
"@pattern-lab/cli": "^0.0.1-alpha.21",
"@pattern-lab/core": "^3.0.0-alpha.15",
"@pattern-lab/cli": "^0.0.1-alpha.22",
"@pattern-lab/core": "^3.0.0-alpha.16",
"@pattern-lab/engine-mustache": "^2.0.0-alpha.8",
"@pattern-lab/uikit-workshop": "^1.0.0-alpha.7"
},
Expand All @@ -19,11 +19,11 @@
"bugs": "https://github.com/pattern-lab/patternlab-node/issues",
"author": "Brian Muenzenmeyer",
"scripts": {
"build": "patternlab build --config ./patternlab-config.json",
"help": "patternlab --help",
"install": "patternlab install --config ./patternlab-config.json",
"serve": "patternlab serve --config ./patternlab-config.json",
"version": "patternlab --version"
"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"
},
"license": "MIT",
"engines": {
Expand Down
12 changes: 12 additions & 0 deletions packages/live-server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="1.3.3-alpha.6"></a>
## [1.3.3-alpha.6](https://github.com/pattern-lab/patternlab-node/tree/master/packages/live-server/compare/@pattern-lab/live-server@1.3.3-alpha.5...@pattern-lab/live-server@1.3.3-alpha.6) (2018-07-06)


### Bug Fixes

* **dependencies:** pin all packages marked as latest ([87347d5](https://github.com/pattern-lab/patternlab-node/tree/master/packages/live-server/commit/87347d5))





<a name="1.3.3-alpha.5"></a>
## [1.3.3-alpha.5](https://github.com/pattern-lab/patternlab-node/tree/master/packages/live-server/compare/@pattern-lab/live-server@1.3.3-alpha.4...@pattern-lab/live-server@1.3.3-alpha.5) (2018-07-06)

Expand Down
2 changes: 1 addition & 1 deletion packages/live-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pattern-lab/live-server",
"version": "1.3.3-alpha.5",
"version": "1.3.3-alpha.6",
"description": "simple development http server with live reload capability",
"keywords": [
"front-end",
Expand Down

0 comments on commit 7232cd4

Please sign in to comment.