@openapi-typescript-infra/service 4.1.1 → 4.3.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/.trunk/trunk.yaml +5 -5
- package/CHANGELOG.md +19 -0
- package/Makefile +20 -0
- package/build/bin/generate-config-schema.d.ts +2 -0
- package/build/bin/generate-config-schema.js +53 -0
- package/build/bin/generate-config-schema.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/bin/generate-config-schema.ts +55 -0
package/.trunk/trunk.yaml
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
version: 0.1
|
|
2
2
|
cli:
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.17.1
|
|
4
4
|
plugins:
|
|
5
5
|
sources:
|
|
6
6
|
- id: trunk
|
|
7
|
-
ref: v1.2.
|
|
7
|
+
ref: v1.2.6
|
|
8
8
|
uri: https://github.com/trunk-io/plugins
|
|
9
9
|
lint:
|
|
10
10
|
enabled:
|
|
11
11
|
- actionlint@1.6.26
|
|
12
|
-
- checkov@2.5.
|
|
12
|
+
- checkov@2.5.9
|
|
13
13
|
- eslint@8.51.0
|
|
14
14
|
- git-diff-check
|
|
15
15
|
- markdownlint@0.37.0
|
|
16
16
|
- osv-scanner@1.4.1
|
|
17
17
|
- prettier@3.0.3
|
|
18
|
-
- trivy@0.
|
|
19
|
-
- trufflehog@3.
|
|
18
|
+
- trivy@0.46.0
|
|
19
|
+
- trufflehog@3.60.0
|
|
20
20
|
- yamllint@1.32.0
|
|
21
21
|
ignore:
|
|
22
22
|
- linters: [ALL]
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [4.3.0](https://github.com/openapi-typescript-infra/service/compare/v4.2.0...v4.3.0) (2023-10-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **yarn:** update lockfile ([24b492b](https://github.com/openapi-typescript-infra/service/commit/24b492b4c8780a361b8187ce6e002c94d862fb27))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **config:** add support for generating config schema validation ([a5c9c3f](https://github.com/openapi-typescript-infra/service/commit/a5c9c3f65bfc2798a97a4ffe960ffd88df9f9115))
|
|
12
|
+
|
|
13
|
+
# [4.2.0](https://github.com/openapi-typescript-infra/service/compare/v4.1.1...v4.2.0) (2023-10-18)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **env:** support staging environments ([60baaa3](https://github.com/openapi-typescript-infra/service/commit/60baaa3e15c8a04ae10644d889c329558fb01aa8))
|
|
19
|
+
|
|
1
20
|
## [4.1.1](https://github.com/openapi-typescript-infra/service/compare/v4.1.0...v4.1.1) (2023-10-18)
|
|
2
21
|
|
|
3
22
|
|
package/Makefile
CHANGED
|
@@ -51,6 +51,26 @@ src/generated/service/index.ts: $(shell find api -type f)
|
|
|
51
51
|
./node_modules/.bin/prettier ./src/generated/service/index.ts --write
|
|
52
52
|
rm -rf $(TMP)
|
|
53
53
|
|
|
54
|
+
|
|
55
|
+
# Config schema generation
|
|
56
|
+
# Function to convert snake case to camel case
|
|
57
|
+
define to_camel
|
|
58
|
+
$(shell echo $(1) | awk -F- '{for(i=1; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1' | tr -d '\n')
|
|
59
|
+
endef
|
|
60
|
+
|
|
61
|
+
export CONFIG_SOURCE ?= src/types/config.ts
|
|
62
|
+
export CONFIG_TYPE ?= $(call to_camel,$(SERVICE_NAME))ConfigSchema
|
|
63
|
+
|
|
64
|
+
config-schema: src/generated/config-schema.ts
|
|
65
|
+
|
|
66
|
+
src/generated/config-schema.ts: $(CONFIG_SOURCE)
|
|
67
|
+
mkdir -p src/generated
|
|
68
|
+
echo "Building config schema"
|
|
69
|
+
node ./build/bin/generate-config-schema.js \
|
|
70
|
+
--source $(CONFIG_SOURCE) \
|
|
71
|
+
--type $(CONFIG_TYPE) \
|
|
72
|
+
--output src/generated/config-schema.ts
|
|
73
|
+
|
|
54
74
|
# Postgres database things
|
|
55
75
|
export PGUSER ?= postgres
|
|
56
76
|
export PGPASSWORD ?= postgres
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
10
|
+
const standalone_1 = __importDefault(require("ajv/dist/standalone"));
|
|
11
|
+
const minimist_1 = __importDefault(require("minimist"));
|
|
12
|
+
// Generate an AJV validator from a Typescript type
|
|
13
|
+
// This is mostly included since we already have AJV,
|
|
14
|
+
// and we want you to use it to validate configurations.
|
|
15
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
16
|
+
async function run() {
|
|
17
|
+
// First we need to run typescript-json-schema to
|
|
18
|
+
// generate the JSON schema. We use npx to avoid the
|
|
19
|
+
// runtime dependency.
|
|
20
|
+
const tsJsonSchema = (0, child_process_1.spawnSync)('npx', [
|
|
21
|
+
'-y',
|
|
22
|
+
'typescript-json-schema',
|
|
23
|
+
argv.tsconfig || 'tsconfig.build.json',
|
|
24
|
+
argv.type,
|
|
25
|
+
'--required',
|
|
26
|
+
'--noExtraProps',
|
|
27
|
+
'--strictNullChecks',
|
|
28
|
+
'--include',
|
|
29
|
+
argv.source || 'src/types/config.ts',
|
|
30
|
+
], {
|
|
31
|
+
stdio: 'pipe',
|
|
32
|
+
encoding: 'utf-8',
|
|
33
|
+
});
|
|
34
|
+
if (tsJsonSchema.status !== 0) {
|
|
35
|
+
console.error(tsJsonSchema.stderr);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const schema = JSON.parse(tsJsonSchema.stdout);
|
|
39
|
+
const ajv = new ajv_1.default({ code: { source: true, esm: true } });
|
|
40
|
+
const validate = ajv.compile(schema);
|
|
41
|
+
const moduleCode = (0, standalone_1.default)(ajv, validate);
|
|
42
|
+
if (argv.output) {
|
|
43
|
+
fs_1.default.writeFileSync(argv.output, `// @ts-nocheck\n${moduleCode}\n`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.log(moduleCode);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
run().catch((err) => {
|
|
50
|
+
console.error(err);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=generate-config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-config-schema.js","sourceRoot":"","sources":["../../src/bin/generate-config-schema.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AACpB,iDAA0C;AAE1C,8CAAsB;AACtB,qEAAiD;AACjD,wDAAgC;AAEhC,mDAAmD;AACnD,qDAAqD;AACrD,wDAAwD;AACxD,MAAM,IAAI,GAAG,IAAA,kBAAQ,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7C,KAAK,UAAU,GAAG;IAChB,iDAAiD;IACjD,oDAAoD;IACpD,sBAAsB;IACtB,MAAM,YAAY,GAAG,IAAA,yBAAS,EAC5B,KAAK,EACL;QACE,IAAI;QACJ,wBAAwB;QACxB,IAAI,CAAC,QAAQ,IAAI,qBAAqB;QACtC,IAAI,CAAC,IAAI;QACT,YAAY;QACZ,gBAAgB;QAChB,oBAAoB;QACpB,WAAW;QACX,IAAI,CAAC,MAAM,IAAI,qBAAqB;KACrC,EACD;QACE,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,OAAO;KAClB,CACF,CAAC;IACF,I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