@opencrvs/create-countryconfig 2.0.2-rc.7f5fc98 → 2.0.2-rc.928fbeb

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.
Files changed (2) hide show
  1. package/index.js +33 -29
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -147,11 +147,39 @@ function resolveRef() {
147
147
  process.exit(1)
148
148
  }
149
149
 
150
- function cloneRepository(repoUrl, ref, targetDir) {
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 --depth 1 --branch ' + ref + ' ' + repoUrl + ' ' + targetDir,
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
+ }
155
183
  }
156
184
 
157
185
  const projectName = process.argv[2]
@@ -199,19 +227,6 @@ try {
199
227
  process.exit(1)
200
228
  }
201
229
 
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
230
  const pkgPath = path.join(countryconfigTargetDir, 'package.json')
216
231
  if (fs.existsSync(pkgPath)) {
217
232
  try {
@@ -235,22 +250,11 @@ console.log(
235
250
  )
236
251
 
237
252
  try {
238
- cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName)
239
- } catch (err) {
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
253
+ cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName, {
254
+ keepHistory: true
248
255
  })
249
256
  } catch (err) {
250
- console.error(
251
- 'Failed to remove .git directory from infrastructure:',
252
- err.message
253
- )
257
+ console.error('Failed to clone the infrastructure repository:', err.message)
254
258
  process.exit(1)
255
259
  }
256
260
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/create-countryconfig",
3
- "version": "2.0.2-rc.7f5fc98",
3
+ "version": "2.0.2-rc.928fbeb",
4
4
  "description": "Scaffold a new OpenCRVS country configuration",
5
5
  "bin": {
6
6
  "create-countryconfig": "./index.js"