@opencrvs/create-countryconfig 2.0.2-rc.1248069 → 2.0.2-rc.3152b53
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 +45 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -147,11 +147,50 @@ 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, replaceOriginWithUpstream = 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
|
+
}
|
|
183
|
+
if (replaceOriginWithUpstream) {
|
|
184
|
+
console.log("Replacing 'origin' remote with 'upstream' in " + targetDir + "...")
|
|
185
|
+
execSync('git remote remove origin', {
|
|
186
|
+
cwd: targetDir,
|
|
187
|
+
stdio: 'inherit'
|
|
188
|
+
})
|
|
189
|
+
execSync('git remote add upstream ' + repoUrl, {
|
|
190
|
+
cwd: targetDir,
|
|
191
|
+
stdio: 'inherit'
|
|
192
|
+
})
|
|
193
|
+
}
|
|
155
194
|
}
|
|
156
195
|
|
|
157
196
|
const projectName = process.argv[2]
|
|
@@ -199,19 +238,6 @@ try {
|
|
|
199
238
|
process.exit(1)
|
|
200
239
|
}
|
|
201
240
|
|
|
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
241
|
const pkgPath = path.join(countryconfigTargetDir, 'package.json')
|
|
216
242
|
if (fs.existsSync(pkgPath)) {
|
|
217
243
|
try {
|
|
@@ -235,22 +261,12 @@ console.log(
|
|
|
235
261
|
)
|
|
236
262
|
|
|
237
263
|
try {
|
|
238
|
-
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
process.exit(1)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
try {
|
|
245
|
-
fs.rmSync(path.join(infrastructureTargetDir, '.git'), {
|
|
246
|
-
recursive: true,
|
|
247
|
-
force: true
|
|
264
|
+
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName, {
|
|
265
|
+
keepHistory: true,
|
|
266
|
+
replaceOriginWithUpstream: true
|
|
248
267
|
})
|
|
249
268
|
} catch (err) {
|
|
250
|
-
console.error(
|
|
251
|
-
'Failed to remove .git directory from infrastructure:',
|
|
252
|
-
err.message
|
|
253
|
-
)
|
|
269
|
+
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
254
270
|
process.exit(1)
|
|
255
271
|
}
|
|
256
272
|
|
|
@@ -263,4 +279,3 @@ console.log(' git init')
|
|
|
263
279
|
console.log(' npm install\n')
|
|
264
280
|
console.log('To get started with the infrastructure:\n')
|
|
265
281
|
console.log(' cd ' + infrastructureDirName)
|
|
266
|
-
console.log(' git init\n')
|