Skip to content

Commit b618318

Browse files
authored
Merge branch 'main' into STRIPES-861
2 parents e5ddab3 + ff0c0ca commit b618318

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 4.1.0 IN PROGRESS
44

55
* Populate module descriptor's `name` field with module-name if `description` is missing. Refs STCLI-272.
6-
* Use node-native glob functionality in `translate compile`. Refs STCLI-273.
6+
* Populate module descriptor's `metadata` field with remaining `stripes` properties. Refs STCLI-274.
77

88
## [4.0.0](https://github.com/folio-org/stripes-cli/tree/v4.0.0) (2025-02-24)
99
[Full Changelog](https://github.com/folio-org/stripes-cli/compare/v3.2.0...v4.0.0)

lib/cli/generate-module-descriptor.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Logic borrowed from stripes-core's package2md.js excluding file load and console output
2-
// $ node ../stripes-core/util/package2md.js package.json > MD.json
1+
const { omit } = require('lodash');
2+
33
module.exports = function generateModuleDescriptor(packageJson, isStrict) {
44
const stripes = packageJson.stripes || {};
55
const moduleDescriptor = {
@@ -12,6 +12,9 @@ module.exports = function generateModuleDescriptor(packageJson, isStrict) {
1212
moduleDescriptor.requires = Object.keys(interfaces).map(key => ({ id: key, version: interfaces[key] }));
1313
const optional = stripes.optionalOkapiInterfaces || [];
1414
moduleDescriptor.optional = Object.keys(optional).map(key => ({ id: key, version: optional[key] }));
15+
moduleDescriptor.metadata = {
16+
stripes: omit(stripes, ['okapiInterfaces', 'optionalOkapiInterfaces', 'permissionSets']),
17+
};
1518
}
1619
return moduleDescriptor;
1720
};

lib/commands/mod/descriptor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function moduleDescriptorCommand(argv) {
1414
DescriptorService.writeModuleDescriptorsToDirectory(descriptors, argv.output);
1515
console.log(`${descriptors.length} module descriptors written to ${argv.output}`);
1616
} else if (argv.full) {
17-
console.log(JSON.stringify(descriptors, null, 2));
17+
const output = argv.single && descriptors.length === 1 ? descriptors[0] : descriptors;
18+
console.log(JSON.stringify(output, null, 2));
1819
} else {
1920
descriptors.forEach(descriptor => console.log(descriptor.id));
2021
}
@@ -40,6 +41,11 @@ module.exports = {
4041
type: 'boolean',
4142
default: false,
4243
})
44+
.option('single', {
45+
describe: 'Full JSON descriptor for a single module in the current working directory',
46+
type: 'boolean',
47+
default: false,
48+
})
4349
.option('output', {
4450
describe: 'Directory to write descriptors to as JSON files',
4551
type: 'string',

lib/commands/translate/compile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const importLazy = require('import-lazy')(require);
1010
const fs = importLazy('fs');
1111
const path = importLazy('path');
1212
const process = importLazy('process');
13+
const fg = importLazy('fast-glob');
1314
const { compile } = importLazy('@formatjs/cli-lib');
1415

1516
const { contextMiddleware } = importLazy('../../cli/context-middleware');
16-
const { globSync } = fs;
1717

1818
/**
1919
* createOutDir
@@ -42,8 +42,8 @@ function formatjsCompileCommand(argv) {
4242
ast: true,
4343
format: 'simple',
4444
};
45-
const globSelect = path.join(txPath, '*.json');
46-
const files = globSync(globSelect);
45+
46+
const files = fg.globSync(path.join(txPath, '*.json'));
4747
if (fs.existsSync(txPath) && files.length > 0) {
4848
createOutDir(outDir);
4949
Promise.all(files.map(f => compile([f], opts)))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"configstore": "^3.1.1",
3232
"debug": "^4.0.1",
3333
"express": "^4.17.1",
34+
"fast-glob": "^3.3.1",
3435
"fast-xml-parser": "^4.2.4",
3536
"find-up": "^2.1.0",
3637
"fs-extra": "^11.1.1",

test/okapi/descriptor-service.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ describe('The descriptor-service', function () {
130130
id: 'backend2',
131131
version: '3.1'
132132
}
133-
]
133+
],
134+
metadata: { stripes: { type: packageJsonStub.stripes.type } }
134135
}];
135136

136137
const output = this.sut.getUiModuleDescriptor(true);
@@ -189,7 +190,8 @@ describe('The descriptor-service', function () {
189190
id: 'backend2',
190191
version: '3.1'
191192
}
192-
]
193+
],
194+
metadata: { stripes: { type: packageJsonStub.stripes.type } }
193195
};
194196
});
195197

0 commit comments

Comments
 (0)