@opencrvs/create-countryconfig 2.0.2-rc.1248069 → 2.0.2-rc.5a52b2b
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 +39 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -147,11 +147,45 @@ 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
|
+
}
|
|
183
|
+
console.log("Removing 'origin' remote from " + targetDir + "...")
|
|
184
|
+
execSync('git remote remove origin', {
|
|
185
|
+
cwd: targetDir,
|
|
186
|
+
stdio: 'inherit'
|
|
187
|
+
})
|
|
188
|
+
|
|
155
189
|
}
|
|
156
190
|
|
|
157
191
|
const projectName = process.argv[2]
|
|
@@ -199,19 +233,6 @@ try {
|
|
|
199
233
|
process.exit(1)
|
|
200
234
|
}
|
|
201
235
|
|
|
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
236
|
const pkgPath = path.join(countryconfigTargetDir, 'package.json')
|
|
216
237
|
if (fs.existsSync(pkgPath)) {
|
|
217
238
|
try {
|
|
@@ -235,22 +256,11 @@ console.log(
|
|
|
235
256
|
)
|
|
236
257
|
|
|
237
258
|
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
|
|
259
|
+
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName, {
|
|
260
|
+
keepHistory: true
|
|
248
261
|
})
|
|
249
262
|
} catch (err) {
|
|
250
|
-
console.error(
|
|
251
|
-
'Failed to remove .git directory from infrastructure:',
|
|
252
|
-
err.message
|
|
253
|
-
)
|
|
263
|
+
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
254
264
|
process.exit(1)
|
|
255
265
|
}
|
|
256
266
|
|
|
@@ -263,4 +273,3 @@ console.log(' git init')
|
|
|
263
273
|
console.log(' npm install\n')
|
|
264
274
|
console.log('To get started with the infrastructure:\n')
|
|
265
275
|
console.log(' cd ' + infrastructureDirName)
|
|
266
|
-
console.log(' git init\n')
|