Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 4.1.0 IN PROGRESS

* Populate module descriptor's `name` field with module-name if `description` is missing. Refs STCLI-272.
* Populate module descriptor's `metadata` field with remaining `stripes` properties. Refs STCLI-274.

## [4.0.0](https://github.com/folio-org/stripes-cli/tree/v4.0.0) (2025-02-24)
[Full Changelog](https://github.com/folio-org/stripes-cli/compare/v3.2.0...v4.0.0)
Expand Down
7 changes: 5 additions & 2 deletions lib/cli/generate-module-descriptor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Logic borrowed from stripes-core's package2md.js excluding file load and console output
// $ node ../stripes-core/util/package2md.js package.json > MD.json
const { omit } = require('lodash');

module.exports = function generateModuleDescriptor(packageJson, isStrict) {
const stripes = packageJson.stripes || {};
const moduleDescriptor = {
Expand All @@ -12,6 +12,9 @@ module.exports = function generateModuleDescriptor(packageJson, isStrict) {
moduleDescriptor.requires = Object.keys(interfaces).map(key => ({ id: key, version: interfaces[key] }));
const optional = stripes.optionalOkapiInterfaces || [];
moduleDescriptor.optional = Object.keys(optional).map(key => ({ id: key, version: optional[key] }));
moduleDescriptor.metadata = {
stripes: omit(stripes, ['okapiInterfaces', 'optionalOkapiInterfaces', 'permissionSets']),
};
}
return moduleDescriptor;
};
8 changes: 7 additions & 1 deletion lib/commands/mod/descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function moduleDescriptorCommand(argv) {
DescriptorService.writeModuleDescriptorsToDirectory(descriptors, argv.output);
console.log(`${descriptors.length} module descriptors written to ${argv.output}`);
} else if (argv.full) {
console.log(JSON.stringify(descriptors, null, 2));
const output = argv.single && descriptors.length === 1 ? descriptors[0] : descriptors;
console.log(JSON.stringify(output, null, 2));
} else {
descriptors.forEach(descriptor => console.log(descriptor.id));
}
Expand All @@ -40,6 +41,11 @@ module.exports = {
type: 'boolean',
default: false,
})
.option('single', {
describe: 'Full JSON descriptor for a single module in the current working directory',
type: 'boolean',
default: false,
})
.option('output', {
describe: 'Directory to write descriptors to as JSON files',
type: 'string',
Expand Down
6 changes: 4 additions & 2 deletions test/okapi/descriptor-service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ describe('The descriptor-service', function () {
id: 'backend2',
version: '3.1'
}
]
],
metadata: { stripes: { type: packageJsonStub.stripes.type } }
}];

const output = this.sut.getUiModuleDescriptor(true);
Expand Down Expand Up @@ -189,7 +190,8 @@ describe('The descriptor-service', function () {
id: 'backend2',
version: '3.1'
}
]
],
metadata: { stripes: { type: packageJsonStub.stripes.type } }
};
});

Expand Down
Loading