@opencrvs/toolkit 1.9.13-rc.fc5374d → 2.0.0-rc.05c3312
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.
- package/build.sh +13 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/application-config/index.d.ts +2 -0
- package/dist/application-config/index.d.ts.map +1 -0
- package/dist/application-config/index.js +2156 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +4902 -0
- package/dist/commons/api/router.d.ts +3497 -2348
- package/dist/commons/application-config/index.d.ts +84 -0
- package/dist/commons/conditionals/conditionals.d.ts +27 -3
- package/dist/commons/conditionals/validate.d.ts +13 -3
- package/dist/commons/events/ActionConfig.d.ts +415 -1555
- package/dist/commons/events/ActionDocument.d.ts +888 -1941
- package/dist/commons/events/ActionInput.d.ts +277 -1073
- package/dist/commons/events/ActionType.d.ts +91 -11
- package/dist/commons/events/AdvancedSearchConfig.d.ts +294 -1496
- package/dist/commons/events/AuditLog.d.ts +407 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +30 -190
- package/dist/commons/events/Conditional.d.ts +26 -38
- package/dist/commons/events/Constants.d.ts +1 -1
- package/dist/commons/events/CountryConfigQueryInput.d.ts +1592 -4471
- package/dist/commons/events/DeduplicationConfig.d.ts +15 -171
- package/dist/commons/events/Draft.d.ts +72 -107
- package/dist/commons/events/DynamicFieldValue.d.ts +12 -78
- package/dist/commons/events/EventConfig.d.ts +37 -2420
- package/dist/commons/events/EventConfigInput.d.ts +0 -3
- package/dist/commons/events/EventDocument.d.ts +354 -1366
- package/dist/commons/events/EventIndex.d.ts +212 -1010
- package/dist/commons/events/EventInput.d.ts +3 -8
- package/dist/commons/events/EventMetadata.d.ts +130 -357
- package/dist/commons/events/FieldConfig.d.ts +2897 -12892
- package/dist/commons/events/FieldType.d.ts +26 -4
- package/dist/commons/events/FieldTypeMapping.d.ts +314 -906
- package/dist/commons/events/FieldValue.d.ts +149 -527
- package/dist/commons/events/FileUtils.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +67 -0
- package/dist/commons/events/FormConfig.d.ts +54 -721
- package/dist/commons/events/PageConfig.d.ts +58 -320
- package/dist/commons/events/PlainDate.d.ts +1 -1
- package/dist/commons/events/SummaryConfig.d.ts +14 -161
- package/dist/commons/events/TemplateConfig.d.ts +2 -3
- package/dist/commons/events/TranslationConfig.d.ts +2 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +74 -37
- package/dist/commons/events/WorkqueueConfig.d.ts +2208 -7553
- package/dist/commons/events/deduplication.d.ts +3 -3
- package/dist/commons/events/defineConfig.d.ts +2 -247
- package/dist/commons/events/eventConfigValidation.d.ts +8 -0
- package/dist/commons/events/index.d.ts +3 -0
- package/dist/commons/events/locations.d.ts +73 -20
- package/dist/commons/events/scopes.d.ts +36 -35
- package/dist/commons/events/state/availableActions.d.ts +7 -2
- package/dist/commons/events/state/flags.d.ts +21 -3
- package/dist/commons/events/state/index.d.ts +30 -27
- package/dist/commons/events/state/utils.d.ts +190 -172
- package/dist/commons/events/test.utils.d.ts +52 -11
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +373 -273
- package/dist/commons/notification/UserNotifications.d.ts +76 -637
- package/dist/conditionals/index.d.ts.map +1 -1
- package/dist/conditionals/index.js +330 -14
- package/dist/events/deduplication.d.ts +3 -3
- package/dist/events/index.js +2930 -2118
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +404 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +22 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
- package/dist/migrations/v2.0/checkout-upstream-files.js +147 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +828 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +158 -0
- package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
- package/dist/migrations/v2.0/create-events-index.js +325 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
- package/dist/migrations/v2.0/index.d.ts +11 -0
- package/dist/migrations/v2.0/index.d.ts.map +1 -0
- package/dist/migrations/v2.0/index.js +4812 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +343 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-scopes.js +281 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +267 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +236 -0
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-delete-actions.js +156 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-demo-scope.js +74 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-deprecated-imports.js +96 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.js +77 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +109 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-review-from-register-action.js +163 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
- package/dist/migrations/v2.0/rename-api-paths.js +187 -0
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
- package/dist/migrations/v2.0/rename-location-parent-id.js +180 -0
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +195 -0
- package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
- package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
- package/dist/migrations/v2.0/update-package-json.js +105 -0
- package/dist/notification/index.d.ts.map +1 -1
- package/dist/notification/index.js +2110 -1767
- package/dist/scopes/index.d.ts +711 -352
- package/dist/scopes/index.d.ts.map +1 -1
- package/dist/scopes/index.js +372 -299
- package/opencrvs-toolkit-2.0.0-rc.05c3312.tgz +0 -0
- package/package.json +18 -8
- package/tsconfig.json +12 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/commons/events/CreatedAtLocation.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-built-in-validate-actions-custom.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/make-built-in-validate-actions-custom.ts"],"names":[],"mappings":"AA2WA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.main = main;
|
|
26
|
+
/**
|
|
27
|
+
* Codemod: Transform `VALIDATE` type actions into `CUSTOM` actions inside `defineConfig` calls.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/make-built-in-validate-actions-custom.ts
|
|
31
|
+
*
|
|
32
|
+
* What it does:
|
|
33
|
+
* - Scans all TypeScript files under `src/`
|
|
34
|
+
* - Finds every `defineConfig({ ... })` call expression
|
|
35
|
+
* - Inside the `actions` array of that config, locates object literals
|
|
36
|
+
* whose `type` property resolves to `ActionType.VALIDATE` or the string literal `"VALIDATE"`
|
|
37
|
+
* - Changes the `type` value to `ActionType.CUSTOM` (or `"CUSTOM"` for string literals)
|
|
38
|
+
* - Adds a `customActionType: 'VALIDATE_DECLARATION'` property to those objects
|
|
39
|
+
* - Adds an `auditHistoryLabel` intl descriptor whose `id` is derived from the
|
|
40
|
+
* root `type` value of the `defineConfig` config object
|
|
41
|
+
* - Removes the `deduplication` property from those objects
|
|
42
|
+
* - Replaces `review: { fields: <value> }` with `form: <value>`, or
|
|
43
|
+
* `review: <expr>` with `form: <expr>.fields` when the value is not an inline object
|
|
44
|
+
* - Saves the modified files in-place
|
|
45
|
+
*/
|
|
46
|
+
const ts_morph_1 = require("ts-morph");
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
48
|
+
const TOOLKIT_EVENTS_MODULE = '@opencrvs/toolkit/events';
|
|
49
|
+
const REQUIRED_SYMBOLS = [
|
|
50
|
+
'ConditionalType',
|
|
51
|
+
'and',
|
|
52
|
+
'status',
|
|
53
|
+
'not',
|
|
54
|
+
'flag',
|
|
55
|
+
'InherentFlags'
|
|
56
|
+
];
|
|
57
|
+
function ensureImports(sourceFile) {
|
|
58
|
+
const existingImport = sourceFile.getImportDeclaration((decl) => decl.getModuleSpecifierValue() === TOOLKIT_EVENTS_MODULE);
|
|
59
|
+
if (existingImport) {
|
|
60
|
+
const existingNames = new Set(existingImport.getNamedImports().map((ni) => ni.getName()));
|
|
61
|
+
for (const name of REQUIRED_SYMBOLS) {
|
|
62
|
+
if (!existingNames.has(name)) {
|
|
63
|
+
existingImport.addNamedImport(name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
sourceFile.addImportDeclaration({
|
|
69
|
+
moduleSpecifier: TOOLKIT_EVENTS_MODULE,
|
|
70
|
+
namedImports: REQUIRED_SYMBOLS
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
75
|
+
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
76
|
+
const TYPE_PROPERTY_NAME = 'type';
|
|
77
|
+
const CUSTOM_ACTION_TYPE_PROPERTY_NAME = 'customActionType';
|
|
78
|
+
const AUDIT_HISTORY_LABEL_PROPERTY_NAME = 'auditHistoryLabel';
|
|
79
|
+
const DEDUPLICATION_PROPERTY_NAME = 'deduplication';
|
|
80
|
+
const REVIEW_PROPERTY_NAME = 'review';
|
|
81
|
+
const FIELDS_PROPERTY_NAME = 'fields';
|
|
82
|
+
const FORM_PROPERTY_NAME = 'form';
|
|
83
|
+
const ACTION_TYPE_ENUM_NAME = 'ActionType';
|
|
84
|
+
const VALIDATE_MEMBER_NAME = 'VALIDATE';
|
|
85
|
+
const CUSTOM_MEMBER_NAME = 'CUSTOM';
|
|
86
|
+
const VALIDATE_STRING_LITERAL = 'VALIDATE';
|
|
87
|
+
const CUSTOM_STRING_LITERAL = 'CUSTOM';
|
|
88
|
+
const VALIDATE_DECLARATION_VALUE = 'VALIDATE_DECLARATION';
|
|
89
|
+
function isValidateType(typeInitializer) {
|
|
90
|
+
// Matches: ActionType.VALIDATE
|
|
91
|
+
if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.PropertyAccessExpression) {
|
|
92
|
+
const propAccess = typeInitializer.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAccessExpression);
|
|
93
|
+
const obj = propAccess.getExpression();
|
|
94
|
+
const member = propAccess.getName();
|
|
95
|
+
return (ts_morph_1.Node.isIdentifier(obj) &&
|
|
96
|
+
obj.getText() === ACTION_TYPE_ENUM_NAME &&
|
|
97
|
+
member === VALIDATE_MEMBER_NAME);
|
|
98
|
+
}
|
|
99
|
+
// Matches: "VALIDATE"
|
|
100
|
+
if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.StringLiteral) {
|
|
101
|
+
return (typeInitializer
|
|
102
|
+
.asKindOrThrow(ts_morph_1.SyntaxKind.StringLiteral)
|
|
103
|
+
.getLiteralValue() === VALIDATE_STRING_LITERAL);
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
function resolveEventType(configArg) {
|
|
108
|
+
const typeProperty = configArg.getProperty(TYPE_PROPERTY_NAME);
|
|
109
|
+
if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
|
|
110
|
+
return null;
|
|
111
|
+
const initializer = typeProperty.getInitializer();
|
|
112
|
+
if (!initializer)
|
|
113
|
+
return null;
|
|
114
|
+
// 'birth' / 'death' etc. — use the literal value directly
|
|
115
|
+
if (ts_morph_1.Node.isStringLiteral(initializer)) {
|
|
116
|
+
return initializer.getLiteralValue().toLowerCase();
|
|
117
|
+
}
|
|
118
|
+
// EventType.BIRTH — extract and lowercase the member name
|
|
119
|
+
if (initializer.getKind() === ts_morph_1.SyntaxKind.PropertyAccessExpression &&
|
|
120
|
+
ts_morph_1.Node.isPropertyAccessExpression(initializer)) {
|
|
121
|
+
return initializer.getName().toLowerCase();
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function transformValidateActionToCustom(obj, eventType) {
|
|
126
|
+
const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
|
|
127
|
+
if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const typeInitializer = typeProperty.getInitializer();
|
|
131
|
+
if (!typeInitializer || !isValidateType(typeInitializer)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
// Replace the type value: ActionType.VALIDATE -> ActionType.CUSTOM, "VALIDATE" -> "CUSTOM"
|
|
135
|
+
if (typeInitializer.getKind() === ts_morph_1.SyntaxKind.PropertyAccessExpression) {
|
|
136
|
+
typeInitializer.replaceWithText(`${ACTION_TYPE_ENUM_NAME}.${CUSTOM_MEMBER_NAME}`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
typeInitializer.replaceWithText(`'${CUSTOM_STRING_LITERAL}'`);
|
|
140
|
+
}
|
|
141
|
+
// Add customActionType: 'VALIDATE_DECLARATION' if not already present
|
|
142
|
+
if (!obj.getProperty(CUSTOM_ACTION_TYPE_PROPERTY_NAME)) {
|
|
143
|
+
obj.addPropertyAssignment({
|
|
144
|
+
name: CUSTOM_ACTION_TYPE_PROPERTY_NAME,
|
|
145
|
+
initializer: `'${VALIDATE_DECLARATION_VALUE}'`
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Add auditHistoryLabel intl descriptor if not already present
|
|
149
|
+
if (!obj.getProperty(AUDIT_HISTORY_LABEL_PROPERTY_NAME)) {
|
|
150
|
+
const messageId = `event.${eventType}.custom.action.validate-declaration.audit-history-label`;
|
|
151
|
+
obj.addPropertyAssignment({
|
|
152
|
+
name: AUDIT_HISTORY_LABEL_PROPERTY_NAME,
|
|
153
|
+
initializer: `{
|
|
154
|
+
defaultMessage: 'Validated',
|
|
155
|
+
description: 'The label to show in audit history for the validate action',
|
|
156
|
+
id: '${messageId}'
|
|
157
|
+
}`
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Add supportingCopy intl descriptor if not already present
|
|
161
|
+
if (!obj.getProperty('supportingCopy')) {
|
|
162
|
+
const supportingCopyId = `event.${eventType}.custom.action.validate-declaration.supportingCopy`;
|
|
163
|
+
obj.addPropertyAssignment({
|
|
164
|
+
name: 'supportingCopy',
|
|
165
|
+
initializer: `{
|
|
166
|
+
defaultMessage:
|
|
167
|
+
'Approving this declaration confirms it as legally accepted and eligible for registration.',
|
|
168
|
+
description:
|
|
169
|
+
'This is the supporting copy for the Validate declaration -action',
|
|
170
|
+
id: '${supportingCopyId}'
|
|
171
|
+
}`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
// Add conditionals if not already present
|
|
175
|
+
if (!obj.getProperty('conditionals')) {
|
|
176
|
+
obj.addPropertyAssignment({
|
|
177
|
+
name: 'conditionals',
|
|
178
|
+
initializer: `[
|
|
179
|
+
{
|
|
180
|
+
type: ConditionalType.SHOW,
|
|
181
|
+
conditional: and(status('DECLARED'), not(flag('validated')))
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
type: ConditionalType.ENABLE,
|
|
185
|
+
conditional: not(flag(InherentFlags.POTENTIAL_DUPLICATE))
|
|
186
|
+
}
|
|
187
|
+
]`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// Add flags if not already present
|
|
191
|
+
if (!obj.getProperty('flags')) {
|
|
192
|
+
obj.addPropertyAssignment({
|
|
193
|
+
name: 'flags',
|
|
194
|
+
initializer: `[{ id: 'validated', operation: 'add' }]`
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// Remove the `deduplication` property if present
|
|
198
|
+
const deduplicationProperty = obj.getProperty(DEDUPLICATION_PROPERTY_NAME);
|
|
199
|
+
if (deduplicationProperty) {
|
|
200
|
+
deduplicationProperty.remove();
|
|
201
|
+
}
|
|
202
|
+
// Replace `review` with `form`:
|
|
203
|
+
// - `review: { fields: <value> }` → `form: <value>`
|
|
204
|
+
// - `review: <expr>` → `form: <expr>.fields`
|
|
205
|
+
const reviewProperty = obj.getProperty(REVIEW_PROPERTY_NAME);
|
|
206
|
+
if (reviewProperty && ts_morph_1.Node.isPropertyAssignment(reviewProperty)) {
|
|
207
|
+
const reviewInitializer = reviewProperty.getInitializer();
|
|
208
|
+
if (reviewInitializer) {
|
|
209
|
+
if (ts_morph_1.Node.isObjectLiteralExpression(reviewInitializer)) {
|
|
210
|
+
// Inline object: extract the `fields` value directly
|
|
211
|
+
const fieldsProperty = reviewInitializer.getProperty(FIELDS_PROPERTY_NAME);
|
|
212
|
+
if (fieldsProperty && ts_morph_1.Node.isPropertyAssignment(fieldsProperty)) {
|
|
213
|
+
const fieldsInitializer = fieldsProperty.getInitializer();
|
|
214
|
+
if (fieldsInitializer) {
|
|
215
|
+
reviewProperty.set({
|
|
216
|
+
name: FORM_PROPERTY_NAME,
|
|
217
|
+
initializer: fieldsInitializer.getText()
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
// Reference or other expression: append `.fields`
|
|
224
|
+
reviewProperty.set({
|
|
225
|
+
name: FORM_PROPERTY_NAME,
|
|
226
|
+
initializer: `${reviewInitializer.getText()}.fields`
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
function processFile(filePath, project) {
|
|
234
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
235
|
+
if (!sourceFile)
|
|
236
|
+
return 0;
|
|
237
|
+
let transformedCount = 0;
|
|
238
|
+
// Find all call expressions named `defineConfig`
|
|
239
|
+
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
240
|
+
for (const call of callExpressions) {
|
|
241
|
+
const expression = call.getExpression();
|
|
242
|
+
// Only interested in bare `defineConfig(...)` calls
|
|
243
|
+
if (!ts_morph_1.Node.isIdentifier(expression) ||
|
|
244
|
+
expression.getText() !== DEFINE_CONFIG_NAME) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const args = call.getArguments();
|
|
248
|
+
if (args.length === 0)
|
|
249
|
+
continue;
|
|
250
|
+
// The first argument should be the config object literal
|
|
251
|
+
const configArg = args[0];
|
|
252
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
|
|
253
|
+
continue;
|
|
254
|
+
// Find the `actions` property inside the config object
|
|
255
|
+
const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
|
|
256
|
+
if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
|
|
257
|
+
continue;
|
|
258
|
+
const actionsInitializer = actionsProperty.getInitializer();
|
|
259
|
+
if (!actionsInitializer ||
|
|
260
|
+
!ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
|
|
261
|
+
continue;
|
|
262
|
+
// Resolve the root event type for use in the auditHistoryLabel id
|
|
263
|
+
const eventType = resolveEventType(configArg);
|
|
264
|
+
if (!eventType) {
|
|
265
|
+
console.warn(` [${path_1.default.relative(process.cwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig — skipping auditHistoryLabel id generation`);
|
|
266
|
+
}
|
|
267
|
+
// Iterate over every element in the `actions` array
|
|
268
|
+
let fileNeedsImports = false;
|
|
269
|
+
let configHadValidateAction = false;
|
|
270
|
+
for (const element of actionsInitializer.getElements()) {
|
|
271
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(element))
|
|
272
|
+
continue;
|
|
273
|
+
const wasTransformed = transformValidateActionToCustom(element, eventType !== null && eventType !== void 0 ? eventType : 'unknown');
|
|
274
|
+
if (wasTransformed) {
|
|
275
|
+
transformedCount++;
|
|
276
|
+
fileNeedsImports = true;
|
|
277
|
+
configHadValidateAction = true;
|
|
278
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Add top-level flags array to the config object if a VALIDATE action was found
|
|
282
|
+
if (configHadValidateAction && !configArg.getProperty('flags')) {
|
|
283
|
+
const resolvedEventType = eventType !== null && eventType !== void 0 ? eventType : 'unknown';
|
|
284
|
+
configArg.addPropertyAssignment({
|
|
285
|
+
name: 'flags',
|
|
286
|
+
initializer: `[
|
|
287
|
+
{
|
|
288
|
+
id: 'validated',
|
|
289
|
+
label: {
|
|
290
|
+
id: 'event.${resolvedEventType}.flag.validated',
|
|
291
|
+
defaultMessage: 'Validated',
|
|
292
|
+
description: 'Flag label for validated'
|
|
293
|
+
},
|
|
294
|
+
requiresAction: true
|
|
295
|
+
}
|
|
296
|
+
]`
|
|
297
|
+
});
|
|
298
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Added top-level 'flags' array to defineConfig`);
|
|
299
|
+
}
|
|
300
|
+
if (fileNeedsImports) {
|
|
301
|
+
ensureImports(sourceFile);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return transformedCount;
|
|
305
|
+
}
|
|
306
|
+
function main() {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
309
|
+
console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
|
|
310
|
+
const project = new ts_morph_1.Project({
|
|
311
|
+
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
312
|
+
// Do not emit — we only manipulate source files
|
|
313
|
+
skipAddingFilesFromTsConfig: false
|
|
314
|
+
});
|
|
315
|
+
// Restrict to source files only (exclude node_modules, build artefacts, etc.)
|
|
316
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
317
|
+
const fp = sf.getFilePath();
|
|
318
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
319
|
+
});
|
|
320
|
+
console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
|
|
321
|
+
let totalTransformed = 0;
|
|
322
|
+
const modifiedFiles = [];
|
|
323
|
+
for (const sourceFile of sourceFiles) {
|
|
324
|
+
const filePath = sourceFile.getFilePath();
|
|
325
|
+
const transformed = processFile(filePath, project);
|
|
326
|
+
if (transformed > 0) {
|
|
327
|
+
totalTransformed += transformed;
|
|
328
|
+
modifiedFiles.push(filePath);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (modifiedFiles.length === 0) {
|
|
332
|
+
console.log('No VALIDATE actions found inside defineConfig calls. Nothing to do.');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
|
|
336
|
+
for (const filePath of modifiedFiles) {
|
|
337
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
338
|
+
yield sourceFile.save();
|
|
339
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
340
|
+
}
|
|
341
|
+
console.log(`\nDone. Transformed ${totalTransformed} VALIDATE action(s) to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'.`);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/merge-infrastructure-directory.ts"],"names":[],"mappings":"AAsHA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAkInC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.main = main;
|
|
23
|
+
/**
|
|
24
|
+
* Codemod: Merge upstream changes into the local `infrastructure/` directory
|
|
25
|
+
* from opencrvs/opencrvs-countryconfig.
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* ts-node -r tsconfig-paths/register src/migrations/v2.0/merge-infrastructure-directory.ts
|
|
29
|
+
*
|
|
30
|
+
* What it does:
|
|
31
|
+
* 1. Registers a temporary git remote that points at the canonical
|
|
32
|
+
* opencrvs-countryconfig repository and fetches both:
|
|
33
|
+
* - the upstream "theirs" branch (v2.0) → `UPSTREAM_BRANCH`
|
|
34
|
+
* - the synthetic merge-base branch (latest 1.9 release line)
|
|
35
|
+
* → `BASE_BRANCH`
|
|
36
|
+
* 2. For every file under `infrastructure/` on upstream "theirs", performs
|
|
37
|
+
* a file-scoped 3-way merge:
|
|
38
|
+
* - new file on upstream → checked out and staged
|
|
39
|
+
* - existing file → 3-way merged in place via `git merge-file`,
|
|
40
|
+
* using the BASE_BRANCH version of the file
|
|
41
|
+
* as the ancestor (or an empty file if the
|
|
42
|
+
* base doesn't have it)
|
|
43
|
+
* Files local to the country config that don't exist on upstream are
|
|
44
|
+
* left untouched.
|
|
45
|
+
* 3. Cleanly merged files are staged. Files with conflicts are left in the
|
|
46
|
+
* working tree with standard <<<<<<< / ======= / >>>>>>> markers and
|
|
47
|
+
* MUST be resolved manually by the developer.
|
|
48
|
+
* 4. Removes the temporary remote in all cases (success, failure, or
|
|
49
|
+
* unexpected error) via a `finally` block.
|
|
50
|
+
*
|
|
51
|
+
* Why a content-based synthetic merge-base instead of `git merge-base`:
|
|
52
|
+
* - Country config repos rarely share git history with
|
|
53
|
+
* opencrvs-countryconfig (squashed forks, template-cloned repos, etc.),
|
|
54
|
+
* so `git merge-base HEAD upstream/develop` typically returns nothing.
|
|
55
|
+
* - With no merge-base, a 3-way merge degenerates to a 2-way diff against
|
|
56
|
+
* an empty file — every line that differs becomes a conflict.
|
|
57
|
+
* - `release-v1.9` is the latest 1.9.x release line on upstream and is a
|
|
58
|
+
* near-perfect representation of "what `infrastructure/` looked like
|
|
59
|
+
* before v2.0", regardless of whether the fork's git history reaches it.
|
|
60
|
+
* - For files the country config never modified relative to that baseline,
|
|
61
|
+
* `git merge-file` resolves cleanly to upstream's v2.0 version. Conflicts
|
|
62
|
+
* are produced only where local edits genuinely overlap with v1.9 → v2.0
|
|
63
|
+
* upstream edits — which is what the developer needs to review anyway.
|
|
64
|
+
*
|
|
65
|
+
* Why per-file merge instead of a real `git merge`:
|
|
66
|
+
* - Limits the blast radius to `infrastructure/` only — no other paths
|
|
67
|
+
* are touched.
|
|
68
|
+
* - Doesn't put the repository into an in-progress merge state
|
|
69
|
+
* (no MERGE_HEAD), so subsequent codemods/commands behave normally.
|
|
70
|
+
* - Works regardless of whether the local repo shares history with
|
|
71
|
+
* opencrvs-countryconfig.
|
|
72
|
+
*
|
|
73
|
+
* Caveats:
|
|
74
|
+
* - Local edits to merged files may be overwritten where they overlap
|
|
75
|
+
* with upstream changes. Run on a clean working tree.
|
|
76
|
+
* - Requires git to be installed and network access to github.com.
|
|
77
|
+
* - Requires the country config working directory to be a git repo.
|
|
78
|
+
* - Binary files in `infrastructure/` are not merged textually; if both
|
|
79
|
+
* sides changed a binary file, the result will be invalid and a warning
|
|
80
|
+
* is printed.
|
|
81
|
+
* - Forks that are on a much older 1.9.x and never merged later 1.9 patches
|
|
82
|
+
* may see a few extra conflicts on files where 1.9.x → release-v1.9
|
|
83
|
+
* patches and v1.9 → v2.0 changes textually overlap.
|
|
84
|
+
*/
|
|
85
|
+
const child_process_1 = require("child_process");
|
|
86
|
+
const fs_1 = require("fs");
|
|
87
|
+
const os_1 = require("os");
|
|
88
|
+
const path_1 = require("path");
|
|
89
|
+
const checkout_upstream_files_1 = require("./checkout-upstream-files");
|
|
90
|
+
// Distinct from the remote used by `checkout-upstream-files` so that a stale
|
|
91
|
+
// remote left behind by an aborted run of one codemod doesn't trip up the
|
|
92
|
+
// other.
|
|
93
|
+
const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod-merge-infra';
|
|
94
|
+
const INFRASTRUCTURE_DIR = 'infrastructure';
|
|
95
|
+
// Synthetic merge-base: the tip of upstream's latest 1.9.x release line.
|
|
96
|
+
// We use this branch's content as the "common ancestor" for every file,
|
|
97
|
+
// since most country forks don't share git history with upstream.
|
|
98
|
+
const BASE_BRANCH = 'release-v1.9';
|
|
99
|
+
/**
|
|
100
|
+
* Reads `git show <ref>:<path>` as a Uint8Array (binary-safe).
|
|
101
|
+
* Returns `null` if the path doesn't exist at that ref.
|
|
102
|
+
*/
|
|
103
|
+
function gitShowBytes(ref, path) {
|
|
104
|
+
try {
|
|
105
|
+
const buf = (0, child_process_1.execFileSync)('git', ['show', `${ref}:${path}`], {
|
|
106
|
+
cwd: process.cwd(),
|
|
107
|
+
stdio: ['ignore', 'pipe', 'pipe']
|
|
108
|
+
});
|
|
109
|
+
// Return a plain Uint8Array view to satisfy strict typings of `fs`
|
|
110
|
+
// (which want `ArrayBufferView`, not Node's `Buffer` subtype).
|
|
111
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
112
|
+
}
|
|
113
|
+
catch (_a) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
118
|
+
function main() {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
console.log(`Merging '${INFRASTRUCTURE_DIR}/' from ${checkout_upstream_files_1.UPSTREAM_URL}@${checkout_upstream_files_1.UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...\n`);
|
|
121
|
+
(0, checkout_upstream_files_1.assertIsGitRepo)();
|
|
122
|
+
// Best-effort cleanup of a stale temp remote from a previous aborted run.
|
|
123
|
+
(0, checkout_upstream_files_1.tryGit)(['remote', 'remove', TEMP_REMOTE]);
|
|
124
|
+
try {
|
|
125
|
+
console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${checkout_upstream_files_1.UPSTREAM_URL}`);
|
|
126
|
+
(0, checkout_upstream_files_1.runGit)(['remote', 'add', TEMP_REMOTE, checkout_upstream_files_1.UPSTREAM_URL], { silent: true });
|
|
127
|
+
// Fetch both branches at depth=1 — we only need their tip contents,
|
|
128
|
+
// not their history (the merge is content-based, not history-based).
|
|
129
|
+
console.log(` Fetching ${TEMP_REMOTE}/{${checkout_upstream_files_1.UPSTREAM_BRANCH},${BASE_BRANCH}} (depth 1)...`);
|
|
130
|
+
(0, checkout_upstream_files_1.runGit)(['fetch', '--depth=1', TEMP_REMOTE, checkout_upstream_files_1.UPSTREAM_BRANCH, BASE_BRANCH]);
|
|
131
|
+
const ref = `${TEMP_REMOTE}/${checkout_upstream_files_1.UPSTREAM_BRANCH}`;
|
|
132
|
+
const baseRef = `${TEMP_REMOTE}/${BASE_BRANCH}`;
|
|
133
|
+
// -z gives NUL-separated paths so filenames with spaces or newlines
|
|
134
|
+
// survive the round-trip.
|
|
135
|
+
const upstreamFiles = (0, checkout_upstream_files_1.runGit)([
|
|
136
|
+
'ls-tree',
|
|
137
|
+
'-r',
|
|
138
|
+
'--name-only',
|
|
139
|
+
'-z',
|
|
140
|
+
ref,
|
|
141
|
+
'--',
|
|
142
|
+
`${INFRASTRUCTURE_DIR}/`
|
|
143
|
+
], { silent: true })
|
|
144
|
+
.split('\0')
|
|
145
|
+
.filter(Boolean);
|
|
146
|
+
if (upstreamFiles.length === 0) {
|
|
147
|
+
console.log(` No files found under '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const tmpDir = (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), 'opencrvs-merge-infra-'));
|
|
151
|
+
const baseTmp = (0, path_1.join)(tmpDir, 'base');
|
|
152
|
+
const theirsTmp = (0, path_1.join)(tmpDir, 'theirs');
|
|
153
|
+
let added = 0;
|
|
154
|
+
let merged = 0;
|
|
155
|
+
const conflictedFiles = [];
|
|
156
|
+
for (const file of upstreamFiles) {
|
|
157
|
+
const fullPath = (0, path_1.join)(process.cwd(), file);
|
|
158
|
+
if (!(0, fs_1.existsSync)(fullPath)) {
|
|
159
|
+
// New upstream file — `git checkout` handles binary correctly and
|
|
160
|
+
// stages the result, matching the UX of `checkout-upstream-files`.
|
|
161
|
+
if ((0, checkout_upstream_files_1.tryGit)(['checkout', ref, '--', file])) {
|
|
162
|
+
console.log(` + ${file} (new from upstream)`);
|
|
163
|
+
added++;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
console.warn(` [warn] failed to add new file ${file}`);
|
|
167
|
+
}
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const theirContents = gitShowBytes(ref, file);
|
|
171
|
+
if (theirContents === null) {
|
|
172
|
+
// Shouldn't happen — `ls-tree` just told us the file is there.
|
|
173
|
+
console.warn(` [warn] could not read ${file} from ${ref} — skipping.`);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
(0, fs_1.writeFileSync)(theirsTmp, theirContents);
|
|
177
|
+
// Pull the base version from upstream's latest 1.9 release line. If
|
|
178
|
+
// the file didn't exist there yet (added in v2.0), fall back to an
|
|
179
|
+
// empty base — `git merge-file` will then treat any local content as
|
|
180
|
+
// a local addition.
|
|
181
|
+
const baseContents = gitShowBytes(baseRef, file);
|
|
182
|
+
(0, fs_1.writeFileSync)(baseTmp, baseContents !== null && baseContents !== void 0 ? baseContents : new Uint8Array(0));
|
|
183
|
+
// `git merge-file` does an in-place 3-way merge. Exit codes:
|
|
184
|
+
// 0 → clean merge
|
|
185
|
+
// 1..N → that many conflicts; markers written into the file
|
|
186
|
+
// <0/127 → error (e.g. binary file rejected)
|
|
187
|
+
try {
|
|
188
|
+
(0, child_process_1.execFileSync)('git', ['merge-file', fullPath, baseTmp, theirsTmp], {
|
|
189
|
+
cwd: process.cwd(),
|
|
190
|
+
stdio: ['ignore', 'pipe', 'pipe']
|
|
191
|
+
});
|
|
192
|
+
(0, checkout_upstream_files_1.runGit)(['add', '--', file], { silent: true });
|
|
193
|
+
merged++;
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
const status = err.status;
|
|
197
|
+
if (typeof status === 'number' && status > 0) {
|
|
198
|
+
conflictedFiles.push(file);
|
|
199
|
+
console.warn(` ! ${file} (${status} conflict${status > 1 ? 's' : ''})`);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
conflictedFiles.push(file);
|
|
203
|
+
console.warn(` [warn] merge failed for ${file} (likely binary or unreadable) — left untouched.`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
console.log(`\n Done. ${added} added, ${merged} merged cleanly, ${conflictedFiles.length} with conflicts.`);
|
|
208
|
+
if (conflictedFiles.length > 0) {
|
|
209
|
+
console.warn(`\n NOTE: ${conflictedFiles.length} file(s) under '${INFRASTRUCTURE_DIR}/' have merge conflicts that you must resolve manually.\n` +
|
|
210
|
+
` Look for the standard conflict markers (<<<<<<<, =======, >>>>>>>) in:\n` +
|
|
211
|
+
conflictedFiles.map((f) => ` - ${f}`).join('\n') +
|
|
212
|
+
`\n After resolving, stage the fixes with: git add ${INFRASTRUCTURE_DIR}/`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
if ((0, checkout_upstream_files_1.tryGit)(['remote', 'remove', TEMP_REMOTE])) {
|
|
217
|
+
console.log(` Removed temporary remote '${TEMP_REMOTE}'.`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-application-config-url.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-application-config-url.ts"],"names":[],"mappings":"AAwUA,iBAAe,IAAI,kBAqElB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|