Skip to content

Commit e3f9d6e

Browse files
cmoeseljduteau
andauthored
Replace _updatePubliser/_genonce w/ _build in sushi init (#1619)
* Replace _updatePubliser/_genonce w/ _build in sushi init New IGs should use the _build.sh/_build.bat scripts now, as the other scripts are no longer maintained. * sushi init: use fhir2.base.template The fhir.base.template is now considered insecure, so use fhir2.base.template instead. See: https://www.fhir.org/guides/security-notices/2026-03-npm-dependencies.html#actions-for-ig-authors --------- Co-authored-by: Jean Duteau <jean@duteaudesign.com>
1 parent 48532f4 commit e3f9d6e

7 files changed

Lines changed: 50 additions & 94 deletions

File tree

src/app.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,9 @@ async function runBuild(input: string, program: OptionValues, helpText: string)
330330
const igExporter = new IGExporter(outPackage, defs, igFilesPath);
331331
igExporter.export(outDir);
332332
logger.info('Assembled Implementation Guide sources; ready for IG Publisher.');
333-
if (
334-
!fs
335-
.readdirSync(outDir)
336-
.some(
337-
file =>
338-
file.startsWith('_genonce') ||
339-
file.startsWith('_updatePublisher') ||
340-
file.startsWith('_build')
341-
)
342-
) {
333+
if (!fs.readdirSync(outDir).some(file => file.startsWith('_build'))) {
343334
logger.info(
344-
'The sample-ig located at https://github.com/FHIR/sample-ig contains scripts useful for downloading and running the IG Publisher.'
335+
'The _build script hosted at https://github.com/HL7/ig-publisher-scripts is useful for downloading and running the IG Publisher.'
345336
);
346337
}
347338
}

src/ig/IGExporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ export class IGExporter {
15081508
);
15091509
}
15101510
if (inputIni.IG.template == null) {
1511-
const templateValue = 'fhir.base.template';
1511+
const templateValue = 'fhir2.base.template';
15121512
inputIni.IG.template = templateValue;
15131513
logger.error(
15141514
`The ig.ini file must have a "template" property. Please update ${filePathString} to include ` +

src/utils/Processing.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -879,14 +879,9 @@ export async function init(
879879
path.join(initProjectDir, 'ignoreWarnings.txt'),
880880
path.join(outputDir, 'input', 'ignoreWarnings.txt')
881881
);
882-
// Add the _updatePublisher, _genonce, and _gencontinuous scripts
883-
console.log('Downloading publisher scripts from https://github.com/HL7/ig-publisher-scripts');
884-
for (const script of [
885-
'_genonce.bat',
886-
'_genonce.sh',
887-
'_updatePublisher.bat',
888-
'_updatePublisher.sh'
889-
]) {
882+
// Add the _build script
883+
console.log('Downloading _build scripts from https://github.com/HL7/ig-publisher-scripts');
884+
for (const script of ['_build.bat', '_build.sh']) {
890885
const url = `https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main/${script}`;
891886
try {
892887
const res = await axiosGet(url);

src/utils/init-project/ig.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[IG]
22
ig = fsh-generated/resources/ImplementationGuide-fhir.example.json
3-
template = fhir.base.template#current
3+
template = fhir2.base.template#current

test/ig/IGExporter.IG.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ describe('IGExporter', () => {
11231123
}
11241124
],
11251125
status: 'active',
1126-
template: 'fhir.base.template',
1126+
template: 'fhir2.base.template',
11271127
fhirVersion: ['4.0.1'],
11281128
language: 'en',
11291129
publisher: 'James Tuna',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[IG]
22
ig = sneaky-input/ImplementationGuide.json
3-
template = fhir.base.template
3+
template = fhir2.base.template

test/utils/Processing.test.ts

Lines changed: 41 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ describe('Processing', () => {
21742174
expect(ensureDirSpy.mock.calls[0][0]).toMatch(/.*ExampleIG.*input.*pagecontent/);
21752175
expect(ensureDirSpy.mock.calls[1][0]).toMatch(/.*ExampleIG.*input.*fsh/);
21762176

2177-
expect(writeSpy.mock.calls).toHaveLength(7);
2177+
expect(writeSpy.mock.calls).toHaveLength(5);
21782178
expect(writeSpy.mock.calls[0][0]).toMatch(/.*index\.md/);
21792179
expect(writeSpy.mock.calls[0][1]).toMatch(/# ExampleIG/);
21802180
expect(writeSpy.mock.calls[1][0]).toMatch(/.*ig\.ini/);
@@ -2195,21 +2195,15 @@ describe('Processing', () => {
21952195
expect(copyFileSpy.mock.calls[1][1]).toMatch(/.*ExampleIG.*\.gitignore/);
21962196
expect(copyFileSpy.mock.calls[2][1]).toMatch(/.*ExampleIG.*input.*ignoreWarnings\.txt/);
21972197

2198-
expect(getSpy.mock.calls).toHaveLength(4);
2198+
expect(getSpy.mock.calls).toHaveLength(2);
21992199
const base = 'https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main/';
2200-
expect(getSpy.mock.calls[0][0]).toBe(base + '_genonce.bat');
2201-
expect(getSpy.mock.calls[1][0]).toBe(base + '_genonce.sh');
2202-
expect(getSpy.mock.calls[2][0]).toBe(base + '_updatePublisher.bat');
2203-
expect(getSpy.mock.calls[3][0]).toBe(base + '_updatePublisher.sh');
2200+
expect(getSpy.mock.calls[0][0]).toBe(base + '_build.bat');
2201+
expect(getSpy.mock.calls[1][0]).toBe(base + '_build.sh');
22042202

2205-
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_genonce\.bat/);
2206-
expect(writeSpy.mock.calls[3][1]).toMatch(/_genonce\.bat/);
2207-
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_genonce\.sh/);
2208-
expect(writeSpy.mock.calls[4][1]).toMatch(/_genonce\.sh/);
2209-
expect(writeSpy.mock.calls[5][0]).toMatch(/.*_updatePublisher\.bat/);
2210-
expect(writeSpy.mock.calls[5][1]).toMatch(/_updatePublisher\.bat/);
2211-
expect(writeSpy.mock.calls[6][0]).toMatch(/.*_updatePublisher\.sh/);
2212-
expect(writeSpy.mock.calls[6][1]).toMatch(/_updatePublisher\.sh/);
2203+
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_build\.bat/);
2204+
expect(writeSpy.mock.calls[3][1]).toMatch(/_build\.bat/);
2205+
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_build\.sh/);
2206+
expect(writeSpy.mock.calls[4][1]).toMatch(/_build\.sh/);
22132207
});
22142208

22152209
it('should initialize a project with user input', async () => {
@@ -2252,7 +2246,7 @@ describe('Processing', () => {
22522246
expect(ensureDirSpy.mock.calls[0][0]).toMatch(/.*MyNonDefaultName.*input.*pagecontent/);
22532247
expect(ensureDirSpy.mock.calls[1][0]).toMatch(/.*MyNonDefaultName.*input.*fsh/);
22542248

2255-
expect(writeSpy.mock.calls).toHaveLength(7);
2249+
expect(writeSpy.mock.calls).toHaveLength(5);
22562250
expect(writeSpy.mock.calls[0][0]).toMatch(/.*index\.md/);
22572251
expect(writeSpy.mock.calls[0][1]).toMatch(/# MyNonDefaultName/);
22582252
expect(writeSpy.mock.calls[1][0]).toMatch(/.*ig\.ini/);
@@ -2274,21 +2268,15 @@ describe('Processing', () => {
22742268
/.*MyNonDefaultName.*input.*ignoreWarnings\.txt/
22752269
);
22762270

2277-
expect(getSpy.mock.calls).toHaveLength(4);
2271+
expect(getSpy.mock.calls).toHaveLength(2);
22782272
const base = 'https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main/';
2279-
expect(getSpy.mock.calls[0][0]).toBe(base + '_genonce.bat');
2280-
expect(getSpy.mock.calls[1][0]).toBe(base + '_genonce.sh');
2281-
expect(getSpy.mock.calls[2][0]).toBe(base + '_updatePublisher.bat');
2282-
expect(getSpy.mock.calls[3][0]).toBe(base + '_updatePublisher.sh');
2273+
expect(getSpy.mock.calls[0][0]).toBe(base + '_build.bat');
2274+
expect(getSpy.mock.calls[1][0]).toBe(base + '_build.sh');
22832275

2284-
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_genonce\.bat/);
2285-
expect(writeSpy.mock.calls[3][1]).toMatch(/_genonce\.bat/);
2286-
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_genonce\.sh/);
2287-
expect(writeSpy.mock.calls[4][1]).toMatch(/_genonce\.sh/);
2288-
expect(writeSpy.mock.calls[5][0]).toMatch(/.*_updatePublisher\.bat/);
2289-
expect(writeSpy.mock.calls[5][1]).toMatch(/_updatePublisher\.bat/);
2290-
expect(writeSpy.mock.calls[6][0]).toMatch(/.*_updatePublisher\.sh/);
2291-
expect(writeSpy.mock.calls[6][1]).toMatch(/_updatePublisher\.sh/);
2276+
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_build\.bat/);
2277+
expect(writeSpy.mock.calls[3][1]).toMatch(/_build\.bat/);
2278+
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_build\.sh/);
2279+
expect(writeSpy.mock.calls[4][1]).toMatch(/_build\.sh/);
22922280
});
22932281

22942282
it('should abort initializing a project when the user does not confirm', async () => {
@@ -2333,7 +2321,7 @@ describe('Processing', () => {
23332321
expect(ensureDirSpy.mock.calls[0][0]).toMatch(/.*MyCLIOptionProject.*input.*pagecontent/);
23342322
expect(ensureDirSpy.mock.calls[1][0]).toMatch(/.*MyCLIOptionProject.*input.*fsh/);
23352323

2336-
expect(writeSpy.mock.calls).toHaveLength(7);
2324+
expect(writeSpy.mock.calls).toHaveLength(5);
23372325
expect(writeSpy.mock.calls[0][0]).toMatch(/.*index\.md/);
23382326
expect(writeSpy.mock.calls[0][1]).toMatch(/# MyCLIOptionProject/);
23392327
expect(writeSpy.mock.calls[1][0]).toMatch(/.*ig\.ini/);
@@ -2356,21 +2344,15 @@ describe('Processing', () => {
23562344
/.*MyCLIOptionProject.*input.*ignoreWarnings\.txt/
23572345
);
23582346

2359-
expect(getSpy.mock.calls).toHaveLength(4);
2347+
expect(getSpy.mock.calls).toHaveLength(2);
23602348
const base = 'https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main/';
2361-
expect(getSpy.mock.calls[0][0]).toBe(base + '_genonce.bat');
2362-
expect(getSpy.mock.calls[1][0]).toBe(base + '_genonce.sh');
2363-
expect(getSpy.mock.calls[2][0]).toBe(base + '_updatePublisher.bat');
2364-
expect(getSpy.mock.calls[3][0]).toBe(base + '_updatePublisher.sh');
2349+
expect(getSpy.mock.calls[0][0]).toBe(base + '_build.bat');
2350+
expect(getSpy.mock.calls[1][0]).toBe(base + '_build.sh');
23652351

2366-
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_genonce\.bat/);
2367-
expect(writeSpy.mock.calls[3][1]).toMatch(/_genonce\.bat/);
2368-
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_genonce\.sh/);
2369-
expect(writeSpy.mock.calls[4][1]).toMatch(/_genonce\.sh/);
2370-
expect(writeSpy.mock.calls[5][0]).toMatch(/.*_updatePublisher\.bat/);
2371-
expect(writeSpy.mock.calls[5][1]).toMatch(/_updatePublisher\.bat/);
2372-
expect(writeSpy.mock.calls[6][0]).toMatch(/.*_updatePublisher\.sh/);
2373-
expect(writeSpy.mock.calls[6][1]).toMatch(/_updatePublisher\.sh/);
2352+
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_build\.bat/);
2353+
expect(writeSpy.mock.calls[3][1]).toMatch(/_build\.bat/);
2354+
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_build\.sh/);
2355+
expect(writeSpy.mock.calls[4][1]).toMatch(/_build\.sh/);
23742356
});
23752357

23762358
it('should prompt for and accept inputs for any option not already set with a command line config option', async () => {
@@ -2412,7 +2394,7 @@ describe('Processing', () => {
24122394
expect(ensureDirSpy.mock.calls[0][0]).toMatch(/.*MySemiCLIOptionProject.*input.*pagecontent/);
24132395
expect(ensureDirSpy.mock.calls[1][0]).toMatch(/.*MySemiCLIOptionProject.*input.*fsh/);
24142396

2415-
expect(writeSpy.mock.calls).toHaveLength(7);
2397+
expect(writeSpy.mock.calls).toHaveLength(5);
24162398
expect(writeSpy.mock.calls[0][0]).toMatch(/.*index\.md/);
24172399
expect(writeSpy.mock.calls[0][1]).toMatch(/# MySemiCLIOptionProject/);
24182400
expect(writeSpy.mock.calls[1][0]).toMatch(/.*ig\.ini/);
@@ -2435,21 +2417,15 @@ describe('Processing', () => {
24352417
/.*MySemiCLIOptionProject.*input.*ignoreWarnings\.txt/
24362418
);
24372419

2438-
expect(getSpy.mock.calls).toHaveLength(4);
2420+
expect(getSpy.mock.calls).toHaveLength(2);
24392421
const base = 'https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main/';
2440-
expect(getSpy.mock.calls[0][0]).toBe(base + '_genonce.bat');
2441-
expect(getSpy.mock.calls[1][0]).toBe(base + '_genonce.sh');
2442-
expect(getSpy.mock.calls[2][0]).toBe(base + '_updatePublisher.bat');
2443-
expect(getSpy.mock.calls[3][0]).toBe(base + '_updatePublisher.sh');
2422+
expect(getSpy.mock.calls[0][0]).toBe(base + '_build.bat');
2423+
expect(getSpy.mock.calls[1][0]).toBe(base + '_build.sh');
24442424

2445-
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_genonce\.bat/);
2446-
expect(writeSpy.mock.calls[3][1]).toMatch(/_genonce\.bat/);
2447-
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_genonce\.sh/);
2448-
expect(writeSpy.mock.calls[4][1]).toMatch(/_genonce\.sh/);
2449-
expect(writeSpy.mock.calls[5][0]).toMatch(/.*_updatePublisher\.bat/);
2450-
expect(writeSpy.mock.calls[5][1]).toMatch(/_updatePublisher\.bat/);
2451-
expect(writeSpy.mock.calls[6][0]).toMatch(/.*_updatePublisher\.sh/);
2452-
expect(writeSpy.mock.calls[6][1]).toMatch(/_updatePublisher\.sh/);
2425+
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_build\.bat/);
2426+
expect(writeSpy.mock.calls[3][1]).toMatch(/_build\.bat/);
2427+
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_build\.sh/);
2428+
expect(writeSpy.mock.calls[4][1]).toMatch(/_build\.sh/);
24532429
});
24542430

24552431
it('should accept remaining defaults without prompting for any options not already set with a command line config option when default option is used', async () => {
@@ -2473,7 +2449,7 @@ describe('Processing', () => {
24732449
);
24742450
expect(ensureDirSpy.mock.calls[1][0]).toMatch(/.*MyCLIOptionWithDefaultsProject.*input.*fsh/);
24752451

2476-
expect(writeSpy.mock.calls).toHaveLength(7);
2452+
expect(writeSpy.mock.calls).toHaveLength(5);
24772453
expect(writeSpy.mock.calls[0][0]).toMatch(/.*index\.md/);
24782454
expect(writeSpy.mock.calls[0][1]).toMatch(/# MyCLIOptionWithDefaultsProject/);
24792455
expect(writeSpy.mock.calls[1][0]).toMatch(/.*ig\.ini/);
@@ -2498,21 +2474,15 @@ describe('Processing', () => {
24982474
/.*MyCLIOptionWithDefaultsProject.*input.*ignoreWarnings\.txt/
24992475
);
25002476

2501-
expect(getSpy.mock.calls).toHaveLength(4);
2477+
expect(getSpy.mock.calls).toHaveLength(2);
25022478
const base = 'https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main/';
2503-
expect(getSpy.mock.calls[0][0]).toBe(base + '_genonce.bat');
2504-
expect(getSpy.mock.calls[1][0]).toBe(base + '_genonce.sh');
2505-
expect(getSpy.mock.calls[2][0]).toBe(base + '_updatePublisher.bat');
2506-
expect(getSpy.mock.calls[3][0]).toBe(base + '_updatePublisher.sh');
2507-
2508-
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_genonce\.bat/);
2509-
expect(writeSpy.mock.calls[3][1]).toMatch(/_genonce\.bat/);
2510-
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_genonce\.sh/);
2511-
expect(writeSpy.mock.calls[4][1]).toMatch(/_genonce\.sh/);
2512-
expect(writeSpy.mock.calls[5][0]).toMatch(/.*_updatePublisher\.bat/);
2513-
expect(writeSpy.mock.calls[5][1]).toMatch(/_updatePublisher\.bat/);
2514-
expect(writeSpy.mock.calls[6][0]).toMatch(/.*_updatePublisher\.sh/);
2515-
expect(writeSpy.mock.calls[6][1]).toMatch(/_updatePublisher\.sh/);
2479+
expect(getSpy.mock.calls[0][0]).toBe(base + '_build.bat');
2480+
expect(getSpy.mock.calls[1][0]).toBe(base + '_build.sh');
2481+
2482+
expect(writeSpy.mock.calls[3][0]).toMatch(/.*_build\.bat/);
2483+
expect(writeSpy.mock.calls[3][1]).toMatch(/_build\.bat/);
2484+
expect(writeSpy.mock.calls[4][0]).toMatch(/.*_build\.sh/);
2485+
expect(writeSpy.mock.calls[4][1]).toMatch(/_build\.sh/);
25162486
});
25172487
});
25182488

0 commit comments

Comments
 (0)