@opencrvs/toolkit 2.0.1-rc.5803153 → 2.0.1-rc.584bd06
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,115 @@ 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
|
+
/**
|
|
41
|
+
* Release tags (e.g. "v2.1.0"), highest first. Delegates the version-aware
|
|
42
|
+
* ordering to git itself rather than hand-parsing semver, then filters down
|
|
43
|
+
* to strict "vX.Y.Z" tags - `--sort=-version:refname` alone still leaves in
|
|
44
|
+
* non-release refs (e.g. "vtesting", "v2.0.0-beta") and peeled annotated-tag
|
|
45
|
+
* lines ("refs/tags/v2.0.0^{}").
|
|
46
|
+
*/
|
|
47
|
+
function listReleaseTags(repoUrl) {
|
|
48
|
+
const output = execSync(
|
|
49
|
+
'git ls-remote --tags --sort=-version:refname ' + repoUrl,
|
|
50
|
+
{ encoding: 'utf-8' }
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return output
|
|
54
|
+
.split('\n')
|
|
55
|
+
.map((line) => line.split('\t')[1])
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.map((ref) => ref.replace('refs/tags/', ''))
|
|
58
|
+
.filter((tag) => /^v\d+\.\d+\.\d+$/.test(tag))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The highest release tag present in *both* repositories - used as the
|
|
63
|
+
* fallback when the version-specific tag can't be found in one or both, so
|
|
64
|
+
* scaffolding still lands on a real, matched release rather than develop.
|
|
65
|
+
*/
|
|
66
|
+
function getLatestCommonReleaseTag() {
|
|
67
|
+
const infrastructureTags = new Set(listReleaseTags(INFRASTRUCTURE_REPO_URL))
|
|
68
|
+
return (
|
|
69
|
+
listReleaseTags(COUNTRYCONFIG_REPO_URL).find((tag) =>
|
|
70
|
+
infrastructureTags.has(tag)
|
|
71
|
+
) || null
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A prerelease-shaped own version (e.g. "2.1.0-rc.f5ea803", what npm resolves
|
|
77
|
+
* `@next` to - a build published from every push to develop) never has a
|
|
78
|
+
* matching release tag, so scaffold straight from develop for both
|
|
79
|
+
* repositories instead of wasting a tag lookup that can only fail.
|
|
80
|
+
*
|
|
81
|
+
* Otherwise, the own "X.Y.Z" version - whether resolved via npm's `latest`
|
|
82
|
+
* dist-tag (bare invocation) or an explicit `@X.Y.Z` pin - scaffolds from the
|
|
83
|
+
* matching "vX.Y.Z" tag when it exists in both repositories. If it doesn't
|
|
84
|
+
* (e.g. `latest` lagging behind the repos, or a pin that predates one repo's
|
|
85
|
+
* tagging), fall back to the highest release tag common to both, rather than
|
|
86
|
+
* a mismatched pairing of one tagged repo at that version and another repo
|
|
87
|
+
* at a different release. Exits with an error if no matching release tag
|
|
88
|
+
* exists in both repositories.
|
|
89
|
+
*/
|
|
90
|
+
function resolveRef() {
|
|
91
|
+
if (version.includes('-')) {
|
|
92
|
+
return 'develop'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const tag = 'v' + version
|
|
96
|
+
if (
|
|
97
|
+
tagExists(COUNTRYCONFIG_REPO_URL, tag) &&
|
|
98
|
+
tagExists(INFRASTRUCTURE_REPO_URL, tag)
|
|
99
|
+
) {
|
|
100
|
+
return tag
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const latestCommonTag = getLatestCommonReleaseTag()
|
|
104
|
+
if (latestCommonTag) {
|
|
105
|
+
console.warn(
|
|
106
|
+
'\nWarning: tag "' +
|
|
107
|
+
tag +
|
|
108
|
+
'" was not found in both repositories; falling back to the latest ' +
|
|
109
|
+
'available release, ' +
|
|
110
|
+
latestCommonTag +
|
|
111
|
+
'.'
|
|
112
|
+
)
|
|
113
|
+
return latestCommonTag
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.error(
|
|
117
|
+
'\nError: no matching release tag was found in both the country config and ' +
|
|
118
|
+
'infrastructure repositories.'
|
|
119
|
+
)
|
|
120
|
+
process.exit(1)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function cloneRepository(repoUrl, ref, targetDir) {
|
|
124
|
+
execSync(
|
|
125
|
+
'git clone --depth 1 --branch ' + ref + ' ' + repoUrl + ' ' + targetDir,
|
|
126
|
+
{ stdio: 'inherit' }
|
|
127
|
+
)
|
|
128
|
+
}
|
|
22
129
|
|
|
23
130
|
const projectName = process.argv[2]
|
|
24
131
|
|
|
@@ -33,31 +140,48 @@ const countryconfigDirName = projectName + '-countryconfig'
|
|
|
33
140
|
const infrastructureDirName = projectName + '-infrastructure'
|
|
34
141
|
|
|
35
142
|
const countryconfigTargetDir = path.resolve(process.cwd(), countryconfigDirName)
|
|
36
|
-
const infrastructureTargetDir = path.resolve(
|
|
143
|
+
const infrastructureTargetDir = path.resolve(
|
|
144
|
+
process.cwd(),
|
|
145
|
+
infrastructureDirName
|
|
146
|
+
)
|
|
37
147
|
|
|
38
148
|
if (fs.existsSync(countryconfigTargetDir)) {
|
|
39
|
-
console.error(
|
|
149
|
+
console.error(
|
|
150
|
+
'Error: Directory "' + countryconfigDirName + '" already exists.'
|
|
151
|
+
)
|
|
40
152
|
process.exit(1)
|
|
41
153
|
}
|
|
42
154
|
|
|
43
155
|
if (fs.existsSync(infrastructureTargetDir)) {
|
|
44
|
-
console.error(
|
|
156
|
+
console.error(
|
|
157
|
+
'Error: Directory "' + infrastructureDirName + '" already exists.'
|
|
158
|
+
)
|
|
45
159
|
process.exit(1)
|
|
46
160
|
}
|
|
47
161
|
|
|
48
|
-
|
|
162
|
+
const ref = resolveRef()
|
|
163
|
+
|
|
164
|
+
console.log(
|
|
165
|
+
'\nScaffolding OpenCRVS country config in ./' + countryconfigDirName + '...\n'
|
|
166
|
+
)
|
|
49
167
|
|
|
50
168
|
try {
|
|
51
|
-
|
|
169
|
+
cloneRepository(COUNTRYCONFIG_REPO_URL, ref, countryconfigDirName)
|
|
52
170
|
} catch (err) {
|
|
53
171
|
console.error('Failed to clone the country config repository:', err.message)
|
|
54
172
|
process.exit(1)
|
|
55
173
|
}
|
|
56
174
|
|
|
57
175
|
try {
|
|
58
|
-
fs.rmSync(path.join(countryconfigTargetDir, '.git'), {
|
|
176
|
+
fs.rmSync(path.join(countryconfigTargetDir, '.git'), {
|
|
177
|
+
recursive: true,
|
|
178
|
+
force: true
|
|
179
|
+
})
|
|
59
180
|
} catch (err) {
|
|
60
|
-
console.error(
|
|
181
|
+
console.error(
|
|
182
|
+
'Failed to remove .git directory from country config:',
|
|
183
|
+
err.message
|
|
184
|
+
)
|
|
61
185
|
process.exit(1)
|
|
62
186
|
}
|
|
63
187
|
|
|
@@ -72,22 +196,34 @@ if (fs.existsSync(pkgPath)) {
|
|
|
72
196
|
process.exit(1)
|
|
73
197
|
}
|
|
74
198
|
} else {
|
|
75
|
-
console.warn(
|
|
199
|
+
console.warn(
|
|
200
|
+
'Warning: No package.json found in the cloned country config repository. Project name was not updated.'
|
|
201
|
+
)
|
|
76
202
|
}
|
|
77
203
|
|
|
78
|
-
console.log(
|
|
204
|
+
console.log(
|
|
205
|
+
'\nScaffolding OpenCRVS infrastructure in ./' +
|
|
206
|
+
infrastructureDirName +
|
|
207
|
+
'...\n'
|
|
208
|
+
)
|
|
79
209
|
|
|
80
210
|
try {
|
|
81
|
-
|
|
211
|
+
cloneRepository(INFRASTRUCTURE_REPO_URL, ref, infrastructureDirName)
|
|
82
212
|
} catch (err) {
|
|
83
213
|
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
84
214
|
process.exit(1)
|
|
85
215
|
}
|
|
86
216
|
|
|
87
217
|
try {
|
|
88
|
-
fs.rmSync(path.join(infrastructureTargetDir, '.git'), {
|
|
218
|
+
fs.rmSync(path.join(infrastructureTargetDir, '.git'), {
|
|
219
|
+
recursive: true,
|
|
220
|
+
force: true
|
|
221
|
+
})
|
|
89
222
|
} catch (err) {
|
|
90
|
-
console.error(
|
|
223
|
+
console.error(
|
|
224
|
+
'Failed to remove .git directory from infrastructure:',
|
|
225
|
+
err.message
|
|
226
|
+
)
|
|
91
227
|
process.exit(1)
|
|
92
228
|
}
|
|
93
229
|
|
|
@@ -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
|