Skip to content

Commit 7232cd4

Browse files
Merge pull request #884 from pattern-lab/fix/883-install-edition-dependencies
Fix/883 install edition dependencies
2 parents c40f4d9 + 3ecbb3e commit 7232cd4

File tree

15 files changed

+120
-36
lines changed

15 files changed

+120
-36
lines changed

packages/cli/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
<a name="0.0.1-alpha.22"></a>
7+
## [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)
8+
9+
**Note:** Version bump only for package @pattern-lab/cli
10+
11+
12+
13+
14+
615
<a name="0.0.1-alpha.21"></a>
716
## [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)
817

packages/cli/bin/cli-actions/init.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ const init = options =>
4545

4646
if (edition) {
4747
spinner.text = `⊙ patternlab → Installing edition: ${edition}`;
48-
const newConf = yield installEdition(edition, patternlabConfig); // 3.1
48+
const newConf = yield installEdition(
49+
edition,
50+
patternlabConfig,
51+
projectDir
52+
); // 3.1
4953
patternlabConfig = Object.assign(patternlabConfig, newConf); // 3.2
5054
spinner.succeed(`⊙ patternlab → Installed edition: ${edition}`);
5155
}

packages/cli/bin/install-edition.js

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,63 @@
11
'use strict';
2+
23
const path = require('path');
3-
const pkg = require(path.resolve(process.cwd(), 'package.json'));
4+
const EOL = require('os').EOL;
45
const {
56
checkAndInstallPackage,
67
copyAsync,
78
wrapAsync,
89
writeJsonAsync,
10+
getJSONKey,
911
} = require('./utils');
1012

