Skip to content

Commit 480ed5d

Browse files
committed
feat: setup edition-twig in cli init
1 parent cd91786 commit 480ed5d

File tree

5 files changed

+72
-15
lines changed

5 files changed

+72
-15
lines changed

packages/cli/bin/inquiries/edition.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const editionSetup = [
1414
name: 'edition',
1515
message: 'Which edition do you want to use (defaults to edition-node)?',
1616
choices: [
17+
{
18+
name: 'edition-twig (php engine)',
19+
value: '@pattern-lab/edition-twig',
20+
},
1721
{
1822
name: 'edition-node',
1923
value: '@pattern-lab/edition-node',

packages/cli/bin/inquiries/starterkit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const starterkitSetup = [
2727
},
2828
{
2929
name: 'starterkit-twig-demo',
30-
value: 'starterkit-twig-demo',
30+
value: '@pattern-lab/starterkit-twig-demo',
3131
},
3232
{
3333
name: 'starterkit-mustache-materialdesign',

packages/cli/bin/install-edition.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const installEdition = (edition, config, projectDir) => {
2222
* 4. Do custom post-install procedures for different core editions:
2323
* 4.1 Copy gulpfile.js for edition-node-gulp
2424
* 4.2 Copy scripts for edition-node
25+
* 4.3 Copy items for edition-twig
2526
*/
2627
const sourceDir = config.paths.source.root;
2728
yield checkAndInstallPackage(edition); // 1
@@ -52,6 +53,29 @@ const installEdition = (edition, config, projectDir) => {
5253
);
5354
break;
5455
}
56+
// 4.3
57+
case '@pattern-lab/edition-twig': {
58+
const editionPath = path.resolve('./node_modules', edition);
59+
const editionConfigPath = path.resolve(
60+
editionPath,
61+
'patternlab-config.json'
62+
);
63+
const editionConfig = require(editionConfigPath);
64+
65+
pkg.scripts = Object.assign(
66+
{},
67+
pkg.scripts || {},
68+
yield getJSONKey(edition, 'scripts')
69+
);
70+
71+
yield copyAsync(
72+
path.resolve(editionPath, 'alter-twig.php'),
73+
path.resolve(sourceDir, '../', 'alter-twig.php')
74+
);
75+
76+
config = merge(config, editionConfig);
77+
break;
78+
}
5579
}
5680
yield writeJsonAsync(path.resolve(projectDir, 'package.json'), pkg, {
5781
spaces: 2,

packages/edition-twig/patternlab-config.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
"paths": [
99
"./node_modules/@pattern-lab/uikit-workshop/views-twig"
1010
]
11-
},
12-
{
13-
"id": "atoms",
14-
"recursive": true,
15-
"paths": [
16-
"source/_patterns/00-atoms"
17-
]
18-
},
19-
{
20-
"id": "molecules",
21-
"recursive": true,
22-
"paths": [
23-
"source/_patterns/01-molecules"
24-
]
2511
}
2612
],
2713
"alterTwigEnv": [
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"engines": {
3+
"twig": {
4+
"namespaces": [
5+
{
6+
"id": "atoms",
7+
"recursive": true,
8+
"paths": [
9+
"source/_patterns/00-atoms"
10+
]
11+
},
12+
{
13+
"id": "molecules",
14+
"recursive": true,
15+
"paths": [
16+
"source/_patterns/01-molecules"
17+
]
18+
},
19+
{
20+
"id": "organisms",
21+
"recursive": true,
22+
"paths": [
23+
"source/_patterns/02-organisms"
24+
]
25+
},
26+
{
27+
"id": "templates",
28+
"recursive": true,
29+
"paths": [
30+
"source/_patterns/03-templates"
31+
]
32+
},
33+
{
34+
"id": "pages",
35+
"recursive": true,
36+
"paths": [
37+
"source/_patterns/04-pages"
38+
]
39+
}
40+
]
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)