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

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 +44 -30
  2. 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(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
+ }
183
+ console.log("Removing 'origin' remote from " + targetDir + "...")
184
+ execSync('git remote remove origin', {
185
+ cwd: targetDir,
186
+ stdio: 'inherit'
187
+ })
188
+ console.log("Adding 'upstream' remote to " + targetDir + "...")
189
+ execSync('git remote add upstream https://github.com/opencrvs/infrastructure.git', {
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,11 @@ console.log(
235
261
  )
236
262
 
237
263
  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
264
+ cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName, {
265
+ keepHistory: true
248
266
  })
249
267
  } catch (err) {
250
- console.error(
251
- 'Failed to remove .git directory from infrastructure:',
252
- err.message
253
- )
268
+ console.error('Failed to clone the infrastructure repository:', err.message)
254
269
  process.exit(1)
255
270
  }
256
271
 
@@ -263,4 +278,3 @@ console.log(' git init')
263
278
  console.log(' npm install\n')
264
279
  console.log('To get started with the infrastructure:\n')
265
280
  console.log(' cd ' + infrastructureDirName)
266
- console.log(' git init\n')
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.8027057",
4
4
  "description": "Scaffold a new OpenCRVS country configuration",
5
5
  "bin": {
6
6
  "create-countryconfig": "./index.js"