@opencrvs/create-countryconfig 2.0.2-rc.95f6102 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +52 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -147,11 +147,52 @@ function resolveRef() {
|
|
|
147
147
|
process.exit(1)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
function cloneRepository(
|
|
150
|
+
function cloneRepository(
|
|
151
|
+
repoUrl,
|
|
152
|
+
ref,
|
|
153
|
+
targetDir,
|
|
154
|
+
{ keepHistory = false } = {}
|
|
155
|
+
) {
|
|
156
|
+
const depthFlag = keepHistory ? '' : '--depth 1 '
|
|
151
157
|
execSync(
|
|
152
|
-
'git clone
|
|
158
|
+
'git clone ' +
|
|
159
|
+
depthFlag +
|
|
160
|
+
'--branch ' +
|
|
161
|
+
ref +
|
|
162
|
+
' ' +
|
|
163
|
+
repoUrl +
|
|
164
|
+
' ' +
|
|
165
|
+
targetDir,
|
|
153
166
|
{ stdio: 'inherit' }
|
|
154
167
|
)
|
|
168
|
+
|
|
169
|
+
if (!keepHistory) {
|
|
170
|
+
try {
|
|
171
|
+
fs.rmSync(path.join(targetDir, '.git'), {
|
|
172
|
+
recursive: true,
|
|
173
|
+
force: true
|
|
174
|
+
})
|
|
175
|
+
} catch (err) {
|
|
176
|
+
console.error(
|
|
177
|
+
'Failed to remove .git directory from ' + targetDir + ':',
|
|
178
|
+
err.message
|
|
179
|
+
)
|
|
180
|
+
process.exit(1)
|
|
181
|
+
}
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
console.log(
|
|
186
|
+
"Replacing 'origin' remote with 'upstream' in " + targetDir + '...'
|
|
187
|
+
)
|
|
188
|
+
execSync('git remote remove origin', {
|
|
189
|
+
cwd: targetDir,
|
|
190
|
+
stdio: 'inherit'
|
|
191
|
+
})
|
|
192
|
+
execSync('git remote add upstream ' + repoUrl, {
|
|
193
|
+
cwd: targetDir,
|
|
194
|
+
stdio: 'inherit'
|
|
195
|
+
})
|
|
155
196
|
}
|
|
156
197
|
|
|
157
198
|
const projectName = process.argv[2]
|
|
@@ -199,19 +240,6 @@ try {
|
|
|
199
240
|
process.exit(1)
|
|
200
241
|
}
|
|
201
242
|
|
|
202
|
-
try {
|
|
203
|
-
fs.rmSync(path.join(countryconfigTargetDir, '.git'), {
|
|
204
|
-
recursive: true,
|
|
205
|
-
force: true
|
|
206
|
-
})
|
|
207
|
-
} catch (err) {
|
|
208
|
-
console.error(
|
|
209
|
-
'Failed to remove .git directory from country config:',
|
|
210
|
-
err.message
|
|
211
|
-
)
|
|
212
|
-
process.exit(1)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
243
|
const pkgPath = path.join(countryconfigTargetDir, 'package.json')
|
|
216
244
|
if (fs.existsSync(pkgPath)) {
|
|
217
245
|
try {
|
|
@@ -235,22 +263,11 @@ console.log(
|
|
|
235
263
|
)
|
|
236
264
|
|
|
237
265
|
try {
|
|
238
|
-
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName
|
|
239
|
-
|
|
240
|
-
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
241
|
-
process.exit(1)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
try {
|
|
245
|
-
fs.rmSync(path.join(infrastructureTargetDir, '.git'), {
|
|
246
|
-
recursive: true,
|
|
247
|
-
force: true
|
|
266
|
+
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName, {
|
|
267
|
+
keepHistory: true
|
|
248
268
|
})
|
|
249
269
|
} catch (err) {
|
|
250
|
-
console.error(
|
|
251
|
-
'Failed to remove .git directory from infrastructure:',
|
|
252
|
-
err.message
|
|
253
|
-
)
|
|
270
|
+
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
254
271
|
process.exit(1)
|
|
255
272
|
}
|
|
256
273
|
|
|
@@ -263,4 +280,9 @@ console.log(' git init')
|
|
|
263
280
|
console.log(' npm install\n')
|
|
264
281
|
console.log('To get started with the infrastructure:\n')
|
|
265
282
|
console.log(' cd ' + infrastructureDirName)
|
|
266
|
-
console.log(' git
|
|
283
|
+
console.log(' git remote add origin <your-infrastructure-repo-url>')
|
|
284
|
+
console.log(' git push -u origin ' + ref + '\n')
|
|
285
|
+
console.log(
|
|
286
|
+
'The "upstream" remote points at the official infrastructure repository, ' +
|
|
287
|
+
'so you can pull future releases with `git fetch upstream`.\n'
|
|
288
|
+
)
|