@opencrvs/toolkit 2.0.1-rc.02711e1 → 2.0.1-rc.02c1a89
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.
|
@@ -17,8 +17,54 @@ const fs = require('fs')
|
|
|
17
17
|
|
|
18
18
|
const COUNTRYCONFIG_REPO_URL =
|
|
19
19
|
'https://github.com/opencrvs/opencrvs-countryconfig.git'
|
|
20
|
-
const INFRASTRUCTURE_REPO_URL =
|
|
21
|
-
|
|
20
|
+
const INFRASTRUCTURE_REPO_URL = 'https://github.com/opencrvs/infrastructure.git'
|
|
21
|
+
|
|
22
|
+
const { version } = JSON.parse(
|
|
23
|
+
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8')
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
function tagExists(repoUrl, tag) {
|
|
27
|
+
try {
|
|
28
|
+
execSync(
|
|
29
|
+
'git ls-remote --exit-code --tags ' + repoUrl + ' refs/tags/' + tag,
|
|
30
|
+
{
|
|
31
|
+
stdio: 'pipe'
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
return true
|
|
35
|
+
} catch (err) {
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function resolveRef() {
|
|
41
|
+
if (version.includes('-')) {
|
|
42
|
+
return 'develop'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const tag = 'v' + version
|
|
46
|
+
if (
|
|
47
|
+
tagExists(COUNTRYCONFIG_REPO_URL, tag) &&
|
|
48
|
+
tagExists(INFRASTRUCTURE_REPO_URL, tag)
|
|
49
|
+
) {
|
|
50
|
+
return tag
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.warn(
|
|
54
|
+
'\nWarning: tag "' +
|
|
55
|
+
tag +
|
|
56
|
+
'" was not found in both the country config and infrastructure ' +
|
|
57
|
+
'repositories; falling back to develop for both.'
|
|
58
|
+
)
|
|
59
|
+
return 'develop'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function cloneRepository(repoUrl, ref, targetDir) {
|
|
63
|
+
execSync(
|
|
64
|
+
'git clone --depth 1 --branch ' + ref + ' ' + repoUrl + ' ' + targetDir,
|
|
65
|
+
{ stdio: 'inherit' }
|
|
66
|
+
)
|
|
67
|
+
}
|
|
22
68
|
|
|
23
69
|
const projectName = process.argv[2]
|
|
24
70
|
|
|
@@ -33,31 +79,48 @@ const countryconfigDirName = projectName + '-countryconfig'
|
|
|
33
79
|
const infrastructureDirName = projectName + '-infrastructure'
|
|
34
80
|
|
|
35
81
|
const countryconfigTargetDir = path.resolve(process.cwd(), countryconfigDirName)
|
|
36
|
-
const infrastructureTargetDir = path.resolve(
|
|
82
|
+
const infrastructureTargetDir = path.resolve(
|
|
83
|
+
process.cwd(),
|
|
84
|
+
infrastructureDirName
|
|
85
|
+
)
|
|
37
86
|
|
|
38
87
|
if (fs.existsSync(countryconfigTargetDir)) {
|
|
39
|
-
console.error(
|
|
88
|
+
console.error(
|
|
89
|
+
'Error: Directory "' + countryconfigDirName + '" already exists.'
|
|
90
|
+
)
|
|
40
91
|
process.exit(1)
|
|
41
92
|
}
|
|
42
93
|
|
|
43
94
|
if (fs.existsSync(infrastructureTargetDir)) {
|
|
44
|
-
console.error(
|
|
95
|
+
console.error(
|
|
96
|
+
'Error: Directory "' + infrastructureDirName + '" already exists.'
|
|
97
|
+
)
|
|
45
98
|
process.exit(1)
|
|
46
99
|
}
|
|
47
100
|
|
|
48
|
-
|
|
101
|
+
const ref = resolveRef()
|
|
102
|
+
|
|
103
|
+
console.log(
|
|
104
|
+
'\nScaffolding OpenCRVS country config in ./' + countryconfigDirName + '...\n'
|
|
105
|
+
)
|
|
49
106
|
|
|
50
107
|
try {
|
|
51
|
-
|
|
108
|
+
cloneRepository(COUNTRYCONFIG_REPO_URL, ref, countryconfigDirName)
|
|
52
109
|
} catch (err) {
|
|
53
110
|
console.error('Failed to clone the country config repository:', err.message)
|
|
54
111
|
process.exit(1)
|
|
55
112
|
}
|
|
56
113
|
|
|
57
114
|
try {
|
|
58
|
-
fs.rmSync(path.join(countryconfigTargetDir, '.git'), {
|
|
115
|
+
fs.rmSync(path.join(countryconfigTargetDir, '.git'), {
|
|
116
|
+
recursive: true,
|
|
117
|
+
force: true
|
|
118
|
+
})
|
|
59
119
|
} catch (err) {
|
|
60
|
-
console.error(
|
|
120
|
+
console.error(
|
|
121
|
+
'Failed to remove .git directory from country config:',
|
|
122
|
+
err.message
|
|
123
|
+
)
|
|
61
124
|
process.exit(1)
|
|
62
125
|
}
|
|
63
126
|
|
|
@@ -72,22 +135,34 @@ if (fs.existsSync(pkgPath)) {
|
|
|
72
135
|
process.exit(1)
|
|
73
136
|
}
|
|
74
137
|
} else {
|
|
75
|
-
console.warn(
|
|
138
|
+
console.warn(
|
|
139
|
+
'Warning: No package.json found in the cloned country config repository. Project name was not updated.'
|
|
140
|
+
)
|
|
76
141
|
}
|
|
77
142
|
|
|
78
|
-
console.log(
|
|
143
|
+
console.log(
|
|
144
|
+
'\nScaffolding OpenCRVS infrastructure in ./' +
|
|
145
|
+
infrastructureDirName +
|
|
146
|
+
'...\n'
|
|
147
|
+
)
|
|
79
148
|
|
|
80
149
|
try {
|
|
81
|
-
|
|
150
|
+
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName)
|
|
82
151
|
} catch (err) {
|
|
83
152
|
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
84
153
|
process.exit(1)
|
|
85
154
|
}
|
|
86
155
|
|
|
87
156
|
try {
|
|
88
|
-
fs.rmSync(path.join(infrastructureTargetDir, '.git'), {
|
|
157
|
+
fs.rmSync(path.join(infrastructureTargetDir, '.git'), {
|
|
158
|
+
recursive: true,
|
|
159
|
+
force: true
|
|
160
|
+
})
|
|
89
161
|
} catch (err) {
|
|
90
|
-
console.error(
|
|
162
|
+
console.error(
|
|
163
|
+
'Failed to remove .git directory from infrastructure:',
|
|
164
|
+
err.message
|
|
165
|
+
)
|
|
91
166
|
process.exit(1)
|
|
92
167
|
}
|
|
93
168
|
|
|
@@ -7803,6 +7803,18 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
7803
7803
|
output: void;
|
|
7804
7804
|
meta: object;
|
|
7805
7805
|
}>;
|
|
7806
|
+
upsert: import("@trpc/server").TRPCMutationProcedure<{
|
|
7807
|
+
input: {
|
|
7808
|
+
id: string;
|
|
7809
|
+
name: string;
|
|
7810
|
+
administrativeAreaId: string | null;
|
|
7811
|
+
validUntil: string | null;
|
|
7812
|
+
locationType: string | null;
|
|
7813
|
+
externalId?: string | null | undefined;
|
|
7814
|
+
};
|
|
7815
|
+
output: void;
|
|
7816
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
7817
|
+
}>;
|
|
7806
7818
|
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
7807
7819
|
input: {
|
|
7808
7820
|
id: string;
|
|
@@ -8234,6 +8246,17 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8234
8246
|
output: void;
|
|
8235
8247
|
meta: object;
|
|
8236
8248
|
}>;
|
|
8249
|
+
upsert: import("@trpc/server").TRPCMutationProcedure<{
|
|
8250
|
+
input: {
|
|
8251
|
+
id: string;
|
|
8252
|
+
name: string;
|
|
8253
|
+
parentId: string | null;
|
|
8254
|
+
validUntil: string | null;
|
|
8255
|
+
externalId?: string | null | undefined;
|
|
8256
|
+
};
|
|
8257
|
+
output: void;
|
|
8258
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8259
|
+
}>;
|
|
8237
8260
|
}>>;
|
|
8238
8261
|
integrations: import("@trpc/server").TRPCBuiltRouter<{
|
|
8239
8262
|
ctx: Partial<{
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|