@azure-tools/typespec-ts 0.55.0-dev.5 → 0.55.0-dev.7
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/README.md +3 -24
- package/dist/src/framework/hooks/binder.d.ts +1 -1
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.js +6 -8
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +20 -29
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +0 -4
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +3 -21
- package/dist/src/lib.js.map +1 -1
- package/dist/src/rlc-common/build-client-definitions.d.ts.map +1 -1
- package/dist/src/rlc-common/build-client-definitions.js +4 -4
- package/dist/src/rlc-common/build-client-definitions.js.map +1 -1
- package/dist/src/rlc-common/build-client.d.ts.map +1 -1
- package/dist/src/rlc-common/build-client.js +4 -13
- package/dist/src/rlc-common/build-client.js.map +1 -1
- package/dist/src/rlc-common/build-index-file.d.ts.map +1 -1
- package/dist/src/rlc-common/build-index-file.js +21 -79
- package/dist/src/rlc-common/build-index-file.js.map +1 -1
- package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +1 -1
- package/dist/src/rlc-common/build-is-unexpected-helper.js +1 -5
- package/dist/src/rlc-common/build-is-unexpected-helper.js.map +1 -1
- package/dist/src/rlc-common/build-logger.d.ts.map +1 -1
- package/dist/src/rlc-common/build-logger.js +2 -6
- package/dist/src/rlc-common/build-logger.js.map +1 -1
- package/dist/src/rlc-common/build-object-types.d.ts +1 -1
- package/dist/src/rlc-common/build-object-types.d.ts.map +1 -1
- package/dist/src/rlc-common/build-object-types.js +9 -11
- package/dist/src/rlc-common/build-object-types.js.map +1 -1
- package/dist/src/rlc-common/build-parameter-types.d.ts.map +1 -1
- package/dist/src/rlc-common/build-parameter-types.js +13 -66
- package/dist/src/rlc-common/build-parameter-types.js.map +1 -1
- package/dist/src/rlc-common/build-polling-helper.d.ts.map +1 -1
- package/dist/src/rlc-common/build-polling-helper.js +0 -2
- package/dist/src/rlc-common/build-polling-helper.js.map +1 -1
- package/dist/src/rlc-common/build-response-types.d.ts.map +1 -1
- package/dist/src/rlc-common/build-response-types.js +2 -5
- package/dist/src/rlc-common/build-response-types.js.map +1 -1
- package/dist/src/rlc-common/build-schema-type.d.ts.map +1 -1
- package/dist/src/rlc-common/build-schema-type.js +1 -8
- package/dist/src/rlc-common/build-schema-type.js.map +1 -1
- package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +1 -1
- package/dist/src/rlc-common/build-top-level-index-file.js +1 -5
- package/dist/src/rlc-common/build-top-level-index-file.js.map +1 -1
- package/dist/src/rlc-common/helpers/name-constructors.d.ts +0 -9
- package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/name-constructors.js +0 -10
- package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -1
- package/dist/src/rlc-common/index.d.ts +0 -2
- package/dist/src/rlc-common/index.d.ts.map +1 -1
- package/dist/src/rlc-common/index.js +0 -2
- package/dist/src/rlc-common/index.js.map +1 -1
- package/dist/src/rlc-common/interfaces.d.ts +1 -4
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
- package/dist/src/rlc-common/interfaces.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts +1 -1
- package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-api-extractor-config.js +4 -41
- package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +1 -1
- package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-es-lint-config.js +2 -37
- package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-package-file.js +22 -52
- package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-readme-file.js +6 -7
- package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-test-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-test-config.js +1 -4
- package/dist/src/rlc-common/metadata/build-test-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-ts-config.d.ts +2 -2
- package/dist/src/rlc-common/metadata/build-ts-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-ts-config.js +18 -59
- package/dist/src/rlc-common/metadata/build-ts-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-warp-config.d.ts +1 -1
- package/dist/src/rlc-common/metadata/build-warp-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-warp-config.js +0 -3
- package/dist/src/rlc-common/metadata/build-warp-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts +1 -38
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.js +1 -108
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.js.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +0 -38
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +2 -18
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +1 -18
- package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/package-common.js +20 -94
- package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
- package/dist/src/rlc-common/static/polling-content.d.ts +1 -1
- package/dist/src/rlc-common/static/polling-content.d.ts.map +1 -1
- package/dist/src/rlc-common/static/polling-content.js +1 -1
- package/dist/src/rlc-common/test/build-recorded-client.d.ts +1 -1
- package/dist/src/rlc-common/test/build-recorded-client.d.ts.map +1 -1
- package/dist/src/rlc-common/test/build-recorded-client.js +2 -5
- package/dist/src/rlc-common/test/build-recorded-client.js.map +1 -1
- package/dist/src/rlc-common/test/build-sample-test.d.ts +1 -1
- package/dist/src/rlc-common/test/build-sample-test.d.ts.map +1 -1
- package/dist/src/rlc-common/test/build-sample-test.js +2 -5
- package/dist/src/rlc-common/test/build-sample-test.js.map +1 -1
- package/dist/src/rlc-common/test/build-snippets.d.ts +1 -1
- package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -1
- package/dist/src/rlc-common/test/build-snippets.js +2 -5
- package/dist/src/rlc-common/test/build-snippets.js.map +1 -1
- package/dist/src/rlc-common/test/template.d.ts +2 -2
- package/dist/src/rlc-common/test/template.d.ts.map +1 -1
- package/dist/src/rlc-common/test/template.js +1 -31
- package/dist/src/rlc-common/test/template.js.map +1 -1
- package/dist/src/rlc-common/transform-sample-groups.d.ts.map +1 -1
- package/dist/src/rlc-common/transform-sample-groups.js +4 -8
- package/dist/src/rlc-common/transform-sample-groups.js.map +1 -1
- package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
- package/dist/src/transform/transfrom-rlc-options.js +0 -18
- package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/framework/hooks/binder.ts +1 -1
- package/src/framework/load-static-helpers.ts +8 -10
- package/src/index.ts +19 -31
- package/src/lib.ts +3 -26
- package/src/rlc-common/build-client-definitions.ts +4 -13
- package/src/rlc-common/build-client.ts +4 -22
- package/src/rlc-common/build-index-file.ts +21 -142
- package/src/rlc-common/build-is-unexpected-helper.ts +1 -8
- package/src/rlc-common/build-logger.ts +2 -12
- package/src/rlc-common/build-object-types.ts +5 -17
- package/src/rlc-common/build-parameter-types.ts +9 -103
- package/src/rlc-common/build-polling-helper.ts +0 -3
- package/src/rlc-common/build-response-types.ts +2 -12
- package/src/rlc-common/build-schema-type.ts +1 -11
- package/src/rlc-common/build-top-level-index-file.ts +1 -8
- package/src/rlc-common/helpers/name-constructors.ts +0 -15
- package/src/rlc-common/index.ts +0 -2
- package/src/rlc-common/interfaces.ts +1 -4
- package/src/rlc-common/metadata/build-api-extractor-config.ts +4 -46
- package/src/rlc-common/metadata/build-es-lint-config.ts +2 -38
- package/src/rlc-common/metadata/build-package-file.ts +21 -58
- package/src/rlc-common/metadata/build-readme-file.ts +6 -9
- package/src/rlc-common/metadata/build-test-config.ts +1 -6
- package/src/rlc-common/metadata/build-ts-config.ts +28 -70
- package/src/rlc-common/metadata/build-warp-config.ts +0 -4
- package/src/rlc-common/metadata/package-json/azure-package-common.ts +2 -134
- package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +2 -21
- package/src/rlc-common/metadata/package-json/package-common.ts +21 -114
- package/src/rlc-common/static/polling-content.ts +1 -1
- package/src/rlc-common/test/build-recorded-client.ts +2 -5
- package/src/rlc-common/test/build-sample-test.ts +2 -5
- package/src/rlc-common/test/build-snippets.ts +2 -5
- package/src/rlc-common/test/template.ts +1 -31
- package/src/rlc-common/transform-sample-groups.ts +3 -12
- package/src/transform/transfrom-rlc-options.ts +0 -20
- package/dist/src/rlc-common/helpers/package-util.d.ts +0 -4
- package/dist/src/rlc-common/helpers/package-util.d.ts.map +0 -1
- package/dist/src/rlc-common/helpers/package-util.js +0 -7
- package/dist/src/rlc-common/helpers/package-util.js.map +0 -1
- package/dist/src/rlc-common/metadata/build-rollup-config.d.ts +0 -6
- package/dist/src/rlc-common/metadata/build-rollup-config.d.ts.map +0 -1
- package/dist/src/rlc-common/metadata/build-rollup-config.js +0 -139
- package/dist/src/rlc-common/metadata/build-rollup-config.js.map +0 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts +0 -8
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts.map +0 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js +0 -101
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js.map +0 -1
- package/src/rlc-common/helpers/package-util.ts +0 -9
- package/src/rlc-common/metadata/build-rollup-config.ts +0 -146
- package/src/rlc-common/metadata/package-json/build-azure-standalone-package.ts +0 -123
|
@@ -128,18 +128,11 @@ module.exports = function (config) {
|
|
|
128
128
|
|
|
129
129
|
export const recordedClientContent = `
|
|
130
130
|
|
|
131
|
-
{{#if isEsm}}
|
|
132
131
|
import {
|
|
133
132
|
Recorder,
|
|
134
133
|
RecorderStartOptions,
|
|
135
134
|
VitestTestContext,
|
|
136
135
|
} from "@azure-tools/test-recorder";
|
|
137
|
-
{{/if}}
|
|
138
|
-
|
|
139
|
-
{{#if isCjs}}
|
|
140
|
-
import { Context } from "mocha";
|
|
141
|
-
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
|
|
142
|
-
{{/if}}
|
|
143
136
|
|
|
144
137
|
const replaceableVariables: Record<string, string> = {
|
|
145
138
|
SUBSCRIPTION_ID: "azure_subscription_id"
|
|
@@ -154,25 +147,14 @@ const recorderEnvSetup: RecorderStartOptions = {
|
|
|
154
147
|
* Should be called first in the test suite to make sure environment variables are
|
|
155
148
|
* read before they are being used.
|
|
156
149
|
*/
|
|
157
|
-
{{#if isEsm}}
|
|
158
150
|
export async function createRecorder(context: VitestTestContext): Promise<Recorder> {
|
|
159
151
|
const recorder = new Recorder(context);
|
|
160
152
|
await recorder.start(recorderEnvSetup);
|
|
161
153
|
return recorder;
|
|
162
154
|
}
|
|
163
|
-
{{/if}}
|
|
164
|
-
|
|
165
|
-
{{#if isCjs}}
|
|
166
|
-
export async function createRecorder(context: Context): Promise<Recorder> {
|
|
167
|
-
const recorder = new Recorder(context.currentTest);
|
|
168
|
-
await recorder.start(recorderEnvSetup);
|
|
169
|
-
return recorder;
|
|
170
|
-
}
|
|
171
|
-
{{/if}}
|
|
172
155
|
`;
|
|
173
156
|
|
|
174
157
|
export const sampleTestContent = `
|
|
175
|
-
{{#if isEsm}}
|
|
176
158
|
// import { Recorder } from "@azure-tools/test-recorder";
|
|
177
159
|
// import { createRecorder } from "./utils/recordedClient.js";
|
|
178
160
|
import { assert,
|
|
@@ -181,24 +163,12 @@ import { assert,
|
|
|
181
163
|
it,
|
|
182
164
|
describe
|
|
183
165
|
} from "vitest";
|
|
184
|
-
{{/if}}
|
|
185
|
-
|
|
186
|
-
{{#if isCjs}}
|
|
187
|
-
// import { Recorder } from "@azure-tools/test-recorder";
|
|
188
|
-
import { assert } from "chai";
|
|
189
|
-
// import { createRecorder } from "./utils/recordedClient{{#if isModularLibrary}}.js{{/if}}";
|
|
190
|
-
// import { Context } from "mocha";
|
|
191
|
-
{{/if}}
|
|
192
166
|
|
|
193
167
|
describe("My test", () => {
|
|
194
168
|
// let recorder: Recorder;
|
|
195
169
|
|
|
196
|
-
// beforeEach(async function(
|
|
197
|
-
{{#if isEsm}}
|
|
170
|
+
// beforeEach(async function(ctx) {
|
|
198
171
|
// recorder = await createRecorder(ctx);
|
|
199
|
-
{{else}}
|
|
200
|
-
// recorder = await createRecorder(this);
|
|
201
|
-
{{/if}}
|
|
202
172
|
// });
|
|
203
173
|
|
|
204
174
|
// afterEach(async function() {
|
|
@@ -65,7 +65,6 @@ export function transformSampleGroups(model: RLCModel, allowMockValue = true) {
|
|
|
65
65
|
const operatonConcante = getOperationConcate(
|
|
66
66
|
detail.operationName,
|
|
67
67
|
pathDetails.operationGroupName,
|
|
68
|
-
model.options?.sourceFrom,
|
|
69
68
|
);
|
|
70
69
|
const operationPrefix = normalizeName(
|
|
71
70
|
camelCase(transformSpecialLetterToSpace(operatonConcante)),
|
|
@@ -373,20 +372,12 @@ function addValueInImportedDict(
|
|
|
373
372
|
function buildMethodParamMap(model: RLCModel): Map<string, OperationParameter> {
|
|
374
373
|
const map = new Map<string, OperationParameter>();
|
|
375
374
|
(model.parameters ?? []).forEach((p) => {
|
|
376
|
-
const operatonConcante = getOperationConcate(
|
|
377
|
-
p.operationName,
|
|
378
|
-
p.operationGroup,
|
|
379
|
-
model.options?.sourceFrom,
|
|
380
|
-
);
|
|
375
|
+
const operatonConcante = getOperationConcate(p.operationName, p.operationGroup);
|
|
381
376
|
map.set(operatonConcante, p);
|
|
382
377
|
});
|
|
383
378
|
return map;
|
|
384
379
|
}
|
|
385
380
|
|
|
386
|
-
function getOperationConcate(opName: string, opGroup: string
|
|
387
|
-
return
|
|
388
|
-
? opGroup === "" || opGroup === "Client"
|
|
389
|
-
? opName
|
|
390
|
-
: `${opGroup}${opName}`
|
|
391
|
-
: `${opGroup}_${opName}`;
|
|
381
|
+
function getOperationConcate(opName: string, opGroup: string) {
|
|
382
|
+
return `${opGroup}_${opName}`;
|
|
392
383
|
}
|
|
@@ -42,10 +42,8 @@ function extractRLCOptions(
|
|
|
42
42
|
const isModularLibrary = emitterOptions["is-modular-library"] !== false;
|
|
43
43
|
const includeShortcuts = getIncludeShortcuts(emitterOptions);
|
|
44
44
|
const packageDetails = getPackageDetails(program, emitterOptions, isModularLibrary);
|
|
45
|
-
const moduleKind = getModuleKind(emitterOptions);
|
|
46
45
|
const serviceInfo = getServiceInfo(program, isModularLibrary);
|
|
47
46
|
const includeHeadersInResponse = emitterOptions["include-headers-in-response"] === true;
|
|
48
|
-
const azureSdkForJs = getAzureSdkForJs(emitterOptions);
|
|
49
47
|
const generateMetadata = getGenerateMetadata(emitterOptions);
|
|
50
48
|
const generateTest = getGenerateTest(emitterOptions);
|
|
51
49
|
const generateSample = getGenerateSample(dpgContext, emitterOptions);
|
|
@@ -82,16 +80,13 @@ function extractRLCOptions(
|
|
|
82
80
|
return {
|
|
83
81
|
...credentialInfo,
|
|
84
82
|
includeHeadersInResponse,
|
|
85
|
-
moduleKind,
|
|
86
83
|
includeShortcuts,
|
|
87
84
|
packageDetails,
|
|
88
85
|
generateMetadata,
|
|
89
86
|
generateTest,
|
|
90
87
|
generateSample,
|
|
91
|
-
azureSdkForJs,
|
|
92
88
|
serviceInfo,
|
|
93
89
|
azureOutputDirectory,
|
|
94
|
-
sourceFrom: "TypeSpec",
|
|
95
90
|
enableOperationGroup,
|
|
96
91
|
enableModelNamespace,
|
|
97
92
|
hierarchyClient,
|
|
@@ -266,10 +261,6 @@ function getIncludeShortcuts(emitterOptions: EmitterOptions) {
|
|
|
266
261
|
return Boolean(emitterOptions["include-shortcuts"]);
|
|
267
262
|
}
|
|
268
263
|
|
|
269
|
-
function getModuleKind(emitterOptions: EmitterOptions) {
|
|
270
|
-
return emitterOptions["module-kind"] ?? "esm";
|
|
271
|
-
}
|
|
272
|
-
|
|
273
264
|
function buildPackageDetails(
|
|
274
265
|
program: Program,
|
|
275
266
|
emitterOptions: EmitterOptions,
|
|
@@ -318,13 +309,6 @@ function getServiceInfo(program: Program, isModularLibrary: boolean): ServiceInf
|
|
|
318
309
|
};
|
|
319
310
|
}
|
|
320
311
|
|
|
321
|
-
function getAzureSdkForJs(emitterOptions: EmitterOptions) {
|
|
322
|
-
return emitterOptions["azure-sdk-for-js"] === undefined ||
|
|
323
|
-
emitterOptions["azure-sdk-for-js"] === null
|
|
324
|
-
? true
|
|
325
|
-
: Boolean(emitterOptions["azure-sdk-for-js"]);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
312
|
function getGenerateMetadata(emitterOptions: EmitterOptions) {
|
|
329
313
|
if (
|
|
330
314
|
emitterOptions["generate-metadata"] === undefined ||
|
|
@@ -341,10 +325,6 @@ function getGenerateMetadata(emitterOptions: EmitterOptions) {
|
|
|
341
325
|
* @returns
|
|
342
326
|
*/
|
|
343
327
|
function getGenerateTest(emitterOptions: EmitterOptions) {
|
|
344
|
-
// Disable generateTest if azureSdkForJS is false
|
|
345
|
-
if (!getAzureSdkForJs(emitterOptions)) {
|
|
346
|
-
return false;
|
|
347
|
-
}
|
|
348
328
|
return emitterOptions["generate-test"];
|
|
349
329
|
}
|
|
350
330
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-util.d.ts","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/package-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAE/D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAEjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-util.js","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/package-util.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,KAAe;IACpD,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAe;IACtD,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC;AACvC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-rollup-config.d.ts","sourceRoot":"","sources":["../../../../src/rlc-common/metadata/build-rollup-config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ;;;cA2IhD"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { Project } from "ts-morph";
|
|
4
|
-
export function buildRollupConfig(model) {
|
|
5
|
-
const azureSdkForJs = Boolean(model.options?.azureSdkForJs);
|
|
6
|
-
// Only generate the file when it is not in sdk repo
|
|
7
|
-
if (azureSdkForJs === true || azureSdkForJs === undefined) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const project = new Project({ useInMemoryFileSystem: true });
|
|
11
|
-
const filePath = "rollup.config.js";
|
|
12
|
-
const rollupFile = project.createSourceFile(filePath, undefined, {
|
|
13
|
-
overwrite: true,
|
|
14
|
-
});
|
|
15
|
-
rollupFile.addStatements(`import nodeResolve from "@rollup/plugin-node-resolve";
|
|
16
|
-
import cjs from "@rollup/plugin-commonjs";
|
|
17
|
-
import sourcemaps from "rollup-plugin-sourcemaps";
|
|
18
|
-
import multiEntry from "@rollup/plugin-multi-entry";
|
|
19
|
-
import json from "@rollup/plugin-json";
|
|
20
|
-
|
|
21
|
-
import nodeBuiltins from "builtin-modules";
|
|
22
|
-
|
|
23
|
-
// #region Warning Handler
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A function that can determine whether a rollup warning should be ignored. If
|
|
27
|
-
* the function returns \`true\`, then the warning will not be displayed.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
function ignoreNiseSinonEval(warning) {
|
|
31
|
-
return (
|
|
32
|
-
warning.code === "EVAL" &&
|
|
33
|
-
(warning.id && ((warning.id.includes("node_modules/nise")) ||
|
|
34
|
-
warning.id.includes("node_modules/sinon")) === true)
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function ignoreChaiCircularDependency(warning) {
|
|
39
|
-
return (
|
|
40
|
-
warning.code === "CIRCULAR_DEPENDENCY" &&
|
|
41
|
-
(warning.importer && warning.importer.includes("node_modules/chai") === true)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const warningInhibitors = [
|
|
46
|
-
ignoreChaiCircularDependency,
|
|
47
|
-
ignoreNiseSinonEval
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Construct a warning handler for the shared rollup configuration
|
|
52
|
-
* that ignores certain warnings that are not relevant to testing.
|
|
53
|
-
*/
|
|
54
|
-
function makeOnWarnForTesting() {
|
|
55
|
-
return (warning, warn) => {
|
|
56
|
-
// If every inhibitor returns false (i.e. no inhibitors), then show the warning
|
|
57
|
-
if (warningInhibitors.every(inhib => !inhib(warning))) {
|
|
58
|
-
warn(warning);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// #endregion
|
|
64
|
-
|
|
65
|
-
function makeBrowserTestConfig() {
|
|
66
|
-
const config = {
|
|
67
|
-
input: {
|
|
68
|
-
include: ["dist-esm/test/**/*.spec.js"],
|
|
69
|
-
exclude: ["dist-esm/test/**/node/**"]
|
|
70
|
-
},
|
|
71
|
-
output: {
|
|
72
|
-
file: \`dist-test/index.browser.js\`,
|
|
73
|
-
format: "umd",
|
|
74
|
-
sourcemap: true
|
|
75
|
-
},
|
|
76
|
-
preserveSymlinks: false,
|
|
77
|
-
plugins: [
|
|
78
|
-
multiEntry({ exports: false }),
|
|
79
|
-
nodeResolve({
|
|
80
|
-
mainFields: ["module", "browser"]
|
|
81
|
-
}),
|
|
82
|
-
cjs(),
|
|
83
|
-
json(),
|
|
84
|
-
sourcemaps()
|
|
85
|
-
//viz({ filename: "dist-test/browser-stats.html", sourcemap: true })
|
|
86
|
-
],
|
|
87
|
-
onwarn: makeOnWarnForTesting(),
|
|
88
|
-
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0,
|
|
89
|
-
// rollup started respecting the "sideEffects" field in package.json. Since
|
|
90
|
-
// our package.json sets "sideEffects=false", this also applies to test
|
|
91
|
-
// code, which causes all tests to be removed by tree-shaking.
|
|
92
|
-
treeshake: false
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
return config;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const defaultConfigurationOptions = {
|
|
99
|
-
disableBrowserBundle: false
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export function makeConfig(
|
|
103
|
-
pkg,
|
|
104
|
-
options
|
|
105
|
-
) {
|
|
106
|
-
options = {
|
|
107
|
-
...defaultConfigurationOptions,
|
|
108
|
-
...(options || {})
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const baseConfig = {
|
|
112
|
-
// Use the package's module field if it has one
|
|
113
|
-
input: pkg["module"] || "dist-esm/src/index.js",
|
|
114
|
-
external: [
|
|
115
|
-
...nodeBuiltins,
|
|
116
|
-
...Object.keys(pkg.dependencies),
|
|
117
|
-
...Object.keys(pkg.devDependencies)
|
|
118
|
-
],
|
|
119
|
-
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
|
|
120
|
-
preserveSymlinks: false,
|
|
121
|
-
plugins: [sourcemaps(), nodeResolve()]
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const config = [baseConfig];
|
|
125
|
-
|
|
126
|
-
if (!options.disableBrowserBundle) {
|
|
127
|
-
config.push(makeBrowserTestConfig());
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return config;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export default makeConfig(require("./package.json"));`);
|
|
134
|
-
return {
|
|
135
|
-
path: filePath,
|
|
136
|
-
content: rollupFile.getFullText(),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=build-rollup-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-rollup-config.js","sourceRoot":"","sources":["../../../../src/rlc-common/metadata/build-rollup-config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC5D,oDAAoD;IACpD,IAAI,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAC1D,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,kBAAkB,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE;QAC/D,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,UAAU,CAAC,aAAa,CACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0DAsHsD,CACvD,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,UAAU,CAAC,WAAW,EAAE;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AzurePackageInfoConfig } from "./azure-package-common.js";
|
|
2
|
-
/**
|
|
3
|
-
* Builds the package.json for an Azure package that won't be hosted in the azure-sdk-for-js repo.
|
|
4
|
-
*/
|
|
5
|
-
export declare function buildAzureStandalonePackage(config: AzurePackageInfoConfig): {
|
|
6
|
-
scripts: Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=build-azure-standalone-package.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-azure-standalone-package.d.ts","sourceRoot":"","sources":["../../../../../src/rlc-common/metadata/package-json/build-azure-standalone-package.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EAIvB,MAAM,2BAA2B,CAAC;AAGnC;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,sBAAsB;;EAQzE"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { getAzureCommonPackageInfo, getAzurePackageDependencies, getAzurePackageDevDependencies, } from "./azure-package-common.js";
|
|
4
|
-
import { getCommonPackageScripts, getPackageCommonInfo } from "./package-common.js";
|
|
5
|
-
/**
|
|
6
|
-
* Builds the package.json for an Azure package that won't be hosted in the azure-sdk-for-js repo.
|
|
7
|
-
*/
|
|
8
|
-
export function buildAzureStandalonePackage(config) {
|
|
9
|
-
const packageInfo = {
|
|
10
|
-
...getAzureStandalonePackageInfo(config),
|
|
11
|
-
...getAzureStandaloneDependencies(config),
|
|
12
|
-
scripts: getAzureStandaloneScripts(config),
|
|
13
|
-
};
|
|
14
|
-
return packageInfo;
|
|
15
|
-
}
|
|
16
|
-
function getAzureStandalonePackageInfo(config) {
|
|
17
|
-
const commonPackageInfo = getPackageCommonInfo(config);
|
|
18
|
-
return {
|
|
19
|
-
...commonPackageInfo,
|
|
20
|
-
...getAzureCommonPackageInfo(config),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function getAzureStandaloneDependencies(config) {
|
|
24
|
-
return {
|
|
25
|
-
dependencies: {
|
|
26
|
-
...getAzurePackageDependencies(config),
|
|
27
|
-
},
|
|
28
|
-
devDependencies: {
|
|
29
|
-
...getStandaloneDevDependencies(config),
|
|
30
|
-
"@microsoft/api-extractor": "^7.40.3",
|
|
31
|
-
rimraf: "^5.0.5",
|
|
32
|
-
mkdirp: "^3.0.1",
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function getStandaloneDevDependencies(config) {
|
|
37
|
-
return {
|
|
38
|
-
...getAzurePackageDevDependencies(config),
|
|
39
|
-
"@microsoft/api-extractor": "^7.40.3",
|
|
40
|
-
...getStandaloneCjsDevDependencies(config),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function getStandaloneCjsDevDependencies(config) {
|
|
44
|
-
if (config.moduleKind !== "cjs") {
|
|
45
|
-
return {};
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
"@rollup/plugin-commonjs": "^24.0.0",
|
|
49
|
-
"@rollup/plugin-json": "^6.0.0",
|
|
50
|
-
"@rollup/plugin-multi-entry": "^6.0.0",
|
|
51
|
-
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
52
|
-
...(config.moduleKind === "cjs" && config.withTests && { "cross-env": "^7.0.2" }),
|
|
53
|
-
rollup: "^2.66.1",
|
|
54
|
-
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
55
|
-
"uglify-js": "^3.4.9",
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function getAzureStandaloneScripts(config) {
|
|
59
|
-
const testScripts = {
|
|
60
|
-
"test:browser": "karma start --single-run",
|
|
61
|
-
"test:node": `nyc mocha -r esm --require source-map-support/register --timeout 5000000 --full-trace "dist-esm/test/{,!(browser)/**/}*.spec.js"`,
|
|
62
|
-
test: "npm run test:node && npm run test:browser",
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
...getCommonPackageScripts(),
|
|
66
|
-
clean: "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
|
67
|
-
...(config.withTests && testScripts),
|
|
68
|
-
...getCjsScripts(config),
|
|
69
|
-
...getEsmScripts(config),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function getCjsScripts(config) {
|
|
73
|
-
if (config.moduleKind !== "cjs") {
|
|
74
|
-
return {};
|
|
75
|
-
}
|
|
76
|
-
const testScripts = {
|
|
77
|
-
"build:test": "tsc -p . && rollup -c 2>&1",
|
|
78
|
-
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
|
|
79
|
-
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
build: "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api",
|
|
83
|
-
...(config.withTests && testScripts),
|
|
84
|
-
minify: "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function getEsmScripts(config) {
|
|
88
|
-
if (config.moduleKind !== "esm") {
|
|
89
|
-
return {};
|
|
90
|
-
}
|
|
91
|
-
const testScripts = {
|
|
92
|
-
test: "npm run clean && tshy && npm run unit-test:node && npm run unit-test:browser && npm run integration-test",
|
|
93
|
-
"test:node": "vitest -c vitest.config.ts",
|
|
94
|
-
"test:browser": "vitest -c vitest.browser.config.ts",
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
build: "npm run clean && tshy && npm run extract-api",
|
|
98
|
-
...(config.withTests && testScripts),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=build-azure-standalone-package.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-azure-standalone-package.js","sourceRoot":"","sources":["../../../../../src/rlc-common/metadata/package-json/build-azure-standalone-package.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RLCModel } from "../interfaces.js";
|
|
2
|
-
|
|
3
|
-
export function isAzureMonorepoPackage(model: RLCModel): boolean {
|
|
4
|
-
return Boolean(model.options?.azureSdkForJs);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function isAzureStandalonePackage(model: RLCModel): boolean {
|
|
8
|
-
return !model.options?.azureSdkForJs;
|
|
9
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { Project } from "ts-morph";
|
|
5
|
-
import { RLCModel } from "../interfaces.js";
|
|
6
|
-
|
|
7
|
-
export function buildRollupConfig(model: RLCModel) {
|
|
8
|
-
const azureSdkForJs = Boolean(model.options?.azureSdkForJs);
|
|
9
|
-
// Only generate the file when it is not in sdk repo
|
|
10
|
-
if (azureSdkForJs === true || azureSdkForJs === undefined) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const project = new Project({ useInMemoryFileSystem: true });
|
|
15
|
-
const filePath = "rollup.config.js";
|
|
16
|
-
const rollupFile = project.createSourceFile(filePath, undefined, {
|
|
17
|
-
overwrite: true,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
rollupFile.addStatements(
|
|
21
|
-
`import nodeResolve from "@rollup/plugin-node-resolve";
|
|
22
|
-
import cjs from "@rollup/plugin-commonjs";
|
|
23
|
-
import sourcemaps from "rollup-plugin-sourcemaps";
|
|
24
|
-
import multiEntry from "@rollup/plugin-multi-entry";
|
|
25
|
-
import json from "@rollup/plugin-json";
|
|
26
|
-
|
|
27
|
-
import nodeBuiltins from "builtin-modules";
|
|
28
|
-
|
|
29
|
-
// #region Warning Handler
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* A function that can determine whether a rollup warning should be ignored. If
|
|
33
|
-
* the function returns \`true\`, then the warning will not be displayed.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
function ignoreNiseSinonEval(warning) {
|
|
37
|
-
return (
|
|
38
|
-
warning.code === "EVAL" &&
|
|
39
|
-
(warning.id && ((warning.id.includes("node_modules/nise")) ||
|
|
40
|
-
warning.id.includes("node_modules/sinon")) === true)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function ignoreChaiCircularDependency(warning) {
|
|
45
|
-
return (
|
|
46
|
-
warning.code === "CIRCULAR_DEPENDENCY" &&
|
|
47
|
-
(warning.importer && warning.importer.includes("node_modules/chai") === true)
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const warningInhibitors = [
|
|
52
|
-
ignoreChaiCircularDependency,
|
|
53
|
-
ignoreNiseSinonEval
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Construct a warning handler for the shared rollup configuration
|
|
58
|
-
* that ignores certain warnings that are not relevant to testing.
|
|
59
|
-
*/
|
|
60
|
-
function makeOnWarnForTesting() {
|
|
61
|
-
return (warning, warn) => {
|
|
62
|
-
// If every inhibitor returns false (i.e. no inhibitors), then show the warning
|
|
63
|
-
if (warningInhibitors.every(inhib => !inhib(warning))) {
|
|
64
|
-
warn(warning);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// #endregion
|
|
70
|
-
|
|
71
|
-
function makeBrowserTestConfig() {
|
|
72
|
-
const config = {
|
|
73
|
-
input: {
|
|
74
|
-
include: ["dist-esm/test/**/*.spec.js"],
|
|
75
|
-
exclude: ["dist-esm/test/**/node/**"]
|
|
76
|
-
},
|
|
77
|
-
output: {
|
|
78
|
-
file: \`dist-test/index.browser.js\`,
|
|
79
|
-
format: "umd",
|
|
80
|
-
sourcemap: true
|
|
81
|
-
},
|
|
82
|
-
preserveSymlinks: false,
|
|
83
|
-
plugins: [
|
|
84
|
-
multiEntry({ exports: false }),
|
|
85
|
-
nodeResolve({
|
|
86
|
-
mainFields: ["module", "browser"]
|
|
87
|
-
}),
|
|
88
|
-
cjs(),
|
|
89
|
-
json(),
|
|
90
|
-
sourcemaps()
|
|
91
|
-
//viz({ filename: "dist-test/browser-stats.html", sourcemap: true })
|
|
92
|
-
],
|
|
93
|
-
onwarn: makeOnWarnForTesting(),
|
|
94
|
-
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0,
|
|
95
|
-
// rollup started respecting the "sideEffects" field in package.json. Since
|
|
96
|
-
// our package.json sets "sideEffects=false", this also applies to test
|
|
97
|
-
// code, which causes all tests to be removed by tree-shaking.
|
|
98
|
-
treeshake: false
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return config;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const defaultConfigurationOptions = {
|
|
105
|
-
disableBrowserBundle: false
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export function makeConfig(
|
|
109
|
-
pkg,
|
|
110
|
-
options
|
|
111
|
-
) {
|
|
112
|
-
options = {
|
|
113
|
-
...defaultConfigurationOptions,
|
|
114
|
-
...(options || {})
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const baseConfig = {
|
|
118
|
-
// Use the package's module field if it has one
|
|
119
|
-
input: pkg["module"] || "dist-esm/src/index.js",
|
|
120
|
-
external: [
|
|
121
|
-
...nodeBuiltins,
|
|
122
|
-
...Object.keys(pkg.dependencies),
|
|
123
|
-
...Object.keys(pkg.devDependencies)
|
|
124
|
-
],
|
|
125
|
-
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
|
|
126
|
-
preserveSymlinks: false,
|
|
127
|
-
plugins: [sourcemaps(), nodeResolve()]
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const config = [baseConfig];
|
|
131
|
-
|
|
132
|
-
if (!options.disableBrowserBundle) {
|
|
133
|
-
config.push(makeBrowserTestConfig());
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return config;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export default makeConfig(require("./package.json"));`,
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
path: filePath,
|
|
144
|
-
content: rollupFile.getFullText(),
|
|
145
|
-
};
|
|
146
|
-
}
|