Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SUSHI --init to avoid publisher errors #899

Merged
merged 5 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/utils/Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,19 @@ export async function init(): Promise<void> {
configDoc.set(field, userValue);
}
});

// And for nested publisher fields
['name', 'url'].forEach(field => {
const userValue = readlineSync.question(
`Publisher ${field.charAt(0).toUpperCase() + field.slice(1)} (Default: ${configDoc
jafeltra marked this conversation as resolved.
Show resolved Hide resolved
.get('publisher')
.get(field)}): `
);
if (userValue) {
configDoc.get('publisher').set(field, userValue);
}
});

// Ensure copyrightYear is accurate
configDoc.set('copyrightYear', `${new Date().getFullYear()}+`);
const projectName = configDoc.get('name');
Expand Down
10 changes: 9 additions & 1 deletion src/utils/init-project/patient.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
// SUSHI will look for definitions in any file using the .fsh ending.
Profile: MyPatient
Parent: Patient
* name 1..* MS
Description: "An example profile of the Patient resource."
* name 1..* MS

Instance: PatientExample
InstanceOf: MyPatient
Description: "An example of a patient with a license to krill."
* name
* given[0] = "James"
* family = "Pond"
3 changes: 3 additions & 0 deletions src/utils/init-project/sushi-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ version: 0.1.0
fhirVersion: 4.0.1
copyrightYear: 2020+
releaseLabel: ci-build
publisher:
name: Example Publisher
url: http://example.org/example-publisher

# ╭────────────────────────────────────────────menu.xml────────────────────────────────────────────╮
# │ To use a provided input/includes/menu.xml file, delete the "menu" property below. │
Expand Down
16 changes: 13 additions & 3 deletions test/utils/Processing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,9 @@ describe('Processing', () => {
['Id (Default: fhir.example): '],
['Canonical (Default: http://example.org): '],
['Status (Default: draft): '],
['Version (Default: 0.1.0): ']
['Version (Default: 0.1.0): '],
['Publisher Name (Default: Example Publisher): '],
['Publisher Url (Default: http://example.org/example-publisher): ']
]);
expect(yesNoSpy.mock.calls).toHaveLength(1);
expect(yesNoSpy.mock.calls[0][0]).toMatch(/Initialize SUSHI project in .*ExampleIG/);
Expand Down Expand Up @@ -1075,6 +1077,10 @@ describe('Processing', () => {
return 'active';
} else if (question.startsWith('Version')) {
return '2.0.0';
} else if (question.startsWith('Publisher Name')) {
return 'SUSHI Chefs';
} else if (question.startsWith('Publisher Url')) {
return 'http://custom-publisher.org';
}
});
await init();
Expand All @@ -1083,7 +1089,9 @@ describe('Processing', () => {
['Id (Default: fhir.example): '],
['Canonical (Default: http://example.org): '],
['Status (Default: draft): '],
['Version (Default: 0.1.0): ']
['Version (Default: 0.1.0): '],
['Publisher Name (Default: Example Publisher): '],
['Publisher Url (Default: http://example.org/example-publisher): ']
]);
expect(yesNoSpy.mock.calls).toHaveLength(1);
expect(yesNoSpy.mock.calls[0][0]).toMatch(/Initialize SUSHI project in .*MyNonDefaultName/);
Expand Down Expand Up @@ -1139,7 +1147,9 @@ describe('Processing', () => {
['Id (Default: fhir.example): '],
['Canonical (Default: http://example.org): '],
['Status (Default: draft): '],
['Version (Default: 0.1.0): ']
['Version (Default: 0.1.0): '],
['Publisher Name (Default: Example Publisher): '],
['Publisher Url (Default: http://example.org/example-publisher): ']
]);
expect(yesNoSpy.mock.calls).toHaveLength(1);
expect(yesNoSpy.mock.calls[0][0]).toMatch(/Initialize SUSHI project in .*ExampleIG/);
Expand Down
3 changes: 3 additions & 0 deletions test/utils/fixtures/init-config/default-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ version: 0.1.0
fhirVersion: 4.0.1
copyrightYear: 2021+
releaseLabel: ci-build
publisher:
name: Example Publisher
url: http://example.org/example-publisher

# ╭────────────────────────────────────────────menu.xml────────────────────────────────────────────╮
# │ To use a provided input/includes/menu.xml file, delete the "menu" property below. │
Expand Down
3 changes: 3 additions & 0 deletions test/utils/fixtures/init-config/user-input-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ version: 2.0.0
fhirVersion: 4.0.1
copyrightYear: 2021+
releaseLabel: ci-build
publisher:
name: SUSHI Chefs
url: http://custom-publisher.org

# ╭────────────────────────────────────────────menu.xml────────────────────────────────────────────╮
# │ To use a provided input/includes/menu.xml file, delete the "menu" property below. │
Expand Down