@gefyra/diffyr6-cli 1.0.0 → 1.0.2
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/LICENSE +21 -21
- package/README.md +449 -447
- package/config/README.md +27 -27
- package/config/default-rules.json +135 -135
- package/config/resources-r4-not-in-r6.json +42 -42
- package/package.json +54 -54
- package/src/cli.js +94 -92
- package/src/compare-profiles.js +386 -386
- package/src/config.js +153 -147
- package/src/generate-fsh.js +457 -457
- package/src/index.js +462 -394
- package/src/rules-engine.js +642 -642
- package/src/upgrade-sushi.js +553 -553
- package/src/utils/fs.js +38 -38
- package/src/utils/html.js +28 -28
- package/src/utils/process.js +101 -101
- package/src/utils/removed-resources.js +135 -135
- package/src/utils/sushi-log.js +46 -46
- package/src/utils/validator.js +103 -103
- package/src/utils/zip.js +112 -0
package/src/config.js
CHANGED
|
@@ -1,147 +1,153 @@
|
|
|
1
|
-
import fsp from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import { pathExists } from './utils/fs.js';
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = path.dirname(__filename);
|
|
8
|
-
|
|
9
|
-
export const CONFIG_VERSION = '1.0.
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Default configuration values
|
|
13
|
-
*/
|
|
14
|
-
export const DEFAULT_CONFIG = {
|
|
15
|
-
configVersion: CONFIG_VERSION,
|
|
16
|
-
packageId: null,
|
|
17
|
-
packageVersion: 'current',
|
|
18
|
-
enableGoFSH: true,
|
|
19
|
-
resourcesDir: 'Resources',
|
|
20
|
-
resourcesR6Dir: 'ResourcesR6',
|
|
21
|
-
compareDir: 'compare',
|
|
22
|
-
outputDir: 'output',
|
|
23
|
-
rulesConfigPath: null,
|
|
24
|
-
validatorJarPath: null,
|
|
25
|
-
workdir: null,
|
|
26
|
-
compareMode: 'incremental',
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
import fsp from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { pathExists } from './utils/fs.js';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export const CONFIG_VERSION = '1.0.1';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Default configuration values
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_CONFIG = {
|
|
15
|
+
configVersion: CONFIG_VERSION,
|
|
16
|
+
packageId: null,
|
|
17
|
+
packageVersion: 'current',
|
|
18
|
+
enableGoFSH: true,
|
|
19
|
+
resourcesDir: 'Resources',
|
|
20
|
+
resourcesR6Dir: 'ResourcesR6',
|
|
21
|
+
compareDir: 'compare',
|
|
22
|
+
outputDir: 'output',
|
|
23
|
+
rulesConfigPath: null,
|
|
24
|
+
validatorJarPath: null,
|
|
25
|
+
workdir: null,
|
|
26
|
+
compareMode: 'incremental',
|
|
27
|
+
exportZip: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Loads and validates a configuration file
|
|
32
|
+
*/
|
|
33
|
+
export async function loadConfig(configPath) {
|
|
34
|
+
const raw = await fsp.readFile(configPath, 'utf8');
|
|
35
|
+
const config = JSON.parse(raw);
|
|
36
|
+
|
|
37
|
+
// Validate config version
|
|
38
|
+
validateConfigVersion(config);
|
|
39
|
+
|
|
40
|
+
// Merge with defaults
|
|
41
|
+
const merged = { ...DEFAULT_CONFIG, ...config };
|
|
42
|
+
|
|
43
|
+
// Validate required fields
|
|
44
|
+
validateConfig(merged);
|
|
45
|
+
|
|
46
|
+
return merged;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validates the configuration version
|
|
51
|
+
*/
|
|
52
|
+
function validateConfigVersion(config) {
|
|
53
|
+
if (!config.configVersion) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Missing 'configVersion' field in config. Expected version: ${CONFIG_VERSION}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const [major, minor] = config.configVersion.split('.').map(Number);
|
|
60
|
+
const [expectedMajor] = CONFIG_VERSION.split('.').map(Number);
|
|
61
|
+
|
|
62
|
+
if (major !== expectedMajor) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Incompatible config version: ${config.configVersion}. Expected major version: ${expectedMajor}`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Validates the configuration object
|
|
71
|
+
*/
|
|
72
|
+
function validateConfig(config) {
|
|
73
|
+
const errors = [];
|
|
74
|
+
|
|
75
|
+
if (!config.packageId && config.enableGoFSH) {
|
|
76
|
+
errors.push('packageId is required when enableGoFSH is true');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!config.resourcesDir) {
|
|
80
|
+
errors.push('resourcesDir is required');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!config.resourcesR6Dir) {
|
|
84
|
+
errors.push('resourcesR6Dir is required');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!config.compareDir) {
|
|
88
|
+
errors.push('compareDir is required');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!config.outputDir) {
|
|
92
|
+
errors.push('outputDir is required');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (config.compareMode && !['incremental', 'full'].includes(config.compareMode)) {
|
|
96
|
+
errors.push('compareMode must be either "incremental" or "full"');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (typeof config.exportZip !== 'boolean') {
|
|
100
|
+
errors.push('exportZip must be a boolean');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (errors.length > 0) {
|
|
104
|
+
throw new Error(`Invalid configuration:\n${errors.map(e => ` - ${e}`).join('\n')}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Creates an example configuration file
|
|
110
|
+
*/
|
|
111
|
+
export async function createExampleConfig(outputPath) {
|
|
112
|
+
const example = {
|
|
113
|
+
configVersion: CONFIG_VERSION,
|
|
114
|
+
packageId: 'de.basisprofil.r4',
|
|
115
|
+
packageVersion: '1.5.0',
|
|
116
|
+
enableGoFSH: true,
|
|
117
|
+
resourcesDir: 'Resources',
|
|
118
|
+
resourcesR6Dir: 'ResourcesR6',
|
|
119
|
+
compareDir: 'compare',
|
|
120
|
+
outputDir: 'output',
|
|
121
|
+
rulesConfigPath: null,
|
|
122
|
+
validatorJarPath: null,
|
|
123
|
+
workdir: null,
|
|
124
|
+
compareMode: 'incremental',
|
|
125
|
+
exportZip: true
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
await fsp.writeFile(
|
|
129
|
+
outputPath,
|
|
130
|
+
JSON.stringify(example, null, 2),
|
|
131
|
+
'utf8'
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Loads the default rules configuration
|
|
137
|
+
*/
|
|
138
|
+
export async function loadDefaultRules() {
|
|
139
|
+
const rulesPath = path.join(__dirname, '..', 'config', 'default-rules.json');
|
|
140
|
+
const raw = await fsp.readFile(rulesPath, 'utf8');
|
|
141
|
+
return JSON.parse(raw);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Loads rules from a custom path or falls back to default
|
|
146
|
+
*/
|
|
147
|
+
export async function loadRules(customPath) {
|
|
148
|
+
if (customPath && await pathExists(customPath)) {
|
|
149
|
+
const raw = await fsp.readFile(customPath, 'utf8');
|
|
150
|
+
return JSON.parse(raw);
|
|
151
|
+
}
|
|
152
|
+
return loadDefaultRules();
|
|
153
|
+
}
|