@next-core/build-config-factory 2.17.9 → 2.18.0
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/CHANGELOG.md +16 -0
- package/package.json +2 -2
- package/src/generateProviderContracts.js +43 -0
- package/src/post-build.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.18.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.17.9...@next-core/build-config-factory@2.18.0) (2021-12-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* refactor generate contract ([0a40c3a](https://github.com/easyops-cn/next-core/commit/0a40c3a6889db1465250a126dda0112ea5ca1a2c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* generate new contract.json after build provider-of-* package ([cbf7f96](https://github.com/easyops-cn/next-core/commit/cbf7f96d0130bd4a680fec11d9371c4e9bc01f5b))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.17.9](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.17.8...@next-core/build-config-factory@2.17.9) (2021-12-03)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @next-core/build-config-factory
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-config-factory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "build config factory",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/build-config-factory",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"typedoc": "^0.19.2",
|
|
38
38
|
"typedoc-plugin-no-inherit": "^1.2.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "642cc9f88ce8bdc943a39870d0b0d7189febf72b"
|
|
41
41
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const fs = require("fs-extra");
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const changeCase = require("change-case");
|
|
5
|
+
const yaml = require("js-yaml");
|
|
6
|
+
const { omit } = require("lodash");
|
|
7
|
+
|
|
8
|
+
module.exports = function generateProviderDocsV2(pluginName) {
|
|
9
|
+
let contractPath;
|
|
10
|
+
const providersJson = require(path.resolve("providers.json"));
|
|
11
|
+
try {
|
|
12
|
+
contractPath = require.resolve(`${providersJson.sdk}/dist/contract.json`, {
|
|
13
|
+
paths: [process.cwd()],
|
|
14
|
+
});
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.log(
|
|
17
|
+
chalk.yellow(
|
|
18
|
+
`Warning: no contract.json file generated, if need it please execute \`yarn yo-sdk\` for ${providersJson.sdk} and build it later`
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const doc = yaml.safeLoad(fs.readFileSync(contractPath), "utf-8");
|
|
25
|
+
const contract = {
|
|
26
|
+
...omit(doc, ["name", "contracts"]),
|
|
27
|
+
name: `providers-of-${changeCase.paramCase(doc.name)}`,
|
|
28
|
+
providers: doc.contracts.map((item) => {
|
|
29
|
+
const [service, model, name] = item.contract.split(".");
|
|
30
|
+
return {
|
|
31
|
+
provider: `providers-of-${changeCase.paramCase(
|
|
32
|
+
service
|
|
33
|
+
)}.${changeCase.paramCase(model)}-api-${changeCase.paramCase(name)}`,
|
|
34
|
+
...omit(item, "contract"),
|
|
35
|
+
};
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
fs.writeFileSync(
|
|
39
|
+
path.join(process.cwd(), "dist", "contract.json"),
|
|
40
|
+
JSON.stringify(contract, null, 2)
|
|
41
|
+
);
|
|
42
|
+
console.log(`Providers contract for ${pluginName} generated.`);
|
|
43
|
+
};
|
package/src/post-build.js
CHANGED
|
@@ -7,6 +7,7 @@ const ensureMicroApp = require("./ensureMicroApp");
|
|
|
7
7
|
const ensureDeps = require("./ensureDeps");
|
|
8
8
|
const validateDeps = require("./validateDeps");
|
|
9
9
|
const generateProviderDocs = require("./generateProviderDocs");
|
|
10
|
+
const generateProviderContracts = require("./generateProviderContracts");
|
|
10
11
|
const generateBrickDocs = require("./generateBrickDocs");
|
|
11
12
|
const generateBrickContracts = require("./generateBrickContracts");
|
|
12
13
|
const generateSnippets = require("./generateSnippets");
|
|
@@ -188,6 +189,7 @@ module.exports = (scope) => {
|
|
|
188
189
|
const isProviderBricks = pluginName.startsWith(providerPackagePrefix);
|
|
189
190
|
if (isProviderBricks) {
|
|
190
191
|
generateProviderDocs(pluginName);
|
|
192
|
+
generateProviderContracts(pluginName);
|
|
191
193
|
} else {
|
|
192
194
|
enableGenerateDoc && generateBrickDocs(pluginName);
|
|
193
195
|
}
|