@azure/api-management-custom-widgets-scaffolder 1.0.0-beta.3 → 1.0.0-beta.4
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/bin/execute.js
CHANGED
|
@@ -12,13 +12,7 @@ var chalk = require('chalk');
|
|
|
12
12
|
var glob = require('glob');
|
|
13
13
|
var mustache = require('mustache');
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var inquirer__default = /*#__PURE__*/_interopDefaultLegacy(inquirer);
|
|
18
|
-
var Parser__default = /*#__PURE__*/_interopDefaultLegacy(Parser);
|
|
19
|
-
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
20
|
-
var mustache__default = /*#__PURE__*/_interopDefaultLegacy(mustache);
|
|
21
|
-
|
|
15
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
22
16
|
// Copyright (c) Microsoft Corporation.
|
|
23
17
|
// Licensed under the MIT license.
|
|
24
18
|
/**
|
|
@@ -33,10 +27,11 @@ const OVERRIDE_DEFAULT_PORT = 3000;
|
|
|
33
27
|
const TECHNOLOGIES = ["typescript", "react", "vue"];
|
|
34
28
|
/**
|
|
35
29
|
* Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
|
|
30
|
+
* Prefix "cw-" to avoid conflicts with existing widgets.
|
|
36
31
|
*
|
|
37
32
|
* @param displayName - User defined name of the custom widget.
|
|
38
33
|
*/
|
|
39
|
-
const displayNameToName = (displayName) => encodeURIComponent(displayName
|
|
34
|
+
const displayNameToName = (displayName) => encodeURIComponent(("cw-" + displayName)
|
|
40
35
|
.normalize("NFD")
|
|
41
36
|
.toLowerCase()
|
|
42
37
|
.replace(/[\u0300-\u036f]/g, "")
|
|
@@ -49,6 +44,7 @@ const displayNameToName = (displayName) => encodeURIComponent(displayName
|
|
|
49
44
|
const widgetFolderName = (name) => `azure-api-management-widget-${name}`;
|
|
50
45
|
|
|
51
46
|
// Copyright (c) Microsoft Corporation.
|
|
47
|
+
// Licensed under the MIT license.
|
|
52
48
|
const fieldIdToName = {
|
|
53
49
|
displayName: "Widget display name",
|
|
54
50
|
technology: "Technology",
|
|
@@ -113,7 +109,7 @@ const validateMiscConfig = {
|
|
|
113
109
|
return validateUrl(fieldIdToName.openUrl)(input);
|
|
114
110
|
},
|
|
115
111
|
};
|
|
116
|
-
const promptWidgetConfig = (partial) =>
|
|
112
|
+
const promptWidgetConfig = (partial) => inquirer.prompt([
|
|
117
113
|
{
|
|
118
114
|
name: "displayName",
|
|
119
115
|
type: "input",
|
|
@@ -131,7 +127,7 @@ const promptWidgetConfig = (partial) => inquirer__default["default"].prompt([
|
|
|
131
127
|
],
|
|
132
128
|
},
|
|
133
129
|
], partial);
|
|
134
|
-
const promptServiceInformation = (partial) =>
|
|
130
|
+
const promptServiceInformation = (partial) => inquirer.prompt([
|
|
135
131
|
{
|
|
136
132
|
name: "resourceId",
|
|
137
133
|
type: "input",
|
|
@@ -159,7 +155,7 @@ const promptServiceInformation = (partial) => inquirer__default["default"].promp
|
|
|
159
155
|
message: fieldIdToName.apiVersion + " (optional; e.g., 2021-08-01)",
|
|
160
156
|
},
|
|
161
157
|
], partial);
|
|
162
|
-
const promptMiscConfig = (partial) =>
|
|
158
|
+
const promptMiscConfig = (partial) => inquirer.prompt([
|
|
163
159
|
{
|
|
164
160
|
name: "openUrl",
|
|
165
161
|
type: "input",
|
|
@@ -756,7 +752,7 @@ const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supporte
|
|
|
756
752
|
|
|
757
753
|
let __dirname$1;
|
|
758
754
|
try {
|
|
759
|
-
__dirname$1 = url.fileURLToPath((typeof document === 'undefined' ?
|
|
755
|
+
__dirname$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('execute.js', document.baseURI).href)));
|
|
760
756
|
} catch (e) {
|
|
761
757
|
__dirname$1 = process.cwd();
|
|
762
758
|
}
|
|
@@ -778,7 +774,7 @@ const mainFilename = __dirname$1.substring(0, __dirname$1.lastIndexOf('node_modu
|
|
|
778
774
|
},
|
|
779
775
|
getProcessArgvBin,
|
|
780
776
|
mainFilename: mainFilename || process.cwd(),
|
|
781
|
-
Parser
|
|
777
|
+
Parser,
|
|
782
778
|
path: {
|
|
783
779
|
basename: path.basename,
|
|
784
780
|
dirname: path.dirname,
|
|
@@ -812,6 +808,7 @@ const mainFilename = __dirname$1.substring(0, __dirname$1.lastIndexOf('node_modu
|
|
|
812
808
|
});
|
|
813
809
|
|
|
814
810
|
// Copyright (c) Microsoft Corporation.
|
|
811
|
+
// Licensed under the MIT license.
|
|
815
812
|
const extractConfigFromArgs = (argv, validateConfig, red) => {
|
|
816
813
|
const configPartial = {};
|
|
817
814
|
let missing = false;
|
|
@@ -837,7 +834,7 @@ const extractConfigFromArgs = (argv, validateConfig, red) => {
|
|
|
837
834
|
return { configPartial, missing };
|
|
838
835
|
};
|
|
839
836
|
const buildGetConfig = (gray, red) => {
|
|
840
|
-
const argv =
|
|
837
|
+
const argv = Parser(hideBin(process.argv));
|
|
841
838
|
return async (promptForConfig, validateConfig) => {
|
|
842
839
|
const { configPartial, missing } = extractConfigFromArgs(argv, validateConfig, red);
|
|
843
840
|
if (missing || !Object.values(configPartial).length) {
|
|
@@ -852,6 +849,7 @@ const buildGetConfig = (gray, red) => {
|
|
|
852
849
|
};
|
|
853
850
|
|
|
854
851
|
// Copyright (c) Microsoft Corporation.
|
|
852
|
+
// Licensed under the MIT license.
|
|
855
853
|
async function getTemplates(template) {
|
|
856
854
|
const sharedFiles = await getFiles(path.join(__dirname, "templates", "_shared", "**", "**", "*.*"));
|
|
857
855
|
const templateFiles = await getFiles(path.join(__dirname, "templates", template, "**", "**", "*.*"));
|
|
@@ -866,6 +864,7 @@ async function getFiles(path) {
|
|
|
866
864
|
}
|
|
867
865
|
|
|
868
866
|
// Copyright (c) Microsoft Corporation.
|
|
867
|
+
// Licensed under the MIT license.
|
|
869
868
|
const templateSuffix = ".mustache";
|
|
870
869
|
/**
|
|
871
870
|
* Generates a scaffold project of Custom widget for API Managements' Dev Portal.
|
|
@@ -899,7 +898,7 @@ async function generateProject(widgetConfig, deploymentConfig, options = {}) {
|
|
|
899
898
|
const encoding = file.endsWith(".ttf") ? "binary" : "utf8";
|
|
900
899
|
let fileData = await fs.promises.readFile(file, { encoding });
|
|
901
900
|
if (isTemplate) {
|
|
902
|
-
fileData =
|
|
901
|
+
fileData = mustache.render(fileData, {
|
|
903
902
|
name,
|
|
904
903
|
displayName: widgetConfig.displayName,
|
|
905
904
|
config: JSON.stringify(Object.assign(Object.assign({}, widgetConfig), { name }), null, "\t"),
|
|
@@ -929,10 +928,10 @@ async function generateProject(widgetConfig, deploymentConfig, options = {}) {
|
|
|
929
928
|
}
|
|
930
929
|
|
|
931
930
|
const log = console.log;
|
|
932
|
-
const white = (msg) => log(
|
|
933
|
-
const green = (msg) => log(
|
|
934
|
-
const red = (msg) => log(
|
|
935
|
-
const gray = (msg) => log(
|
|
931
|
+
const white = (msg) => log(chalk.white(msg));
|
|
932
|
+
const green = (msg) => log(chalk.green(msg));
|
|
933
|
+
const red = (msg) => log(chalk.red(msg));
|
|
934
|
+
const gray = (msg) => log(chalk.gray(msg));
|
|
936
935
|
async function main() {
|
|
937
936
|
green("\nThis tool generates code scaffold for custom widgets in the Azure API Management’s developer portal. Learn more at https://aka.ms/apimdocs/portal/customwidgets.\n");
|
|
938
937
|
const getConfig = buildGetConfig(gray, red);
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var path = require('path');
|
|
4
6
|
var fs = require('fs');
|
|
5
7
|
var glob = require('glob');
|
|
@@ -19,10 +21,11 @@ const OVERRIDE_DEFAULT_PORT = 3000;
|
|
|
19
21
|
const TECHNOLOGIES = ["typescript", "react", "vue"];
|
|
20
22
|
/**
|
|
21
23
|
* Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
|
|
24
|
+
* Prefix "cw-" to avoid conflicts with existing widgets.
|
|
22
25
|
*
|
|
23
26
|
* @param displayName - User defined name of the custom widget.
|
|
24
27
|
*/
|
|
25
|
-
const displayNameToName = (displayName) => encodeURIComponent(displayName
|
|
28
|
+
const displayNameToName = (displayName) => encodeURIComponent(("cw-" + displayName)
|
|
26
29
|
.normalize("NFD")
|
|
27
30
|
.toLowerCase()
|
|
28
31
|
.replace(/[\u0300-\u036f]/g, "")
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/scaffolding.ts","../src/getTemplates.ts","../src/generateProject.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.\n */\nexport const OVERRIDE_PORT_KEY = \"MS_APIM_CW_localhost_port\";\n/**\n * Default port for running local dev server on.\n */\nexport const OVERRIDE_DEFAULT_PORT = 3000;\n\n/** All supported technologies to scaffold a widget in. */\nexport type ScaffoldTech = \"typescript\" | \"react\" | \"vue\";\n\n/** List of all supported technologies to scaffold a widget in. */\nexport const TECHNOLOGIES: ScaffoldTech[] = [\"typescript\", \"react\", \"vue\"];\n\n/** Main data which DevPortal needs for every custom widget. */\nexport interface WidgetConfig {\n /** Name of the custom widget which is displayed in DevPortal. */\n displayName: string;\n /** Technology to use to scaffold the widget. */\n technology: ScaffoldTech;\n /** Optional URL for a custom icon, which will be displayed in DevPortal widget list. */\n iconUrl?: string;\n}\n\n/** Data needed for deployment. */\nexport interface ServiceInformation {\n /** Management API endpoint to use (e.g. management.azure.com). */\n managementApiEndpoint: string;\n /** resourceId of your APIM service, must be in this format: subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ApiManagement/service/<service-name> */\n resourceId: string;\n /** optional override which API version to use during deployment */\n apiVersion?: string;\n}\n\n/** Miscellaneous data for scaffolding of a custom widget which will not be stored in DevPortal. */\nexport interface Options {\n /** The URL to open after development server of the widget is started (URL of your Developer Portal). If you don't want to use this feature, set it to `false`. If you want to open just the widget page, set it to `true`. */\n openUrl?: string;\n /** advance configuration option for the deploy function - tenant ID for InteractiveBrowserCredentialNodeOptions */\n configAdvancedTenantId?: string;\n /** advance configuration option for the deploy function - redirect URI for InteractiveBrowserCredentialNodeOptions */\n configAdvancedRedirectUri?: string;\n}\n\nexport type Configs = WidgetConfig | ServiceInformation | Options;\n\n/**\n * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as \"name\".\n *\n * @param displayName - User defined name of the custom widget.\n */\nexport const displayNameToName = (displayName: string): string =>\n encodeURIComponent(\n displayName\n .normalize(\"NFD\")\n .toLowerCase()\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/[^a-z0-9-]/g, \"-\")\n );\n\n/**\n * Returns name of the folder for widget project.\n *\n * @param name - name of the widget\n */\nexport const widgetFolderName = (name: string): string => `azure-api-management-widget-${name}`;\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ScaffoldTech } from \"./scaffolding\";\nimport { glob } from \"glob\";\nimport { join as pathJoin } from \"path\";\n\nexport async function getTemplates(template: ScaffoldTech): Promise<string[]> {\n const sharedFiles = await getFiles(\n pathJoin(__dirname, \"templates\", \"_shared\", \"**\", \"**\", \"*.*\")\n );\n const templateFiles = await getFiles(\n pathJoin(__dirname, \"templates\", template, \"**\", \"**\", \"*.*\")\n );\n return [...sharedFiles, ...templateFiles];\n}\n\nasync function getFiles(path: string): Promise<string[]> {\n // Starting from glob v8 `\\` is only used as an escape character, and never as a path separator in glob patterns.\n // Glob pattern paths must use forward-slashes as path separators.\n // See https://github.com/isaacs/node-glob/blob/af57da21c7722bb6edb687ccd4ad3b99d3e7a333/changelog.md#80\n const normalizedPath = path.replace(/\\\\/g, \"/\");\n return glob(normalizedPath, { dot: true });\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ServiceInformation,\n OVERRIDE_DEFAULT_PORT,\n OVERRIDE_PORT_KEY,\n Options,\n WidgetConfig,\n displayNameToName,\n widgetFolderName,\n} from \"./scaffolding\";\nimport { join as joinPath, parse as parsePath } from \"path\";\nimport { promises as fs } from \"fs\";\nimport { getTemplates } from \"./getTemplates\";\nimport mustache from \"mustache\";\n\nconst templateSuffix = \".mustache\";\n\n/**\n * Generates a scaffold project of Custom widget for API Managements' Dev Portal.\n *\n * @param widgetConfig - JSON object with data required by DevPortal to handle a widget integration.\n * @param deploymentConfig - JSON object with data for deployment.\n * @param options - JSON object with other data, which will not be stored in the DevPortal.\n */\nexport async function generateProject(\n widgetConfig: WidgetConfig,\n deploymentConfig: ServiceInformation,\n options: Options = {}\n): Promise<void> {\n const { openUrl, configAdvancedTenantId, configAdvancedRedirectUri } = options;\n const openUrlParsed = openUrl ? new URL(openUrl) : null;\n if (openUrlParsed) {\n openUrlParsed.searchParams.append(OVERRIDE_PORT_KEY, String(OVERRIDE_DEFAULT_PORT));\n }\n\n const name = displayNameToName(widgetConfig.displayName);\n const serverSettings = {\n port: OVERRIDE_DEFAULT_PORT,\n open: openUrlParsed ? openUrlParsed.toString() : true,\n };\n\n const configAdditional = {\n interactiveBrowserCredentialOptions: { redirectUri: \"http://localhost:1337\" } as {\n redirectUri: string;\n tenantId?: string;\n },\n };\n if (configAdvancedTenantId) {\n configAdditional.interactiveBrowserCredentialOptions.tenantId = configAdvancedTenantId;\n }\n if (configAdvancedRedirectUri) {\n configAdditional.interactiveBrowserCredentialOptions.redirectUri = configAdvancedRedirectUri;\n }\n\n const renderTemplate = async (file: string): Promise<void> => {\n const isTemplate = file.endsWith(templateSuffix);\n const encoding = file.endsWith(\".ttf\") ? \"binary\" : \"utf8\";\n let fileData = await fs.readFile(file, { encoding });\n if (isTemplate) {\n fileData = mustache.render(fileData, {\n name,\n displayName: widgetConfig.displayName,\n config: JSON.stringify({ ...widgetConfig, name }, null, \"\\t\"),\n configDeploy: JSON.stringify(deploymentConfig, null, \"\\t\"),\n configAdditional: JSON.stringify(configAdditional, null, \"\\t\"),\n serverSettings: JSON.stringify(serverSettings, null, \"\\t\"),\n });\n }\n\n let relativePath = file;\n if (__dirname.includes(\"\\\\\")) {\n relativePath = relativePath.replace(/\\//g, \"\\\\\");\n }\n relativePath = relativePath\n .replace(joinPath(__dirname, \"templates\", \"_shared\"), \"\")\n .replace(joinPath(__dirname, \"templates\", widgetConfig.technology), \"\")\n .replace(templateSuffix, \"\");\n const newFilePath = joinPath(process.cwd(), widgetFolderName(name), relativePath);\n const dir = parsePath(newFilePath).dir;\n\n await fs.mkdir(dir, { recursive: true });\n await fs.writeFile(newFilePath, fileData, { encoding });\n };\n\n const templates = await getTemplates(widgetConfig.technology);\n for (const file of Object.values(templates)) {\n await renderTemplate(file);\n }\n\n return;\n}\n"],"names":["pathJoin","glob","fs","joinPath","parsePath"],"mappings":";;;;;;;AAAA;AACA;AAEA;;AAEG;AACI,MAAM,iBAAiB,GAAG,4BAA4B;AAC7D;;AAEG;AACI,MAAM,qBAAqB,GAAG,KAAK;AAK1C;AACa,MAAA,YAAY,GAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE;AAkC3E;;;;AAIG;AACU,MAAA,iBAAiB,GAAG,CAAC,WAAmB,KACnD,kBAAkB,CAChB,WAAW;KACR,SAAS,CAAC,KAAK,CAAC;AAChB,KAAA,WAAW,EAAE;AACb,KAAA,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AAC/B,KAAA,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,EAC9B;AAEJ;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,KAAa,CAAA,4BAAA,EAA+B,IAAI,CAAA;;ACrE7F;AACA;AAMO,eAAe,YAAY,CAAC,QAAsB,EAAA;IACvD,M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copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.\n */\nexport const OVERRIDE_PORT_KEY = \"MS_APIM_CW_localhost_port\";\n/**\n * Default port for running local dev server on.\n */\nexport const OVERRIDE_DEFAULT_PORT = 3000;\n\n/** All supported technologies to scaffold a widget in. */\nexport type ScaffoldTech = \"typescript\" | \"react\" | \"vue\";\n\n/** List of all supported technologies to scaffold a widget in. */\nexport const TECHNOLOGIES: ScaffoldTech[] = [\"typescript\", \"react\", \"vue\"];\n\n/** Main data which DevPortal needs for every custom widget. */\nexport interface WidgetConfig {\n /** Name of the custom widget which is displayed in DevPortal. */\n displayName: string;\n /** Technology to use to scaffold the widget. */\n technology: ScaffoldTech;\n /** Optional URL for a custom icon, which will be displayed in DevPortal widget list. */\n iconUrl?: string;\n}\n\n/** Data needed for deployment. */\nexport interface ServiceInformation {\n /** Management API endpoint to use (e.g. management.azure.com). */\n managementApiEndpoint: string;\n /** resourceId of your APIM service, must be in this format: subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ApiManagement/service/<service-name> */\n resourceId: string;\n /** optional override which API version to use during deployment */\n apiVersion?: string;\n}\n\n/** Miscellaneous data for scaffolding of a custom widget which will not be stored in DevPortal. */\nexport interface Options {\n /** The URL to open after development server of the widget is started (URL of your Developer Portal). If you don't want to use this feature, set it to `false`. If you want to open just the widget page, set it to `true`. */\n openUrl?: string;\n /** advance configuration option for the deploy function - tenant ID for InteractiveBrowserCredentialNodeOptions */\n configAdvancedTenantId?: string;\n /** advance configuration option for the deploy function - redirect URI for InteractiveBrowserCredentialNodeOptions */\n configAdvancedRedirectUri?: string;\n}\n\nexport type Configs = WidgetConfig | ServiceInformation | Options;\n\n/**\n * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as \"name\".\n * Prefix \"cw-\" to avoid conflicts with existing widgets.\n *\n * @param displayName - User defined name of the custom widget.\n */\nexport const displayNameToName = (displayName: string): string =>\n encodeURIComponent(\n (\"cw-\" + displayName)\n .normalize(\"NFD\")\n .toLowerCase()\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/[^a-z0-9-]/g, \"-\")\n );\n\n/**\n * Returns name of the folder for widget project.\n *\n * @param name - name of the widget\n */\nexport const widgetFolderName = (name: string): string => `azure-api-management-widget-${name}`;\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ScaffoldTech } from \"./scaffolding\";\nimport { glob } from \"glob\";\nimport { join as pathJoin } from \"path\";\n\nexport async function getTemplates(template: ScaffoldTech): Promise<string[]> {\n const sharedFiles = await getFiles(\n pathJoin(__dirname, \"templates\", \"_shared\", \"**\", \"**\", \"*.*\")\n );\n const templateFiles = await getFiles(\n pathJoin(__dirname, \"templates\", template, \"**\", \"**\", \"*.*\")\n );\n return [...sharedFiles, ...templateFiles];\n}\n\nasync function getFiles(path: string): Promise<string[]> {\n // Starting from glob v8 `\\` is only used as an escape character, and never as a path separator in glob patterns.\n // Glob pattern paths must use forward-slashes as path separators.\n // See https://github.com/isaacs/node-glob/blob/af57da21c7722bb6edb687ccd4ad3b99d3e7a333/changelog.md#80\n const normalizedPath = path.replace(/\\\\/g, \"/\");\n return glob(normalizedPath, { dot: true });\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ServiceInformation,\n OVERRIDE_DEFAULT_PORT,\n OVERRIDE_PORT_KEY,\n Options,\n WidgetConfig,\n displayNameToName,\n widgetFolderName,\n} from \"./scaffolding\";\nimport { join as joinPath, parse as parsePath } from \"path\";\nimport { promises as fs } from \"fs\";\nimport { getTemplates } from \"./getTemplates\";\nimport mustache from \"mustache\";\n\nconst templateSuffix = \".mustache\";\n\n/**\n * Generates a scaffold project of Custom widget for API Managements' Dev Portal.\n *\n * @param widgetConfig - JSON object with data required by DevPortal to handle a widget integration.\n * @param deploymentConfig - JSON object with data for deployment.\n * @param options - JSON object with other data, which will not be stored in the DevPortal.\n */\nexport async function generateProject(\n widgetConfig: WidgetConfig,\n deploymentConfig: ServiceInformation,\n options: Options = {}\n): Promise<void> {\n const { openUrl, configAdvancedTenantId, configAdvancedRedirectUri } = options;\n const openUrlParsed = openUrl ? new URL(openUrl) : null;\n if (openUrlParsed) {\n openUrlParsed.searchParams.append(OVERRIDE_PORT_KEY, String(OVERRIDE_DEFAULT_PORT));\n }\n\n const name = displayNameToName(widgetConfig.displayName);\n const serverSettings = {\n port: OVERRIDE_DEFAULT_PORT,\n open: openUrlParsed ? openUrlParsed.toString() : true,\n };\n\n const configAdditional = {\n interactiveBrowserCredentialOptions: { redirectUri: \"http://localhost:1337\" } as {\n redirectUri: string;\n tenantId?: string;\n },\n };\n if (configAdvancedTenantId) {\n configAdditional.interactiveBrowserCredentialOptions.tenantId = configAdvancedTenantId;\n }\n if (configAdvancedRedirectUri) {\n configAdditional.interactiveBrowserCredentialOptions.redirectUri = configAdvancedRedirectUri;\n }\n\n const renderTemplate = async (file: string): Promise<void> => {\n const isTemplate = file.endsWith(templateSuffix);\n const encoding = file.endsWith(\".ttf\") ? \"binary\" : \"utf8\";\n let fileData = await fs.readFile(file, { encoding });\n if (isTemplate) {\n fileData = mustache.render(fileData, {\n name,\n displayName: widgetConfig.displayName,\n config: JSON.stringify({ ...widgetConfig, name }, null, \"\\t\"),\n configDeploy: JSON.stringify(deploymentConfig, null, \"\\t\"),\n configAdditional: JSON.stringify(configAdditional, null, \"\\t\"),\n serverSettings: JSON.stringify(serverSettings, null, \"\\t\"),\n });\n }\n\n let relativePath = file;\n if (__dirname.includes(\"\\\\\")) {\n relativePath = relativePath.replace(/\\//g, \"\\\\\");\n }\n relativePath = relativePath\n .replace(joinPath(__dirname, \"templates\", \"_shared\"), \"\")\n .replace(joinPath(__dirname, \"templates\", widgetConfig.technology), \"\")\n .replace(templateSuffix, \"\");\n const newFilePath = joinPath(process.cwd(), widgetFolderName(name), relativePath);\n const dir = parsePath(newFilePath).dir;\n\n await fs.mkdir(dir, { recursive: true });\n await fs.writeFile(newFilePath, fileData, { encoding });\n };\n\n const templates = await getTemplates(widgetConfig.technology);\n for (const file of Object.values(templates)) {\n await renderTemplate(file);\n }\n\n return;\n}\n"],"names":["pathJoin","glob","fs","joinPath","parsePath"],"mappings":";;;;;;;;;AAAA;AACA;AAEA;;AAEG;AACI,MAAM,iBAAiB,GAAG,4BAA4B;AAC7D;;AAEG;AACI,MAAM,qBAAqB,GAAG,KAAK;AAK1C;AACa,MAAA,YAAY,GAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE;AAkC3E;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,WAAmB,KACnD,kBAAkB,CAChB,CAAC,KAAK,GAAG,WAAW;KACjB,SAAS,CAAC,KAAK,CAAC;AAChB,KAAA,WAAW,EAAE;AACb,KAAA,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AAC/B,KAAA,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,EAC9B;AAEJ;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,KAAa,CAAA,4BAAA,EAA+B,IAAI,CAAA;;ACtE7F;AACA;AAMO,eAAe,YAAY,CAAC,QAAsB,EAAA;IACvD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAChCA,SAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAC/D,CAAC;IACF,MAAM,aAAa,GAAG,MAAM,QAAQ,CAClCA,SAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAC9D,CAAC;AACF,IAAA,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,CAAC;AAC5C,CAAC;AAED,eAAe,QAAQ,CAAC,IAAY,EAAA;;;;IAIlC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAA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,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AAC/B,QAAA,MAAM,WAAW,GAAGA,SAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;QAClF,MAAM,GAAG,GAAGC,UAAS,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC;AAEvC,QAAA,MAAMF,WAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACzC,QAAA,MAAMA,WAAE,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC1D,KAAC,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC9D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;AAC3C,QAAA,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;AAC5B,KAAA;IAED,OAAO;AACT;;;;;;;;;"}
|
|
@@ -12,10 +12,11 @@ export const OVERRIDE_DEFAULT_PORT = 3000;
|
|
|
12
12
|
export const TECHNOLOGIES = ["typescript", "react", "vue"];
|
|
13
13
|
/**
|
|
14
14
|
* Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
|
|
15
|
+
* Prefix "cw-" to avoid conflicts with existing widgets.
|
|
15
16
|
*
|
|
16
17
|
* @param displayName - User defined name of the custom widget.
|
|
17
18
|
*/
|
|
18
|
-
export const displayNameToName = (displayName) => encodeURIComponent(displayName
|
|
19
|
+
export const displayNameToName = (displayName) => encodeURIComponent(("cw-" + displayName)
|
|
19
20
|
.normalize("NFD")
|
|
20
21
|
.toLowerCase()
|
|
21
22
|
.replace(/[\u0300-\u036f]/g, "")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffolding.js","sourceRoot":"","sources":["../../src/scaffolding.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AAC7D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAK1C,kEAAkE;AAClE,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAkC3E
|
|
1
|
+
{"version":3,"file":"scaffolding.js","sourceRoot":"","sources":["../../src/scaffolding.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AAC7D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAK1C,kEAAkE;AAClE,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAkC3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAC/D,kBAAkB,CAChB,CAAC,KAAK,GAAG,WAAW,CAAC;KAClB,SAAS,CAAC,KAAK,CAAC;KAChB,WAAW,EAAE;KACb,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;KAC/B,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAC/B,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,+BAA+B,IAAI,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Unique identifier under which is specified which port to use for injecting locally hosted custom widget to a running DevPortal instance.\n */\nexport const OVERRIDE_PORT_KEY = \"MS_APIM_CW_localhost_port\";\n/**\n * Default port for running local dev server on.\n */\nexport const OVERRIDE_DEFAULT_PORT = 3000;\n\n/** All supported technologies to scaffold a widget in. */\nexport type ScaffoldTech = \"typescript\" | \"react\" | \"vue\";\n\n/** List of all supported technologies to scaffold a widget in. */\nexport const TECHNOLOGIES: ScaffoldTech[] = [\"typescript\", \"react\", \"vue\"];\n\n/** Main data which DevPortal needs for every custom widget. */\nexport interface WidgetConfig {\n /** Name of the custom widget which is displayed in DevPortal. */\n displayName: string;\n /** Technology to use to scaffold the widget. */\n technology: ScaffoldTech;\n /** Optional URL for a custom icon, which will be displayed in DevPortal widget list. */\n iconUrl?: string;\n}\n\n/** Data needed for deployment. */\nexport interface ServiceInformation {\n /** Management API endpoint to use (e.g. management.azure.com). */\n managementApiEndpoint: string;\n /** resourceId of your APIM service, must be in this format: subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ApiManagement/service/<service-name> */\n resourceId: string;\n /** optional override which API version to use during deployment */\n apiVersion?: string;\n}\n\n/** Miscellaneous data for scaffolding of a custom widget which will not be stored in DevPortal. */\nexport interface Options {\n /** The URL to open after development server of the widget is started (URL of your Developer Portal). If you don't want to use this feature, set it to `false`. If you want to open just the widget page, set it to `true`. */\n openUrl?: string;\n /** advance configuration option for the deploy function - tenant ID for InteractiveBrowserCredentialNodeOptions */\n configAdvancedTenantId?: string;\n /** advance configuration option for the deploy function - redirect URI for InteractiveBrowserCredentialNodeOptions */\n configAdvancedRedirectUri?: string;\n}\n\nexport type Configs = WidgetConfig | ServiceInformation | Options;\n\n/**\n * Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as \"name\".\n * Prefix \"cw-\" to avoid conflicts with existing widgets.\n *\n * @param displayName - User defined name of the custom widget.\n */\nexport const displayNameToName = (displayName: string): string =>\n encodeURIComponent(\n (\"cw-\" + displayName)\n .normalize(\"NFD\")\n .toLowerCase()\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/[^a-z0-9-]/g, \"-\")\n );\n\n/**\n * Returns name of the folder for widget project.\n *\n * @param name - name of the widget\n */\nexport const widgetFolderName = (name: string): string => `azure-api-management-widget-${name}`;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/api-management-custom-widgets-scaffolder",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sdk-type": "client",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"create-apimanagement-widget": "bin/execute.js"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"azure",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"build:browser": "tsc -p . && dev-tool run bundle --browser-test=false",
|
|
42
42
|
"build:node": "tsc -p . && dev-tool run bundle",
|
|
43
43
|
"build:test": "echo skip",
|
|
44
|
-
"bundle:bin": "rollup -c rollup.config.bin.
|
|
44
|
+
"bundle:bin": "rollup -c rollup.config.bin.mjs",
|
|
45
45
|
"build:samples": "echo skip",
|
|
46
46
|
"build": "npm run clean && tsc -p . && dev-tool run bundle --browser-test=false && npm run bundle:bin && api-extractor run --local",
|
|
47
47
|
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore --ignore-path ./.prettierignore \"src/templates/**\" \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@microsoft/api-extractor": "^7.31.1",
|
|
67
67
|
"@types/chai": "^4.1.6",
|
|
68
68
|
"@types/mocha": "^10.0.0",
|
|
69
|
-
"@types/node": "^
|
|
69
|
+
"@types/node": "^18.0.0",
|
|
70
70
|
"@types/inquirer": "^8.2.1",
|
|
71
71
|
"@types/yargs": "^17.0.10",
|
|
72
72
|
"@types/yargs-parser": "^21.0.0",
|
|
@@ -76,30 +76,29 @@
|
|
|
76
76
|
"eslint": "^8.0.0",
|
|
77
77
|
"magic-string": "~0.27.0",
|
|
78
78
|
"mocha": "^10.0.0",
|
|
79
|
-
"mocha-junit-reporter": "^2.0.0",
|
|
80
79
|
"prettier": "^2.5.1",
|
|
81
|
-
"
|
|
80
|
+
"c8": "^8.0.0",
|
|
82
81
|
"rimraf": "^3.0.0",
|
|
83
82
|
"ts-node": "^10.0.0",
|
|
84
|
-
"typescript": "~5.
|
|
83
|
+
"typescript": "~5.2.0",
|
|
85
84
|
"util": "^0.12.1",
|
|
86
85
|
"dotenv": "^16.0.0",
|
|
87
86
|
"@azure/test-utils": "^1.0.0",
|
|
88
87
|
"@types/mustache": "^4.2.1",
|
|
89
|
-
"sinon": "^
|
|
90
|
-
"@types/sinon": "^
|
|
88
|
+
"sinon": "^17.0.0",
|
|
89
|
+
"@types/sinon": "^17.0.0"
|
|
91
90
|
},
|
|
92
91
|
"dependencies": {
|
|
93
92
|
"mustache": "^4.2.0",
|
|
94
93
|
"prettier": "^2.5.1",
|
|
95
94
|
"glob": "^9.0.0",
|
|
96
95
|
"tslib": "^2.2.0",
|
|
97
|
-
"typescript": "~5.
|
|
96
|
+
"typescript": "~5.2.0",
|
|
98
97
|
"chalk": "^4.1.2",
|
|
99
98
|
"inquirer": "^8.2.4",
|
|
100
99
|
"yargs": "^17.0.1",
|
|
101
100
|
"yargs-parser": "^21.0.1",
|
|
102
|
-
"rollup": "^
|
|
103
|
-
"@rollup/plugin-node-resolve": "^
|
|
101
|
+
"rollup": "^4.0.0",
|
|
102
|
+
"@rollup/plugin-node-resolve": "^15.0.0"
|
|
104
103
|
}
|
|
105
104
|
}
|
|
@@ -24,6 +24,7 @@ export declare interface DeploymentConfig {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Converts user defined name of a custom widget to a unique ID, which is in context of Dev Portal known as "name".
|
|
27
|
+
* Prefix "cw-" to avoid conflicts with existing widgets.
|
|
27
28
|
*
|
|
28
29
|
* @param displayName - User defined name of the custom widget.
|
|
29
30
|
*/
|