@opencrvs/create-countryconfig 2.0.0-rc.fd02169 → 2.0.0-rc.fd7ac44

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 +50 -20
  2. package/package.json +5 -1
package/index.js CHANGED
@@ -15,7 +15,10 @@ const { execSync } = require('child_process')
15
15
  const path = require('path')
16
16
  const fs = require('fs')
17
17
 
18
- const REPO_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git'
18
+ const COUNTRYCONFIG_REPO_URL =
19
+ 'https://github.com/opencrvs/opencrvs-countryconfig.git'
20
+ const INFRASTRUCTURE_REPO_URL =
21
+ 'https://github.com/opencrvs/infrastructure.git'
19
22
 
20
23
  const projectName = process.argv[2]
21
24
 
@@ -26,48 +29,75 @@ if (!projectName) {
26
29
  process.exit(1)
27
30
  }
28
31
 
29
- const targetDir = path.resolve(process.cwd(), projectName)
32
+ const countryconfigDirName = projectName + '-countryconfig'
33
+ const infrastructureDirName = projectName + '-infrastructure'
30
34
 
31
- if (fs.existsSync(targetDir)) {
32
- console.error(`Error: Directory "${projectName}" already exists.`)
35
+ const countryconfigTargetDir = path.resolve(process.cwd(), countryconfigDirName)
36
+ const infrastructureTargetDir = path.resolve(process.cwd(), infrastructureDirName)
37
+
38
+ if (fs.existsSync(countryconfigTargetDir)) {
39
+ console.error('Error: Directory "' + countryconfigDirName + '" already exists.')
40
+ process.exit(1)
41
+ }
42
+
43
+ if (fs.existsSync(infrastructureTargetDir)) {
44
+ console.error('Error: Directory "' + infrastructureDirName + '" already exists.')
33
45
  process.exit(1)
34
46
  }
35
47
 
36
- console.log(`\nScaffolding OpenCRVS country config in ./${projectName}...\n`)
48
+ console.log('\nScaffolding OpenCRVS country config in ./' + countryconfigDirName + '...\n')
37
49
 
38
50
  try {
39
- execSync(`git clone --depth 1 ${REPO_URL} ${projectName}`, {
40
- stdio: 'inherit'
41
- })
51
+ execSync('git clone --depth 1 ' + COUNTRYCONFIG_REPO_URL + ' ' + countryconfigDirName, { stdio: 'inherit' })
42
52
  } catch (err) {
43
- console.error('Failed to clone the repository:', err.message)
53
+ console.error('Failed to clone the country config repository:', err.message)
44
54
  process.exit(1)
45
55
  }
46
56
 
47
57
  try {
48
- fs.rmSync(path.join(targetDir, '.git'), { recursive: true, force: true })
58
+ fs.rmSync(path.join(countryconfigTargetDir, '.git'), { recursive: true, force: true })
49
59
  } catch (err) {
50
- console.error('Failed to remove .git directory:', err.message)
60
+ console.error('Failed to remove .git directory from country config:', err.message)
51
61
  process.exit(1)
52
62
  }
53
63
 
54
- const pkgPath = path.join(targetDir, 'package.json')
64
+ const pkgPath = path.join(countryconfigTargetDir, 'package.json')
55
65
  if (fs.existsSync(pkgPath)) {
56
66
  try {
57
67
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
58
- pkg.name = projectName
68
+ pkg.name = countryconfigDirName
59
69
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
60
70
  } catch (err) {
61
71
  console.error('Failed to update package.json:', err.message)
62
72
  process.exit(1)
63
73
  }
64
74
  } else {
65
- console.warn(
66
- `Warning: No package.json found in the cloned repository. Project name was not updated.`
67
- )
75
+ console.warn('Warning: No package.json found in the cloned country config repository. Project name was not updated.')
76
+ }
77
+
78
+ console.log('\nScaffolding OpenCRVS infrastructure in ./' + infrastructureDirName + '...\n')
79
+
80
+ try {
81
+ execSync('git clone --depth 1 ' + INFRASTRUCTURE_REPO_URL + ' ' + infrastructureDirName, { stdio: 'inherit' })
82
+ } catch (err) {
83
+ console.error('Failed to clone the infrastructure repository:', err.message)
84
+ process.exit(1)
85
+ }
86
+
87
+ try {
88
+ fs.rmSync(path.join(infrastructureTargetDir, '.git'), { recursive: true, force: true })
89
+ } catch (err) {
90
+ console.error('Failed to remove .git directory from infrastructure:', err.message)
91
+ process.exit(1)
68
92
  }
69
93
 
70
- console.log(`\nDone! To get started:\n`)
71
- console.log(` cd ${projectName}`)
72
- console.log(` git init`)
73
- console.log(` npm install\n`)
94
+ console.log('\nDone! Your project has been set up in two directories:\n')
95
+ console.log(' ./' + countryconfigDirName + ' -- country configuration')
96
+ console.log(' ./' + infrastructureDirName + ' -- server infrastructure\n')
97
+ console.log('To get started with the country config:\n')
98
+ console.log(' cd ' + countryconfigDirName)
99
+ console.log(' git init')
100
+ console.log(' npm install\n')
101
+ console.log('To get started with the infrastructure:\n')
102
+ console.log(' cd ' + infrastructureDirName)
103
+ console.log(' git init\n')
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@opencrvs/create-countryconfig",
3
- "version": "2.0.0-rc.fd02169",
3
+ "version": "2.0.0-rc.fd7ac44",
4
4
  "description": "Scaffold a new OpenCRVS country configuration",
5
5
  "bin": {
6
6
  "create-countryconfig": "./index.js"
7
7
  },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/opencrvs/opencrvs-core.git"
11
+ },
8
12
  "files": [
9
13
  "index.js"
10
14
  ],