-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
165 lines (155 loc) · 8.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const fs = require('fs');
const xml2js = require('xml2js');
const builder = require('xmlbuilder2');
const { setup } = require('./lib/tasks/conversion-setup');
const { convertContentPackageToBundleContent, adjustFileContent } = require('./lib/tasks/converter');
const { migrateCP2FM } = require('./lib/tasks/adjust-fm-project');
const { copyFiles } = require('./lib/tasks/per-fs');
const { adjustPOMModules } = require('./lib/tasks/migrate-content')
console.log('=== time to move to sling12');
let thisFolder = __dirname
console.log('First Copy Peregrine into our Output Folder, this folder: ' + thisFolder);
let projectFolder = setup(thisFolder);
// Copy themeclean-flex into our project
let themeCleanFlexCopies = [
{'source': '../themeclean-flex', 'target': './themes'}
];
copyFiles(projectFolder, themeCleanFlexCopies);
let pomCopyInstructions = [
{ 'source': 'project/build/resources', 'target': 'project/build', 'adjust':'targetPath', 'adjusters': [
{'search': 'apps/', 'replace': 'SLING-CONTENT/apps/'}, {'search':'etc/', 'replace': 'SLING-CONTENT/etc/'}]
},
{ 'source': 'project/build/plugins/plugin/artifactId=frontend-maven-plugin', 'target': 'project/build/plugins/plugin'}
];
let vueModule = {
'parent': 'pagerenderer', 'name': 'vue', 'core': 'core', 'ui': 'ui.apps',
'coreArtifact': 'pagerender-vue.core', 'uiArtifact': 'pagerender-vue.ui.apps', 'pomCopy': pomCopyInstructions
};
let themeCleanModule = {
'parent': 'themes', 'name': 'themeclean', 'core': 'core', 'ui': 'ui.apps',
'group': 'com.themeclean', 'coreArtifact': 'themeclean-core', 'uiArtifact': 'themeclean-ui.apps', 'pomCopy': pomCopyInstructions
};
let themeCleanFlexModule = {
'parent': 'themes', 'name': 'themeclean-flex', 'core': 'core', 'ui': 'ui.apps',
'group': 'com.themecleanflex', 'coreArtifact': 'themecleanflex.core', 'uiArtifact': 'themecleanflex.ui.apps', 'pomCopy': pomCopyInstructions
};
let adminBaseModule = {
'parent': '.', 'name': 'admin-base', 'core': 'core', 'ui': 'ui.apps',
'coreArtifact': 'admin.core', 'uiArtifact': 'admin.ui.apps', 'pomCopy': pomCopyInstructions
};
let modules = [
{ 'parent': 'platform', 'name': 'base', 'core': 'core', 'ui': 'ui.apps'},
{ 'parent': 'platform', 'name': 'felib', 'core': 'core', 'ui': 'ui.apps'},
{ 'parent': 'platform', 'name': 'replication', 'core': 'core', 'ui': 'ui.apps'},
adminBaseModule,
vueModule,
themeCleanModule,
themeCleanFlexModule
];
for(let module of modules) {
convertContentPackageToBundleContent(projectFolder, module);
}
// Copy additional source files for pagerenderer/vue
let copies = [
{'source': 'admin-base/ui.apps/src/main/buildjs', 'target': 'admin-base/core/src/main'},
{'source': 'admin-base/ui.apps/src/main/js', 'target': 'admin-base/core/src/main'},
{'source': 'admin-base/ui.apps/package.json', 'target': 'admin-base/core'},
{'source': 'admin-base/ui.apps/package-lock.json', 'target': 'admin-base/core'},
{'source': 'admin-base/ui.apps/rollup.config.js', 'target': 'admin-base/core'},
{'source': 'admin-base/ui.apps/jsdoc.config.json', 'target': 'admin-base/core'},
{'source': 'pagerenderer/vue/ui.apps/jsdoc.config.json', 'target': 'pagerenderer/vue/core'},
{'source': 'pagerenderer/vue/ui.apps/package.json', 'target': 'pagerenderer/vue/core'},
{'source': 'pagerenderer/vue/ui.apps/package-lock.json', 'target': 'pagerenderer/vue/core'},
{'source': 'pagerenderer/vue/ui.apps/rollup.config.js', 'target': 'pagerenderer/vue/core'},
{'source': 'pagerenderer/vue/ui.apps/src/main/js', 'target': 'pagerenderer/vue/core/src/main'},
{'source': 'buildscripts/buildvue.js', 'target': 'buildscripts', 'name': 'buildvue-pv.js'}
];
copyFiles(projectFolder, copies);
// Adjust Admin Base files
adjustFileContent(
projectFolder + '/admin-base/core/package.json',
[{'type': 'raw', 'search': 'buildscripts/buildvue.js', 'replace': 'buildscripts/buildvue-pv.js'}]
);
adjustFileContent(
projectFolder + '/admin-base/core/rollup.config.js',
[{'type': 'raw', 'search': 'target/classes/etc/felibs/', 'replace': 'target/classes/SLING-CONTENT/etc/felibs/'}]
);
// Adjust pagerenderer/vue files
// First the rollup configuration to use the correct output path
adjustFileContent(
projectFolder + '/pagerenderer/vue/core/rollup.config.js',
[{'type': 'raw', 'search': 'target/classes/etc/felibs/pagerendervue/js/perview.js', 'replace': 'target/classes/SLING-CONTENT/etc/felibs/pagerendervue/js/perview.js'}]
);
// Then the package configuration to use a different (adjusted) buildvue script
adjustFileContent(
projectFolder + '/pagerenderer/vue/core/package.json',
[{'type': 'raw', 'search': 'buildscripts/buildvue.js', 'replace': 'buildscripts/buildvue-pv.js'}]
);
// Then the Copy Felibs Script to use a different (adjusted) Content Root
adjustFileContent(
projectFolder + '/buildscripts/copyfelibs.js',
[
{'type': 'raw', 'search': 'src/main/content/jcr_root', 'replace': 'src/main/resources/SLING-CONTENT'},
{'type': 'raw', 'search': 'target/classes/etc/felibs/admin/dependencies', 'replace': 'target/classes/SLING-CONTENT/etc/felibs/admin/dependencies'}
]
);
// Finally adjust the buildvue script to use the correct output paths
adjustFileContent(
projectFolder + '/buildscripts/buildvue-pv.js',
[
{'type': 'raw', 'search': 'src/main/content/jcr_root/apps', 'replace': 'src/main/resources/SLING-CONTENT/apps'},
{'type': 'raw', 'search': './target/classes/etc/felibs/', 'replace': './target/classes/SLING-CONTENT/etc/felibs/'}
]
);
// Copy additional source files for themes/themeclean
copies = [
{'source': 'themes/themeclean/ui.apps/package.json', 'target': 'themes/themeclean/core'},
{'source': 'themes/themeclean/ui.apps/package-lock.json', 'target': 'themes/themeclean/core'},
{'source': 'themes/themeclean/ui.apps/src/main/content/buildscripts', 'target': 'themes/themeclean/core/src/main'}
];
copyFiles(projectFolder, copies);
// First adjust the package configuration to use a different (adjusted) buildvue script
adjustFileContent(
projectFolder + '/themes/themeclean/core/package.json',
[
{'type': 'raw', 'search': 'themes/themeclean/ui.apps', 'replace': 'themes/themeclean/core'},
{'type': 'raw', 'search': './src/main/content/buildscripts/buildvue.js', 'replace': './src/main/buildscripts/buildvue.js'}
]
);
// Finally adjust the buildvue script to use the correct output paths
adjustFileContent(
projectFolder + '/themes/themeclean/core/src/main/buildscripts/buildvue.js',
[
{'type': 'raw', 'search': 'src/main/content/jcr_root/apps', 'replace': 'src/main/resources/SLING-CONTENT/apps'},
{'type': 'raw', 'search': './target/classes/etc/felibs/', 'replace': './target/classes/SLING-CONTENT/etc/felibs/'}
]
);
// Handle Themeclean-Flex
// Copy the files from UI Apps into Core
copies = [
{'source': 'themes/themeclean-flex/ui.apps/package.json', 'target': 'themes/themeclean-flex/core'},
{'source': 'themes/themeclean-flex/ui.apps/package-lock.json', 'target': 'themes/themeclean-flex/core'},
{'source': 'themes/themeclean-flex/ui.apps/postcss.config.js', 'target': 'themes/themeclean-flex/core'},
{'source': 'themes/themeclean-flex/ui.apps/tailwind.config.js', 'target': 'themes/themeclean-flex/core'},
{'source': 'themes/themeclean-flex/ui.apps/src/main/content/buildscripts', 'target': 'themes/themeclean-flex/core/src/main'}
];
copyFiles(projectFolder, copies);
// First adjust the package configuration to use a different folder
adjustFileContent(
projectFolder + '/themes/themeclean-flex/core/package.json',
[
{'type': 'raw', 'search': 'ui.apps', 'replace': 'core'},
{'type': 'raw', 'search': './src/main/content/buildscripts', 'replace': './src/main/buildscripts'},
{'type': 'raw', 'search': './src/main/content/jcr_root', 'replace': './src/main/resources/SLING-CONTENT'}
]
);
// Finally adjust the buildvue script to use the correct output paths
adjustFileContent(
projectFolder + '/themes/themeclean-flex/core/src/main/buildscripts/buildvue.js',
[
{'type': 'raw', 'search': 'src/main/content/jcr_root', 'replace': 'src/main/resources/SLING-CONTENT'},
{'type': 'raw', 'search': './target/classes/etc/felibs/', 'replace': './target/classes/SLING-CONTENT/etc/felibs/'}
]
);
migrateCP2FM(projectFolder, modules);
adjustPOMModules(projectFolder, ['themes/themeclean-flex'], undefined);