11-
const installEdition = (edition, config) =>
12-
wrapAsync(function*() {
13+
const installEdition = (edition, config, projectDir) => {
14+
const pkg = require(path.resolve(projectDir, 'package.json'));
15+
16+
return wrapAsync(function*() {
1317
/**
1418
* 1. Trigger edition install
1519
* 2. Copy over the mandatory edition files to sourceDir
16-
* 3. Do custom post-install procedures for different core editions:
17-
* 3.1 Copy gulpfile.js for edition-node-gulp
20+
* 3. Copy dependencies defined in edition
21+
* 4. Do custom post-install procedures for different core editions:
22+
* 4.1 Copy gulpfile.js for edition-node-gulp
23+
* 4.2 Copy scripts for edition-node
1824
*/
1925
const sourceDir = config.paths.source.root;
2026
yield checkAndInstallPackage(edition); // 1
2127
yield copyAsync(
2228
path.resolve('./node_modules', edition, 'source', '_meta'),
2329
path.resolve(sourceDir, '_meta')
2430
); // 2
25-
switch (edition) { // 3
26-
// 3.1
31+
pkg.dependencies = Object.assign(
32+
{},
33+
pkg.dependencies || {},
34+
yield getJSONKey(edition, 'dependencies')
35+
); // 3
36+
switch (edition) { // 4
37+
// 4.1
2738
case '@pattern-lab/edition-node-gulp': {
2839
yield copyAsync(
2940
path.resolve('./node_modules', edition, 'gulpfile.js'),
3041
path.resolve(sourceDir, '../', 'gulpfile.js')
3142
);
3243
break;
3344
}
45+
// 4.2
3446
case '@pattern-lab/edition-node': {
35-
const scriptsJSON = {
36-
'pl:build': 'patternlab build --config ./patternlab-config.json',
37-
'pl:help': 'patternlab --help',
38-
'pl:install': 'patternlab install --config ./patternlab-config.json',
39-
'pl:serve': 'patternlab serve --config ./patternlab-config.json',
40-
'pl:version': 'patternlab --version',
41-
};
42-
pkg.scripts = Object.assign({}, pkg.scripts || {}, scriptsJSON);
43-
yield writeJsonAsync('./package.json', pkg, { spaces: 2 });
47+
pkg.scripts = Object.assign(
48+
{},
49+
pkg.scripts || {},
50+
yield getJSONKey(edition, 'scripts')
51+
);
4452
break;
4553
}
4654
}
55+
yield writeJsonAsync(path.resolve(projectDir, 'package.json'), pkg, {
56+
spaces: 2,
57+
EOL: EOL,
58+
});
4759
return config;
4860
});
61+
};
4962

5063
module.exports = installEdition;

packages/cli/bin/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ const checkAndInstallPackage = (packageName, url) =>
175175
*/
176176
const noop = () => {};
177177

178+
const getJSONKey = (packageName, key, fileName = 'package.json') =>
179+
wrapAsync(function*() {
180+
yield checkAndInstallPackage(packageName);
181+
const packageJSON = yield fs.readJson(
182+
path.resolve('node_modules', packageName, fileName)
183+
);
184+
return packageJSON[key];
185+
});
186+
178187
module.exports = {
179188
copyWithPattern,
180189
copyAsync: fs.copy,
@@ -189,4 +198,5 @@ module.exports = {
189198
wrapAsync,
190199
checkAndInstallPackage,
191200
noop,
201+
getJSONKey,
192202
};

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@pattern-lab/cli",
33
"description": "Command-line interface (CLI) for the @pattern-lab/core.",
4-
"version": "0.0.1-alpha.21",
4+
"version": "0.0.1-alpha.22",
55
"bin": {
66
"patternlab": "bin/patternlab.js"
77
},
88
"author": {
99
"name": "Raphael Okon"
1010
},
1111
"dependencies": {
12-
"@pattern-lab/core": "^3.0.0-alpha.15",
13-
"@pattern-lab/live-server": "^1.3.3-alpha.5",
12+
"@pattern-lab/core": "^3.0.0-alpha.16",
13+
"@pattern-lab/live-server": "^1.3.3-alpha.6",
1414
"archiver": "2.1.1",
1515
"chalk": "2.4.1",
1616
"commander": "2.15.1",

packages/core/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
<a name="3.0.0-alpha.16"></a>
7+
# [3.0.0-alpha.16](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)
8+
9+
**Note:** Version bump only for package @pattern-lab/core
10+
11+
12+
13+
14+
615
<a name="3.0.0-alpha.15"></a>
716
# [3.0.0-alpha.15](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)
817

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@pattern-lab/core",
33
"description": "Create atomic design systems with Pattern Lab. This is the core API and orchestrator of the ecosystem.",
4-
"version": "3.0.0-alpha.15",
4+
"version": "3.0.0-alpha.16",
55
"main": "./src/index.js",
66
"dependencies": {
77
"@pattern-lab/engine-mustache": "^2.0.0-alpha.8",
8-
"@pattern-lab/live-server": "^1.3.3-alpha.5",
8+
"@pattern-lab/live-server": "^1.3.3-alpha.6",
99
"chalk": "1.1.3",
1010
"chokidar": "1.7.0",
1111
"dive": "0.5.0",

packages/development-edition-engine-react/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
<a name="0.1.1-alpha.4"></a>
7+
## [0.1.1-alpha.4](https://github.com/pattern-lab/edition-node-gulp/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)
8+
9+
**Note:** Version bump only for package @pattern-lab/engine-react-testing-tree
10+
11+
12+
13+
14+
615
<a name="0.1.1-alpha.3"></a>
716
## [0.1.1-alpha.3](https://github.com/pattern-lab/edition-node-gulp/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)
817

packages/development-edition-engine-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@pattern-lab/engine-react-testing-tree",
33
"description": "The tree of components we use to test, develop and validate the React engine",
4-
"version": "0.1.1-alpha.3",
4+
"version": "0.1.1-alpha.4",
55
"private": true,
66
"main": "gulpfile.js",
77
"dependencies": {
8-
"@pattern-lab/core": "^3.0.0-alpha.15",
8+
"@pattern-lab/core": "^3.0.0-alpha.16",
99
"@pattern-lab/engine-mustache": "^2.0.0-alpha.8",
1010
"@pattern-lab/engine-react": "^0.2.1-alpha.5",
1111
"@pattern-lab/uikit-workshop": "^1.0.0-alpha.7",

packages/edition-node-gulp/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
<a name="2.0.0-alpha.14"></a>
7+
# [2.0.0-alpha.14](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node-gulp/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)
8+
9+
**Note:** Version bump only for package @pattern-lab/edition-node-gulp
10+
11+
12+
13+
14+
615
<a name="2.0.0-alpha.13"></a>
716
# [2.0.0-alpha.13](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node-gulp/compare/@pattern-lab/[email protected]...@pattern-lab/[email protected]) (2018-07-06)
817

0 commit comments

Comments
 (0)