@voxgig/create-sdkgen 0.17.1 → 0.17.2
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.
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CreateRoot = void 0;
|
|
7
|
+
exports.sanitizeDefName = sanitizeDefName;
|
|
7
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
9
|
// import * as Fs from 'node:fs'
|
|
9
10
|
const jostraca_1 = require("jostraca");
|
|
@@ -88,6 +89,36 @@ function mergeGuide(existing, template) {
|
|
|
88
89
|
}
|
|
89
90
|
return missing.join('\n') + '\n\n' + existing;
|
|
90
91
|
}
|
|
92
|
+
// The OpenAPI filename is inherited from the upstream API slug, and upstream
|
|
93
|
+
// slugs are not constrained: the freepublicapis corpus contains apostrophes
|
|
94
|
+
// (catherine-shulman's-quotes), accents (dólar-y-monedas, kölner-adressen),
|
|
95
|
+
// and '!' / '>' / '_'. That name is copied into .sdk/def/ AND written verbatim
|
|
96
|
+
// into a single-quoted aontu string in sdk.aontu:
|
|
97
|
+
//
|
|
98
|
+
// def: 'catherine-shulman's-quotes_0.1.0.json'
|
|
99
|
+
// ^ terminates the string -> AontuError, no SDK
|
|
100
|
+
//
|
|
101
|
+
// Slugs are [a-z0-9-]; a filename additionally needs '.' and '_' for the
|
|
102
|
+
// version segment and extension, so those are kept — which also means every
|
|
103
|
+
// already-conforming name (including cedar's dotted gitlab-v4-swagger-2.0.yaml)
|
|
104
|
+
// is untouched and no repo churns. Everything else is folded to '-'.
|
|
105
|
+
function sanitizeDefName(filename) {
|
|
106
|
+
const clean = filename
|
|
107
|
+
.normalize('NFKD').replace(/[\u0300-\u036f]/g, '') // dólar -> dolar
|
|
108
|
+
.toLowerCase()
|
|
109
|
+
// Quotes are ELIDED, not folded to '-', so the filename agrees with the
|
|
110
|
+
// repo name apidef's sanitizeSlug derives from the same slug:
|
|
111
|
+
// catherine-shulman's-quotes -> catherine-shulmans-quotes(-sdk).
|
|
112
|
+
.replace(/['’"]/g, '')
|
|
113
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
114
|
+
.replace(/-+/g, '-')
|
|
115
|
+
// yu-gi-oh!_0.1.0.json would otherwise keep the '!' as a dangling '-'
|
|
116
|
+
// before the version separator: yu-gi-oh-_0.1.0.json.
|
|
117
|
+
.replace(/-+([._])/g, '$1')
|
|
118
|
+
.replace(/([._])-+/g, '$1')
|
|
119
|
+
.replace(/^-|-$/g, '');
|
|
120
|
+
return '' === clean ? 'openapi.yml' : clean;
|
|
121
|
+
}
|
|
91
122
|
// TODO: rename to RootSdk
|
|
92
123
|
const CreateRoot = (0, jostraca_1.cmp)(function CreateRoot(props) {
|
|
93
124
|
const { ctx$, ctx$: { folder }, spec, model } = props;
|
|
@@ -115,7 +146,7 @@ const CreateRoot = (0, jostraca_1.cmp)(function CreateRoot(props) {
|
|
|
115
146
|
(0, jostraca_1.Content)(GITIGNORE_TOP);
|
|
116
147
|
});
|
|
117
148
|
const origdef = spec.def;
|
|
118
|
-
const projdef = node_path_1.default.basename(origdef);
|
|
149
|
+
const projdef = sanitizeDefName(node_path_1.default.basename(origdef));
|
|
119
150
|
spec.def = projdef;
|
|
120
151
|
(0, jostraca_1.Folder)({ name: spec.sdk_folder }, () => {
|
|
121
152
|
(0, jostraca_1.File)({ name: '.gitignore' }, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateRoot.js","sourceRoot":"","sources":["../../../src/project/standard/CreateRoot.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"CreateRoot.js","sourceRoot":"","sources":["../../../src/project/standard/CreateRoot.ts"],"names":[],"mappings":";;;;;;QAmOE,eAAe;AAjOjB,0DAA4B;AAC5B,gCAAgC;AAEhC,uCAUiB;AAGjB,yCAAqC;AAGrC,MAA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AC,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;oBAEtE,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE;wBAC9B,IAAA,kBAAO,EAAC,UAAU,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;oBACnD,CAAC,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IAEJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;QAIA,UAAU"}
|
package/package.json
CHANGED
|
@@ -111,6 +111,38 @@ function mergeGuide(existing: string | null, template: string): string {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
|
|
114
|
+
// The OpenAPI filename is inherited from the upstream API slug, and upstream
|
|
115
|
+
// slugs are not constrained: the freepublicapis corpus contains apostrophes
|
|
116
|
+
// (catherine-shulman's-quotes), accents (dólar-y-monedas, kölner-adressen),
|
|
117
|
+
// and '!' / '>' / '_'. That name is copied into .sdk/def/ AND written verbatim
|
|
118
|
+
// into a single-quoted aontu string in sdk.aontu:
|
|
119
|
+
//
|
|
120
|
+
// def: 'catherine-shulman's-quotes_0.1.0.json'
|
|
121
|
+
// ^ terminates the string -> AontuError, no SDK
|
|
122
|
+
//
|
|
123
|
+
// Slugs are [a-z0-9-]; a filename additionally needs '.' and '_' for the
|
|
124
|
+
// version segment and extension, so those are kept — which also means every
|
|
125
|
+
// already-conforming name (including cedar's dotted gitlab-v4-swagger-2.0.yaml)
|
|
126
|
+
// is untouched and no repo churns. Everything else is folded to '-'.
|
|
127
|
+
function sanitizeDefName(filename: string): string {
|
|
128
|
+
const clean = filename
|
|
129
|
+
.normalize('NFKD').replace(/[\u0300-\u036f]/g, '') // dólar -> dolar
|
|
130
|
+
.toLowerCase()
|
|
131
|
+
// Quotes are ELIDED, not folded to '-', so the filename agrees with the
|
|
132
|
+
// repo name apidef's sanitizeSlug derives from the same slug:
|
|
133
|
+
// catherine-shulman's-quotes -> catherine-shulmans-quotes(-sdk).
|
|
134
|
+
.replace(/['’"]/g, '')
|
|
135
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
136
|
+
.replace(/-+/g, '-')
|
|
137
|
+
// yu-gi-oh!_0.1.0.json would otherwise keep the '!' as a dangling '-'
|
|
138
|
+
// before the version separator: yu-gi-oh-_0.1.0.json.
|
|
139
|
+
.replace(/-+([._])/g, '$1')
|
|
140
|
+
.replace(/([._])-+/g, '$1')
|
|
141
|
+
.replace(/^-|-$/g, '')
|
|
142
|
+
return '' === clean ? 'openapi.yml' : clean
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
114
146
|
// TODO: rename to RootSdk
|
|
115
147
|
const CreateRoot = cmp(function CreateRoot(props: any) {
|
|
116
148
|
const { ctx$, ctx$: { folder }, spec, model } = props
|
|
@@ -147,7 +179,7 @@ const CreateRoot = cmp(function CreateRoot(props: any) {
|
|
|
147
179
|
})
|
|
148
180
|
|
|
149
181
|
const origdef = spec.def
|
|
150
|
-
const projdef = Path.basename(origdef)
|
|
182
|
+
const projdef = sanitizeDefName(Path.basename(origdef))
|
|
151
183
|
spec.def = projdef
|
|
152
184
|
|
|
153
185
|
Folder({ name: spec.sdk_folder }, () => {
|
|
@@ -192,5 +224,6 @@ const CreateRoot = cmp(function CreateRoot(props: any) {
|
|
|
192
224
|
|
|
193
225
|
|
|
194
226
|
export {
|
|
195
|
-
CreateRoot
|
|
227
|
+
CreateRoot,
|
|
228
|
+
sanitizeDefName,
|
|
196
229
|
}
|