(#864) Convert to type=module in package.json
This commit is contained in:
Родитель
3c1ab13fbd
Коммит
12d4c75ccc
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -2,6 +2,7 @@
|
||||||
"name": "@azure/static-web-apps-cli",
|
"name": "@azure/static-web-apps-cli",
|
||||||
"version": "1.1.10",
|
"version": "1.1.10",
|
||||||
"description": "Azure Static Web Apps CLI",
|
"description": "Azure Static Web Apps CLI",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --detectOpenHandles --silent --verbose",
|
"test": "jest --detectOpenHandles --silent --verbose",
|
||||||
"e2e:start:static": "npm run build && node ./dist/cli/bin.js --config ./cypress/fixtures/static/swa-cli.config.json start static",
|
"e2e:start:static": "npm run build && node ./dist/cli/bin.js --config ./cypress/fixtures/static/swa-cli.config.json start static",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const path = require("path");
|
import path from "node:path";
|
||||||
const fs = require("fs");
|
import fs from "node:fs";
|
||||||
const child_process = require("child_process");
|
import child_process from "node:child_process";
|
||||||
|
|
||||||
let branch = "";
|
let branch = "";
|
||||||
let hash = "";
|
let hash = "";
|
||||||
let build = "DEV";
|
let build = "DEV";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { build } from "./build";
|
import { build } from "./build.js";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
import { convertToNativePaths } from "../../../jest.helpers";
|
import { convertToNativePaths } from "../../../jest.helpers.js";
|
||||||
|
|
||||||
jest.mock("child_process", () => ({
|
jest.mock("child_process", () => ({
|
||||||
execSync: jest.fn(),
|
execSync: jest.fn(),
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { detectProjectFolders, generateConfiguration } from "../../../core/frameworks";
|
import { detectProjectFolders, generateConfiguration } from "../../../core/frameworks/detect.js";
|
||||||
import {
|
import { findUpPackageJsonDir, pathExists } from "../../../core/utils/file.js";
|
||||||
findUpPackageJsonDir,
|
import { isUserOrConfigOption } from "../../../core/utils/options.js";
|
||||||
isUserOrConfigOption,
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
logger,
|
import { readWorkflowFile } from "../../../core/utils/workflow-config.js";
|
||||||
pathExists,
|
import { runCommand } from "../../../core/utils/command.js";
|
||||||
readWorkflowFile,
|
import { swaCliConfigFilename } from "../../../core/utils/cli-config.js";
|
||||||
runCommand,
|
|
||||||
swaCliConfigFilename,
|
|
||||||
} from "../../../core/utils";
|
|
||||||
|
|
||||||
export async function build(options: SWACLIConfig) {
|
export async function build(options: SWACLIConfig) {
|
||||||
const workflowConfig = readWorkflowFile();
|
const workflowConfig = readWorkflowFile();
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./build";
|
|
||||||
export { default as registerBuild } from "./register";
|
|
|
@ -1,7 +1,9 @@
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
import { configureOptions, isUserOption, logger, matchLoadedConfigName } from "../../../core/utils";
|
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
|
||||||
import { build } from "./build";
|
import { matchLoadedConfigName } from "../../../core/utils/cli-config.js";
|
||||||
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
|
import { build } from "./build.js";
|
||||||
|
|
||||||
export default function registerCommand(program: Command) {
|
export default function registerCommand(program: Command) {
|
||||||
program
|
program
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
export * from "./init";
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./init";
|
|
||||||
export { default as registerDb } from "./register";
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { logger, execFileCommand } from "../../../../core";
|
import path from "node:path";
|
||||||
import { init, isValidDatabaseType } from "./init";
|
import fs from "node:fs";
|
||||||
import path from "path";
|
import { logger } from "../../../../core/utils/logger.js";
|
||||||
|
import { execFileCommand } from "../../../../core/utils/command.js";
|
||||||
|
import { init, isValidDatabaseType } from "./init.js";
|
||||||
import {
|
import {
|
||||||
DATA_API_BUILDER_DATABASE_TYPES,
|
DATA_API_BUILDER_DATABASE_TYPES,
|
||||||
DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME,
|
DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME,
|
||||||
DATA_API_BUILDER_DEFAULT_FOLDER,
|
DATA_API_BUILDER_DEFAULT_FOLDER,
|
||||||
} from "../../../../core/constants";
|
} from "../../../../core/constants.js";
|
||||||
import fs from "fs";
|
|
||||||
|
|
||||||
// Replace the imported functions with mocks for testing purposes
|
// Replace the imported functions with mocks for testing purposes
|
||||||
jest.mock("../../../../core/dataApiBuilder", () => ({
|
jest.mock("../../../../core/dataApiBuilder", () => ({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import {
|
import {
|
||||||
DATA_API_BUILDER_BINARY_NAME,
|
DATA_API_BUILDER_BINARY_NAME,
|
||||||
DATA_API_BUILDER_DATABASE_TYPES,
|
DATA_API_BUILDER_DATABASE_TYPES,
|
||||||
|
@ -8,9 +8,10 @@ import {
|
||||||
DATA_API_BUILDER_DEFAULT_REST_PATH,
|
DATA_API_BUILDER_DEFAULT_REST_PATH,
|
||||||
DATA_API_BUILDER_DEFAULT_SCHEMA_FILE_NAME,
|
DATA_API_BUILDER_DEFAULT_SCHEMA_FILE_NAME,
|
||||||
DEFAULT_DATA_API_BUILDER_SCHEMA_CONTENT,
|
DEFAULT_DATA_API_BUILDER_SCHEMA_CONTENT,
|
||||||
} from "../../../../core/constants";
|
} from "../../../../core/constants.js";
|
||||||
import { execFileCommand, logger } from "../../../../core";
|
import { execFileCommand } from "../../../../core/utils/command.js";
|
||||||
import { getDataApiBuilderBinaryPath } from "../../../../core/dataApiBuilder";
|
import { logger } from "../../../../core/utils/logger.js";
|
||||||
|
import { getDataApiBuilderBinaryPath } from "../../../../core/dataApiBuilder/index.js";
|
||||||
|
|
||||||
export async function init(options: SWACLIConfig) {
|
export async function init(options: SWACLIConfig) {
|
||||||
let { databaseType, connectionString, cosmosdb_nosqlContainer, cosmosdb_nosqlDatabase } = options;
|
let { databaseType, connectionString, cosmosdb_nosqlContainer, cosmosdb_nosqlDatabase } = options;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import { configureOptions } from "../../../../core/utils";
|
import { configureOptions } from "../../../../core/utils/options.js";
|
||||||
import { init } from "./init";
|
import { init } from "./init.js";
|
||||||
import { DEFAULT_CONFIG } from "../../../../config";
|
import { DEFAULT_CONFIG } from "../../../../config.js";
|
||||||
|
|
||||||
export default function registerCommand(program: Command) {
|
export default function registerCommand(program: Command) {
|
||||||
const dbCommand = program.command("db [command] [options]").description("Manage your database");
|
const dbCommand = program.command("db [command] [options]").description("Manage your database");
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import child_process from "child_process";
|
import child_process from "node:child_process";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { logger } from "../../../core";
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
import * as accountModule from "../../../core/account";
|
import * as accountModule from "../../../core/account.js";
|
||||||
import * as deployClientModule from "../../../core/deploy-client";
|
import * as deployClientModule from "../../../core/deploy-client.js";
|
||||||
import { deploy } from "./deploy";
|
import { deploy } from "./deploy.js";
|
||||||
import * as loginModule from "../login/login";
|
import * as loginModule from "../login/login.js";
|
||||||
|
|
||||||
const pkg = require(path.join(__dirname, "..", "..", "..", "..", "package.json"));
|
const pkg = require(path.join(__dirname, "..", "..", "..", "..", "package.json"));
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { spawn } from "child_process";
|
import { spawn } from "node:child_process";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import ora, { Ora } from "ora";
|
import ora, { Ora } from "ora";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import {
|
import { findSWAConfigFile } from "../../../core/utils/user-config.js";
|
||||||
findSWAConfigFile,
|
import { getCurrentSwaCliConfigFromFile, updateSwaCliConfigFile } from "../../../core/utils/cli-config.js";
|
||||||
getCurrentSwaCliConfigFromFile,
|
import { logger, logGitHubIssueMessageAndExit } from "../../../core/utils/logger.js";
|
||||||
isUserOrConfigOption,
|
import { isUserOrConfigOption } from "../../../core/utils/options.js";
|
||||||
logger,
|
import { readWorkflowFile } from "../../../core/utils/workflow-config.js";
|
||||||
logGitHubIssueMessageAndExit,
|
import { chooseOrCreateProjectDetails, getStaticSiteDeployment } from "../../../core/account.js";
|
||||||
readWorkflowFile,
|
import { DEFAULT_RUNTIME_LANGUAGE } from "../../../core/constants.js";
|
||||||
updateSwaCliConfigFile,
|
import { cleanUp, getDeployClientPath } from "../../../core/deploy-client.js";
|
||||||
} from "../../../core";
|
import { swaCLIEnv } from "../../../core/env.js";
|
||||||
import { chooseOrCreateProjectDetails, getStaticSiteDeployment } from "../../../core/account";
|
import { getDefaultVersion } from "../../../core/functions-versions.js";
|
||||||
import { DEFAULT_RUNTIME_LANGUAGE } from "../../../core/constants";
|
import { login } from "../login/login.js";
|
||||||
import { cleanUp, getDeployClientPath } from "../../../core/deploy-client";
|
|
||||||
import { swaCLIEnv } from "../../../core/env";
|
|
||||||
import { getDefaultVersion } from "../../../core/functions-versions";
|
|
||||||
import { login } from "../login";
|
|
||||||
|
|
||||||
const packageInfo = require(path.join(__dirname, "..", "..", "..", "..", "package.json"));
|
const packageInfo = require(path.join(__dirname, "..", "..", "..", "..", "package.json"));
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./deploy";
|
|
||||||
export { default as registerDeploy } from "./register";
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
import { configureOptions, isUserOption, logger, matchLoadedConfigName } from "../../../core";
|
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
|
||||||
import { addSharedLoginOptionsToCommand } from "../login";
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
import { deploy } from "./deploy";
|
import { matchLoadedConfigName } from "../../../core/utils/cli-config.js";
|
||||||
|
import { addSharedLoginOptionsToCommand } from "../login/register.js";
|
||||||
|
import { deploy } from "./deploy.js";
|
||||||
|
|
||||||
export default function registerCommand(program: Command) {
|
export default function registerCommand(program: Command) {
|
||||||
const deployCommand = program
|
const deployCommand = program
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
export * from "./login";
|
|
||||||
export * from "./deploy";
|
|
||||||
export * from "./init";
|
|
||||||
export * from "./start";
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./init";
|
|
||||||
export { default as registerInit } from "./register";
|
|
|
@ -1,9 +1,9 @@
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { init } from "./init";
|
import { init } from "./init.js";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
import { swaCliConfigFilename } from "../../../core/utils";
|
import { swaCliConfigFilename } from "../../../core/utils/cli-config.js";
|
||||||
import { convertToNativePaths, convertToUnixPaths } from "../../../jest.helpers";
|
import { convertToNativePaths, convertToUnixPaths } from "../../../jest.helpers.js";
|
||||||
|
|
||||||
jest.mock("prompts", () => jest.fn());
|
jest.mock("prompts", () => jest.fn());
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import process from "process";
|
import process from "node:process";
|
||||||
import { promptOrUseDefault } from "../../../core/prompts";
|
import { promptOrUseDefault } from "../../../core/prompts.js";
|
||||||
import {
|
import { dasherize } from "../../../core/utils/strings.js";
|
||||||
dasherize,
|
import { hasConfigurationNameInConfigFile, swaCliConfigFileExists, swaCliConfigFilename, writeConfigFile } from "../../../core/utils/cli-config.js";
|
||||||
hasConfigurationNameInConfigFile,
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
logger,
|
import { detectDbConfigFiles, detectProjectFolders, generateConfiguration, isDescendantPath } from "../../../core/frameworks/detect.js";
|
||||||
swaCliConfigFileExists,
|
import { getChoicesForApiLanguage } from "../../../core/functions-versions.js";
|
||||||
swaCliConfigFilename,
|
|
||||||
writeConfigFile,
|
|
||||||
} from "../../../core/utils";
|
|
||||||
import { detectDbConfigFiles, detectProjectFolders, generateConfiguration, isDescendantPath } from "../../../core/frameworks";
|
|
||||||
import { getChoicesForApiLanguage } from "../../../core/functions-versions";
|
|
||||||
|
|
||||||
export async function init(options: SWACLIConfig, showHints: boolean = true) {
|
export async function init(options: SWACLIConfig, showHints: boolean = true) {
|
||||||
const configFilePath = options.config!;
|
const configFilePath = options.config!;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
import { configureOptions, isUserOption, logger } from "../../../core/utils";
|
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
|
||||||
import { init } from "./init";
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
|
import { init } from "./init.js";
|
||||||
|
|
||||||
export default function registerCommand(program: Command) {
|
export default function registerCommand(program: Command) {
|
||||||
program
|
program
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./login";
|
|
||||||
export { default as registerLogin, addSharedLoginOptionsToCommand } from "./register";
|
|
|
@ -1,15 +1,14 @@
|
||||||
import { TokenCredential } from "@azure/identity";
|
import { TokenCredential } from "@azure/identity";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import { existsSync, promises as fsPromises } from "fs";
|
import { existsSync, promises as fs } from "node:fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { logger, logGitHubIssueMessageAndExit } from "../../../core";
|
import { logger, logGitHubIssueMessageAndExit } from "../../../core/utils/logger.js";
|
||||||
import { authenticateWithAzureIdentity, listSubscriptions, listTenants } from "../../../core/account";
|
import { authenticateWithAzureIdentity, listSubscriptions, listTenants } from "../../../core/account.js";
|
||||||
import { ENV_FILENAME } from "../../../core/constants";
|
import { ENV_FILENAME } from "../../../core/constants.js";
|
||||||
import { updateGitIgnore } from "../../../core/git";
|
import { updateGitIgnore } from "../../../core/git.js";
|
||||||
import { chooseSubscription, chooseTenant } from "../../../core/prompts";
|
import { chooseSubscription, chooseTenant } from "../../../core/prompts.js";
|
||||||
import { Environment } from "../../../core/swa-cli-persistence-plugin/impl/azure-environment";
|
import { Environment } from "../../../core/swa-cli-persistence-plugin/impl/azure-environment.js";
|
||||||
const { readFile, writeFile } = fsPromises;
|
|
||||||
|
|
||||||
const defaultScope = `${Environment.AzureCloud.resourceManagerEndpointUrl}/.default`;
|
const defaultScope = `${Environment.AzureCloud.resourceManagerEndpointUrl}/.default`;
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ async function storeProjectCredentialsInEnvFile(
|
||||||
) {
|
) {
|
||||||
const envFile = path.join(process.cwd(), ENV_FILENAME);
|
const envFile = path.join(process.cwd(), ENV_FILENAME);
|
||||||
const envFileExists = existsSync(envFile);
|
const envFileExists = existsSync(envFile);
|
||||||
const envFileContent = envFileExists ? await readFile(envFile, "utf8") : "";
|
const envFileContent = envFileExists ? await fs.readFile(envFile, "utf8") : "";
|
||||||
const buf = Buffer.from(envFileContent);
|
const buf = Buffer.from(envFileContent);
|
||||||
|
|
||||||
// in case the .env file format changes in the future, we can use the following to parse the file
|
// in case the .env file format changes in the future, we can use the following to parse the file
|
||||||
|
@ -143,7 +142,7 @@ async function storeProjectCredentialsInEnvFile(
|
||||||
// write file if we have at least one new env line
|
// write file if we have at least one new env line
|
||||||
if (newEnvFileLines.length > 0) {
|
if (newEnvFileLines.length > 0) {
|
||||||
const envFileContentWithProjectDetails = [...oldEnvFileLines, ...newEnvFileLines].join("\n");
|
const envFileContentWithProjectDetails = [...oldEnvFileLines, ...newEnvFileLines].join("\n");
|
||||||
await writeFile(envFile, envFileContentWithProjectDetails);
|
await fs.writeFile(envFile, envFileContentWithProjectDetails);
|
||||||
|
|
||||||
logger.log(chalk.green(`✔ Saved project credentials in ${ENV_FILENAME} file.`));
|
logger.log(chalk.green(`✔ Saved project credentials in ${ENV_FILENAME} file.`));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
import { configureOptions } from "../../../core";
|
import { configureOptions } from "../../../core/utils/options.js";
|
||||||
import { loginCommand as login } from "./login";
|
import { loginCommand as login } from "./login.js";
|
||||||
|
|
||||||
export function addSharedLoginOptionsToCommand(command: Command) {
|
export function addSharedLoginOptionsToCommand(command: Command) {
|
||||||
command
|
command
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./start";
|
|
||||||
export { default as registerStart } from "./register";
|
|
|
@ -1,8 +1,12 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
import { configureOptions, isHttpUrl, isUserOption, logger, matchLoadedConfigName, parseServerTimeout, parsePort } from "../../../core";
|
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
|
||||||
import { start } from "./start";
|
import { isHttpUrl, parsePort } from "../../../core/utils/net.js";
|
||||||
|
import { matchLoadedConfigName } from "../../../core/utils/cli-config.js";
|
||||||
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
|
import { parseServerTimeout } from "../../../core/utils/cli.js";
|
||||||
|
import { start } from "./start.js";
|
||||||
|
|
||||||
export default function registerCommand(program: Command) {
|
export default function registerCommand(program: Command) {
|
||||||
program
|
program
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
import concurrently, { CloseEvent } from "concurrently";
|
import { concurrently, CloseEvent, ConcurrentlyOptions } from "concurrently";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
|
import { askNewPort, isAcceptingTcpConnections, parseUrl } from "../../../core/utils/net.js";
|
||||||
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
|
import { createStartupScriptCommand } from "../../../core/utils/cli.js";
|
||||||
|
import { readWorkflowFile } from "../../../core/utils/workflow-config.js";
|
||||||
import {
|
import {
|
||||||
askNewPort,
|
|
||||||
createStartupScriptCommand,
|
|
||||||
detectTargetCoreToolsVersion,
|
|
||||||
getCoreToolsBinary,
|
|
||||||
getNodeMajorVersion,
|
getNodeMajorVersion,
|
||||||
isAcceptingTcpConnections,
|
|
||||||
isCoreToolsVersionCompatible,
|
isCoreToolsVersionCompatible,
|
||||||
logger,
|
getCoreToolsBinary,
|
||||||
parseUrl,
|
detectTargetCoreToolsVersion,
|
||||||
readWorkflowFile,
|
} from "../../../core/func-core-tools.js";
|
||||||
} from "../../../core";
|
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../../../core/constants.js";
|
||||||
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../../../core/constants";
|
import { getDataApiBuilderBinaryPath } from "../../../core/dataApiBuilder/index.js";
|
||||||
import { getDataApiBuilderBinaryPath } from "../../../core/dataApiBuilder";
|
import { swaCLIEnv } from "../../../core/env.js";
|
||||||
import { swaCLIEnv } from "../../../core/env";
|
import { getCertificate } from "../../../core/ssl.js";
|
||||||
import { getCertificate } from "../../../core/ssl";
|
|
||||||
const packageInfo = require("../../../../package.json");
|
const packageInfo = require("../../../../package.json");
|
||||||
const mshaPath = require.resolve("../../../msha/server");
|
const mshaPath = require.resolve("../../../msha/server");
|
||||||
|
|
||||||
|
@ -340,7 +339,8 @@ export async function start(options: SWACLIConfig) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { result } = concurrently(concurrentlyCommands, { restartTries: 0, killOthers: ["failure", "success"] });
|
const concurrentlyOptions: Partial<ConcurrentlyOptions> = { restartTries: 0, killOthers: ["failure", "success"] };
|
||||||
|
const { result } = concurrently(concurrentlyCommands, concurrentlyOptions);
|
||||||
|
|
||||||
await result
|
await result
|
||||||
.then(
|
.then(
|
||||||
|
@ -372,7 +372,7 @@ export async function start(options: SWACLIConfig) {
|
||||||
logger.error(`SWA emulator stopped because ${commandMessage}.`, true);
|
logger.error(`SWA emulator stopped because ${commandMessage}.`, true);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.catch((err) => {
|
.catch((err: Error) => {
|
||||||
logger.error(err.message, true);
|
logger.error(err.message, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { program } from "commander";
|
import { program } from "commander";
|
||||||
import { UpdateNotifier } from "update-notifier";
|
import { UpdateNotifier } from "update-notifier";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { run } from "./index";
|
import { run } from "./index.js";
|
||||||
|
|
||||||
jest.mock("./commands/build/build", () => ({
|
jest.mock("./commands/build/build", () => ({
|
||||||
build: jest.fn(),
|
build: jest.fn(),
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
import process from "process";
|
import process from "node:process";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { Command, Option, program } from "commander";
|
import { Command, Option, program } from "commander";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import updateNotifier from "update-notifier";
|
import updateNotifier from "update-notifier";
|
||||||
import { DEFAULT_CONFIG } from "../config";
|
import { DEFAULT_CONFIG } from "../config.js";
|
||||||
import { configureOptions, getCurrentSwaCliConfigFromFile, getNodeMajorVersion, logger, runCommand, swaCliConfigFilename } from "../core";
|
import { configureOptions } from "../core/utils/options.js";
|
||||||
import { registerDeploy } from "./commands/deploy";
|
import { getCurrentSwaCliConfigFromFile, swaCliConfigFilename } from "../core/utils/cli-config.js";
|
||||||
import { registerInit } from "./commands/init";
|
import { getNodeMajorVersion } from "../core/func-core-tools.js";
|
||||||
import { registerLogin } from "./commands/login";
|
import { logger } from "../core/utils/logger.js";
|
||||||
import { registerStart } from "./commands/start";
|
import { runCommand } from "../core/utils/command.js";
|
||||||
import { registerBuild } from "./commands/build";
|
import { default as registerDeploy } from "./commands/deploy/register.js";
|
||||||
import { registerDocs } from "./commands/docs";
|
import { default as registerInit } from "./commands/init/register.js";
|
||||||
import { registerDb } from "./commands/db/init";
|
import { default as registerLogin } from "./commands/login/register.js";
|
||||||
import { promptOrUseDefault } from "../core/prompts";
|
import { default as registerStart } from "./commands/start/register.js";
|
||||||
|
import { default as registerBuild } from "./commands/build/register.js";
|
||||||
export * from "./commands";
|
import { registerDocs } from "./commands/docs.js";
|
||||||
|
import { default as registerDb } from "./commands/db/init/register.js";
|
||||||
|
import { promptOrUseDefault } from "../core/prompts.js";
|
||||||
|
//export * from "./commands";
|
||||||
|
|
||||||
const pkg = require("../../package.json");
|
const pkg = require("../../package.json");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { useEnvVarOrUseDefault, swaCLIEnv } from "./core/env";
|
import { useEnvVarOrUseDefault, swaCLIEnv } from "./core/env.js";
|
||||||
import { isRunningInDocker } from "./core/utils/docker";
|
import { isRunningInDocker } from "./core/utils/docker.js";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
SWA_CLI_APP_LOCATION,
|
SWA_CLI_APP_LOCATION,
|
||||||
|
|
|
@ -14,13 +14,20 @@ import {
|
||||||
} from "@azure/identity";
|
} from "@azure/identity";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { swaCLIEnv } from "./env";
|
import { swaCLIEnv } from "./env.js";
|
||||||
import { chooseProjectName, chooseProjectSku, chooseStaticSite, wouldYouLikeToCreateStaticSite, wouldYouLikeToOverrideStaticSite } from "./prompts";
|
import {
|
||||||
import { swaCliPersistencePlugin } from "./swa-cli-persistence-plugin";
|
chooseProjectName,
|
||||||
import { SWACLIPersistenceCachePlugin } from "./swa-cli-persistence-plugin/persistence-cache-plugin";
|
chooseProjectSku,
|
||||||
import { dasherize, logger } from "./utils";
|
chooseStaticSite,
|
||||||
import { isRunningInDocker } from "./utils/docker";
|
wouldYouLikeToCreateStaticSite,
|
||||||
|
wouldYouLikeToOverrideStaticSite,
|
||||||
|
} from "./prompts.js";
|
||||||
|
import { swaCliPersistencePlugin } from "./swa-cli-persistence-plugin/index.js";
|
||||||
|
import { SWACLIPersistenceCachePlugin } from "./swa-cli-persistence-plugin/persistence-cache-plugin.js";
|
||||||
|
import { logger } from "./utils/logger.js";
|
||||||
|
import { dasherize } from "./utils/strings.js";
|
||||||
|
import { isRunningInDocker } from "./utils/docker.js";
|
||||||
|
|
||||||
const DEFAULT_AZURE_LOCATION = "West US 2";
|
const DEFAULT_AZURE_LOCATION = "West US 2";
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import path from "path";
|
import os from "node:os";
|
||||||
import { DEFAULT_CONFIG } from "../config";
|
import path from "node:path";
|
||||||
import { address, isHttpUrl } from "./utils/net";
|
import { DEFAULT_CONFIG } from "../config.js";
|
||||||
import os from "os";
|
import { address, isHttpUrl } from "./utils/net.js";
|
||||||
|
|
||||||
// StaticSiteClient related constants
|
// StaticSiteClient related constants
|
||||||
export const DEPLOY_BINARY_NAME = "StaticSitesClient";
|
export const DEPLOY_BINARY_NAME = "StaticSitesClient";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DEFAULT_DATA_API_BUILDER_BINARY } from "../constants";
|
import { DEFAULT_DATA_API_BUILDER_BINARY } from "../constants.js";
|
||||||
import { getDefaultDataApiBuilderBinaryForOS } from "./dab";
|
import { getDefaultDataApiBuilderBinaryForOS } from "./dab.js";
|
||||||
|
|
||||||
describe("getDefaultDataApiBuilderBinaryForOS", () => {
|
describe("getDefaultDataApiBuilderBinaryForOS", () => {
|
||||||
it("returns the default binary for Windows when given win-x64 platform", () => {
|
it("returns the default binary for Windows when given win-x64 platform", () => {
|
||||||
|
|
|
@ -5,16 +5,17 @@ import {
|
||||||
DATA_API_BUILDER_LATEST_TAG,
|
DATA_API_BUILDER_LATEST_TAG,
|
||||||
DATA_API_BUILDER_RELEASE_METADATA_URL,
|
DATA_API_BUILDER_RELEASE_METADATA_URL,
|
||||||
DEFAULT_DATA_API_BUILDER_BINARY,
|
DEFAULT_DATA_API_BUILDER_BINARY,
|
||||||
} from "../constants";
|
} from "../constants.js";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { promisify } from "util";
|
import { promisify } from "node:util";
|
||||||
import { exec } from "child_process";
|
import { exec } from "node:child_process";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import AdmZip from "adm-zip";
|
import AdmZip from "adm-zip";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { getPlatform, logger } from "../utils";
|
import { logger } from "../utils/logger.js";
|
||||||
import { downloadAndValidateBinary } from "../download-binary-helper";
|
import { getPlatform } from "../utils/platform.js";
|
||||||
|
import { downloadAndValidateBinary } from "../download-binary-helper.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the filepath where the Microsoft.DataApiBuilder.exe is located
|
* Gets the filepath where the Microsoft.DataApiBuilder.exe is located
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { DATA_API_BUILDER_BINARY_NAME } from "../constants";
|
import { DATA_API_BUILDER_BINARY_NAME } from "../constants.js";
|
||||||
import { logger } from "../utils";
|
import { logger } from "../utils/logger.js";
|
||||||
import { installAndGetDataApiBuilder } from "./dab";
|
import { installAndGetDataApiBuilder } from "./dab.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function gets the Data-Api Builder binary path and returns it
|
* This function gets the Data-Api Builder binary path and returns it
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants";
|
import { DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants.js";
|
||||||
import { fetchClientVersionDefinition, getLocalClientMetadata } from "./deploy-client";
|
import { fetchClientVersionDefinition, getLocalClientMetadata } from "./deploy-client.js";
|
||||||
import { getPlatform } from "./utils";
|
import { getPlatform } from "./utils/platform.js";
|
||||||
|
|
||||||
jest.mock("node-fetch", () => jest.fn());
|
jest.mock("node-fetch", () => jest.fn());
|
||||||
jest.mock("os", () => ({ platform: () => "linux", homedir: () => "/home/user", tmpdir: () => "/tmp", release: () => "4.4.0-1-amd64" }));
|
jest.mock("os", () => ({ platform: () => "linux", homedir: () => "/home/user", tmpdir: () => "/tmp", release: () => "4.4.0-1-amd64" }));
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { STATIC_SITE_CLIENT_RELEASE_METADATA_URL, DEPLOY_BINARY_NAME, DEPLOY_FOLDER, DEPLOY_BINARY_STABLE_TAG } from "./constants";
|
import { STATIC_SITE_CLIENT_RELEASE_METADATA_URL, DEPLOY_BINARY_NAME, DEPLOY_FOLDER, DEPLOY_BINARY_STABLE_TAG } from "./constants.js";
|
||||||
import { downloadAndValidateBinary } from "./download-binary-helper";
|
import { downloadAndValidateBinary } from "./download-binary-helper.js";
|
||||||
import { swaCLIEnv } from "./env";
|
import { swaCLIEnv } from "./env.js";
|
||||||
import { getPlatform, logger } from "./utils";
|
import { logger } from "./utils/logger.js";
|
||||||
|
import { getPlatform } from "./utils/platform.js";
|
||||||
|
|
||||||
type StaticSiteClientLocalMetadata = {
|
type StaticSiteClientLocalMetadata = {
|
||||||
metadata: StaticSiteClientReleaseMetadata;
|
metadata: StaticSiteClientReleaseMetadata;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import crypto from "crypto";
|
import crypto from "node:crypto";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { PassThrough } from "stream";
|
import { PassThrough } from "node:stream";
|
||||||
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_FOLDER, DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants";
|
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_FOLDER, DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants.js";
|
||||||
import { logger } from "./utils";
|
import { logger } from "./utils/logger.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads the binary to the given output folder
|
* Downloads the binary to the given output folder
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { swaCLIEnv } from "./env";
|
import { swaCLIEnv } from "./env.js";
|
||||||
|
|
||||||
describe("swaCLIEnv()", () => {
|
describe("swaCLIEnv()", () => {
|
||||||
const OLD_ENV = process.env;
|
const OLD_ENV = process.env;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { convertToUnixPaths } from "../../jest.helpers";
|
import { convertToUnixPaths } from "../../jest.helpers.js";
|
||||||
import { detectDbConfigFiles, detectProjectFolders, formatDetectedFolders, generateConfiguration } from "./detect";
|
import { detectDbConfigFiles, detectProjectFolders, formatDetectedFolders, generateConfiguration } from "./detect.js";
|
||||||
|
|
||||||
describe("framework detection", () => {
|
describe("framework detection", () => {
|
||||||
describe("detectProjectFolders()", () => {
|
describe("detectProjectFolders()", () => {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import globrex from "globrex";
|
import globrex from "globrex";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../constants";
|
import { DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../constants.js";
|
||||||
import { DEFAULT_CONFIG } from "../../config";
|
import { DEFAULT_CONFIG } from "../../config.js";
|
||||||
import { hasSpaces, logger, removeTrailingPathSep, safeReadFile, safeReadJson } from "../utils";
|
import { hasSpaces, removeTrailingPathSep } from "../utils/strings.js";
|
||||||
import { apiFrameworks, appFrameworks } from "./frameworks";
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { safeReadFile, safeReadJson } from "../utils/file.js";
|
||||||
|
import { apiFrameworks, appFrameworks } from "./frameworks.js";
|
||||||
|
|
||||||
const packageJsonFile = "package.json";
|
const packageJsonFile = "package.json";
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from "./frameworks";
|
|
||||||
export * from "./detect";
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { sep } from "path";
|
import { sep } from "node:path";
|
||||||
import { Readable } from "stream";
|
import { Readable } from "node:stream";
|
||||||
import {
|
import {
|
||||||
detectTargetCoreToolsVersion,
|
detectTargetCoreToolsVersion,
|
||||||
downloadCoreTools,
|
downloadCoreTools,
|
||||||
getCoreToolsBinary,
|
getCoreToolsBinary,
|
||||||
getLatestCoreToolsRelease,
|
getLatestCoreToolsRelease,
|
||||||
isCoreToolsVersionCompatible,
|
isCoreToolsVersionCompatible,
|
||||||
} from "./func-core-tools";
|
} from "./func-core-tools.js";
|
||||||
|
|
||||||
import { logger } from "../core";
|
import { logger } from "../core/utils/logger.js";
|
||||||
jest.spyOn(logger, "log").mockImplementation();
|
jest.spyOn(logger, "log").mockImplementation();
|
||||||
jest.spyOn(logger, "warn").mockImplementation();
|
jest.spyOn(logger, "warn").mockImplementation();
|
||||||
jest.spyOn(logger, "error").mockImplementation();
|
jest.spyOn(logger, "error").mockImplementation();
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import process from "process";
|
import process from "node:process";
|
||||||
import { exec } from "child_process";
|
import { exec } from "node:child_process";
|
||||||
import { promisify } from "util";
|
import { promisify } from "node:util";
|
||||||
import { PassThrough } from "stream";
|
import { PassThrough } from "node:stream";
|
||||||
import crypto from "crypto";
|
import crypto from "node:crypto";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import AdmZip from "adm-zip";
|
import AdmZip from "adm-zip";
|
||||||
import cliProgress from "cli-progress";
|
import cliProgress from "cli-progress";
|
||||||
import { logger } from "./utils/logger";
|
import { logger } from "./utils/logger.js";
|
||||||
|
|
||||||
const RELEASES_FEED_URL = "https://functionscdn.azureedge.net/public/cli-feed-v4.json";
|
const RELEASES_FEED_URL = "https://functionscdn.azureedge.net/public/cli-feed-v4.json";
|
||||||
const DEFAULT_FUNC_BINARY = "func";
|
const DEFAULT_FUNC_BINARY = "func";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "./constants";
|
import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "./constants.js";
|
||||||
import { logger } from "./utils/logger";
|
import { logger } from "./utils/logger.js";
|
||||||
|
|
||||||
export function getDefaultVersion(apiLanguage: string): string {
|
export function getDefaultVersion(apiLanguage: string): string {
|
||||||
let apiVersion;
|
let apiVersion;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { isGitProject, updateGitIgnore } from "./git";
|
import { isGitProject, updateGitIgnore } from "./git.js";
|
||||||
|
|
||||||
describe("git", () => {
|
describe("git", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import fs from "fs";
|
import { promises as fs, existsSync } from "node:fs";
|
||||||
import { logger } from "./utils";
|
import { logger } from "./utils/logger.js";
|
||||||
const { readFile, writeFile } = fs.promises;
|
|
||||||
|
|
||||||
export async function isGitProject() {
|
export async function isGitProject() {
|
||||||
const gitFolder = path.join(process.cwd(), ".git");
|
const gitFolder = path.join(process.cwd(), ".git");
|
||||||
return fs.existsSync(gitFolder);
|
return existsSync(gitFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateGitIgnore(entry: string) {
|
export async function updateGitIgnore(entry: string) {
|
||||||
|
@ -19,14 +18,14 @@ export async function updateGitIgnore(entry: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const gitIgnoreFile = path.join(process.cwd(), ".gitignore");
|
const gitIgnoreFile = path.join(process.cwd(), ".gitignore");
|
||||||
const gitIgnoreFileExists = fs.existsSync(gitIgnoreFile);
|
const gitIgnoreFileExists = existsSync(gitIgnoreFile);
|
||||||
|
|
||||||
if (!gitIgnoreFileExists) {
|
if (!gitIgnoreFileExists) {
|
||||||
logger.silly(`No .gitignore file found. Skip updating .gitignore`);
|
logger.silly(`No .gitignore file found. Skip updating .gitignore`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gitIgnoreFileContent = await readFile(gitIgnoreFile, "utf8");
|
const gitIgnoreFileContent = await fs.readFile(gitIgnoreFile, "utf8");
|
||||||
const gitIgnoreFileLines = gitIgnoreFileContent.length ? gitIgnoreFileContent.split("\n") : [];
|
const gitIgnoreFileLines = gitIgnoreFileContent.length ? gitIgnoreFileContent.split("\n") : [];
|
||||||
const gitIgnoreFileLinesBeforeUpdate = gitIgnoreFileLines.length;
|
const gitIgnoreFileLinesBeforeUpdate = gitIgnoreFileLines.length;
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ export async function updateGitIgnore(entry: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const gitIgnoreFileContentWithProjectDetails = gitIgnoreFileLines.join("\n");
|
const gitIgnoreFileContentWithProjectDetails = gitIgnoreFileLines.join("\n");
|
||||||
await writeFile(gitIgnoreFile, gitIgnoreFileContentWithProjectDetails, "utf8");
|
await fs.writeFile(gitIgnoreFile, gitIgnoreFileContentWithProjectDetails, "utf8");
|
||||||
|
|
||||||
if (gitIgnoreFileLinesBeforeUpdate < gitIgnoreFileLines.length) {
|
if (gitIgnoreFileLinesBeforeUpdate < gitIgnoreFileLines.length) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
export * from "./utils";
|
|
||||||
export * from "./func-core-tools";
|
|
||||||
export * from "./frameworks";
|
|
|
@ -2,7 +2,8 @@ import { StaticSiteARMResource } from "@azure/arm-appservice";
|
||||||
import { Subscription, TenantIdDescription } from "@azure/arm-subscriptions";
|
import { Subscription, TenantIdDescription } from "@azure/arm-subscriptions";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import prompts, { Answers, PromptObject } from "prompts";
|
import prompts, { Answers, PromptObject } from "prompts";
|
||||||
import { dasherize, logger } from "./utils";
|
import { logger } from "./utils/logger.js";
|
||||||
|
import { dasherize } from "./utils/strings.js";
|
||||||
|
|
||||||
export async function promptOrUseDefault<T extends string = string>(
|
export async function promptOrUseDefault<T extends string = string>(
|
||||||
disablePrompts: boolean,
|
disablePrompts: boolean,
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import baseFs from "fs";
|
import { promises as fs } from "node:fs";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import pem from "pem";
|
import pem from "pem";
|
||||||
import { logger } from "./utils";
|
import { logger } from "./utils/logger.js";
|
||||||
const fs = baseFs.promises;
|
|
||||||
const { mkdir, writeFile } = fs;
|
|
||||||
|
|
||||||
const ONE_MONTH = 1000 * 60 * 60 * 24 * 30;
|
const ONE_MONTH = 1000 * 60 * 60 * 24 * 30;
|
||||||
|
|
||||||
|
@ -117,8 +115,8 @@ export async function getCertificate(options: PEMOptions): Promise<string> {
|
||||||
|
|
||||||
const pemContent = [unsignedCertificate.csr, unsignedCertificate.serviceKey, unsignedCertificate.certificate].join("\n");
|
const pemContent = [unsignedCertificate.csr, unsignedCertificate.serviceKey, unsignedCertificate.certificate].join("\n");
|
||||||
|
|
||||||
await mkdir(cacheDir, { recursive: true });
|
await fs.mkdir(cacheDir, { recursive: true });
|
||||||
await writeFile(cachePath, pemContent);
|
await fs.writeFile(cachePath, pemContent);
|
||||||
|
|
||||||
return cachePath;
|
return cachePath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import { TokenCachePersistenceOptions } from "@azure/identity";
|
import { TokenCachePersistenceOptions } from "@azure/identity";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
import waitOn from "wait-on";
|
import waitOn from "wait-on";
|
||||||
import { isValidIpAddress, isWSL, logger } from "../../utils";
|
import { logger } from "../../utils/logger.js";
|
||||||
|
import { isValidIpAddress } from "../../utils/net.js";
|
||||||
|
import { isWSL } from "../../utils/platform.js";
|
||||||
|
|
||||||
type KeychainModule = typeof import("keytar");
|
type KeychainModule = typeof import("keytar");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import crypto from "crypto";
|
import crypto from "node:crypto";
|
||||||
import { logger } from "../../utils";
|
import { logger } from "../../utils/logger.js";
|
||||||
|
|
||||||
interface Encryption {
|
interface Encryption {
|
||||||
encrypt(key: string, value: string): Promise<string>;
|
encrypt(key: string, value: string): Promise<string>;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import crypto from "crypto";
|
import crypto from "node:crypto";
|
||||||
import { networkInterfaces } from "os";
|
import { networkInterfaces } from "node:os";
|
||||||
import { logger } from "../../utils";
|
import { logger } from "../../utils/logger.js";
|
||||||
|
|
||||||
let machineId: Promise<string>;
|
let machineId: Promise<string>;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { TokenCachePersistenceOptions } from "@azure/identity";
|
import { TokenCachePersistenceOptions } from "@azure/identity";
|
||||||
import { logger } from "../../utils";
|
import { logger } from "../../utils/logger.js";
|
||||||
import { NativeCredentialsStore } from "./credentials-store";
|
import { NativeCredentialsStore } from "./credentials-store.js";
|
||||||
import { CryptoService } from "./crypto";
|
import { CryptoService } from "./crypto.js";
|
||||||
|
|
||||||
export class SecretStorage {
|
export class SecretStorage {
|
||||||
private secretStoragePrefix: Promise<string>;
|
private secretStoragePrefix: Promise<string>;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { IdentityPlugin, TokenCachePersistenceOptions } from "@azure/identity";
|
import { IdentityPlugin, TokenCachePersistenceOptions } from "@azure/identity";
|
||||||
import { ICachePlugin } from "@azure/msal-common";
|
import { ICachePlugin } from "@azure/msal-common";
|
||||||
import { logger } from "../utils";
|
import { logger } from "../utils/logger.js";
|
||||||
import { SWACLIPersistenceCachePlugin } from "./persistence-cache-plugin";
|
import { SWACLIPersistenceCachePlugin } from "./persistence-cache-plugin.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin context entries for controlling cache plugins.
|
* Plugin context entries for controlling cache plugins.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { TokenCachePersistenceOptions } from "@azure/identity";
|
import { TokenCachePersistenceOptions } from "@azure/identity";
|
||||||
import { ICachePlugin, TokenCacheContext } from "@azure/msal-common";
|
import { ICachePlugin, TokenCacheContext } from "@azure/msal-common";
|
||||||
import { logger } from "../utils";
|
import { logger } from "../utils/logger.js";
|
||||||
import { Environment } from "./impl/azure-environment";
|
import { Environment } from "./impl/azure-environment.js";
|
||||||
import { NativeCredentialsStore } from "./impl/credentials-store";
|
import { NativeCredentialsStore } from "./impl/credentials-store.js";
|
||||||
import { CryptoService } from "./impl/crypto";
|
import { CryptoService } from "./impl/crypto.js";
|
||||||
import { getMachineId } from "./impl/machine-identifier";
|
import { getMachineId } from "./impl/machine-identifier.js";
|
||||||
import { SecretStorage } from "./impl/secret-storage";
|
import { SecretStorage } from "./impl/secret-storage.js";
|
||||||
|
|
||||||
export interface SWACLIPersistenceCacheOptions {
|
export interface SWACLIPersistenceCacheOptions {
|
||||||
enableCache: boolean;
|
enableCache: boolean;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
|
|
||||||
// Spy on console to avoid this error: https://github.com/tschaub/mock-fs/issues/234
|
// Spy on console to avoid this error: https://github.com/tschaub/mock-fs/issues/234
|
||||||
jest.spyOn(global.console, "log").mockImplementation();
|
jest.spyOn(global.console, "log").mockImplementation();
|
||||||
jest.spyOn(global.console, "warn").mockImplementation();
|
jest.spyOn(global.console, "warn").mockImplementation();
|
||||||
|
@ -16,13 +17,13 @@ jest.mock("../../core/utils/logger", () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
import * as fsModule from "fs";
|
import * as fsModule from "node:fs";
|
||||||
const spyWriteFile = jest.spyOn(fsModule.promises, "writeFile");
|
const spyWriteFile = jest.spyOn(fsModule.promises, "writeFile");
|
||||||
|
|
||||||
import * as path from "path";
|
import * as path from "node:path";
|
||||||
import { logger } from "../../core";
|
import { logger } from "./logger.js";
|
||||||
import * as cliConfigModule from "./cli-config";
|
import * as cliConfigModule from "./cli-config.js";
|
||||||
import { getConfigFileOptions, updateSwaCliConfigFile, writeConfigFile } from "./cli-config";
|
import { getConfigFileOptions, updateSwaCliConfigFile, writeConfigFile } from "./cli-config.js";
|
||||||
|
|
||||||
const mockConfig1 = {
|
const mockConfig1 = {
|
||||||
$schema: "../../../schema/swa-cli.config.schema.json",
|
$schema: "../../../schema/swa-cli.config.schema.json",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { existsSync, promises as fsPromises } from "fs";
|
import { existsSync, promises as fsPromises } from "node:fs";
|
||||||
import * as path from "path";
|
import * as path from "node:path";
|
||||||
import * as process from "process";
|
import * as process from "node:process";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
const { readFile, writeFile } = fsPromises;
|
const { readFile, writeFile } = fsPromises;
|
||||||
|
|
||||||
export const swaCliConfigSchemaUrl = "https://aka.ms/azure/static-web-apps-cli/schema";
|
export const swaCliConfigSchemaUrl = "https://aka.ms/azure/static-web-apps-cli/schema";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
jest.mock("../constants", () => {});
|
jest.mock("../constants", () => {});
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { argv, createStartupScriptCommand, parseServerTimeout } from "./cli";
|
import { argv, createStartupScriptCommand, parseServerTimeout } from "./cli.js";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
describe("argv()", () => {
|
describe("argv()", () => {
|
||||||
it("process.argv = []", () => {
|
it("process.argv = []", () => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse process.argv and retrieve a specific flag value.
|
* Parse process.argv and retrieve a specific flag value.
|
||||||
|
|
|
@ -3,7 +3,7 @@ jest.mock("./logger", () => {
|
||||||
silly: jest.fn();
|
silly: jest.fn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
import { validateCookie } from "./cookie";
|
import { validateCookie } from "./cookie.js";
|
||||||
|
|
||||||
describe("validateCookie()", () => {
|
describe("validateCookie()", () => {
|
||||||
it("cookies = ''", () => {
|
it("cookies = ''", () => {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import cookie from "cookie";
|
import cookie from "cookie";
|
||||||
import { SWA_AUTH_CONTEXT_COOKIE, SWA_AUTH_COOKIE } from "../constants";
|
import { SWA_AUTH_CONTEXT_COOKIE, SWA_AUTH_COOKIE } from "../constants.js";
|
||||||
import { isValueEncryptedAndSigned, validateSignatureAndDecrypt } from "./auth";
|
import { isValueEncryptedAndSigned, validateSignatureAndDecrypt } from "./auth.js";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize a cookie name-value pair into a string that can be used in Set-Cookie header.
|
* Serialize a cookie name-value pair into a string that can be used in Set-Cookie header.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { convertToNativePaths } from "../../jest.helpers";
|
import { convertToNativePaths } from "../../jest.helpers.js";
|
||||||
import { findUpPackageJsonDir, pathExists, safeReadFile, safeReadJson } from "./file";
|
import { findUpPackageJsonDir, pathExists, safeReadFile, safeReadJson } from "./file.js";
|
||||||
|
|
||||||
describe("file utilities", () => {
|
describe("file utilities", () => {
|
||||||
describe("safeReadJson()", () => {
|
describe("safeReadJson()", () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "node:fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
import { stripJsonComments } from "./strings";
|
import { stripJsonComments } from "./strings.js";
|
||||||
|
|
||||||
export async function safeReadJson(path: string): Promise<JsonData | undefined> {
|
export async function safeReadJson(path: string): Promise<JsonData | undefined> {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { globToRegExp, isBalancedCurlyBrackets, isValidGlobExpression } from "./glob";
|
import { globToRegExp, isBalancedCurlyBrackets, isValidGlobExpression } from "./glob.js";
|
||||||
|
|
||||||
describe("glob functions", () => {
|
describe("glob functions", () => {
|
||||||
describe("globToRegExp()", () => {
|
describe("globToRegExp()", () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn expression into a valid regexp
|
* Turn expression into a valid regexp
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
export * from "./cli";
|
|
||||||
export * from "./cli-config";
|
|
||||||
export * from "./command";
|
|
||||||
export * from "./cookie";
|
|
||||||
export * from "./file";
|
|
||||||
export * from "./glob";
|
|
||||||
export * from "./logger";
|
|
||||||
export * from "./net";
|
|
||||||
export * from "./options";
|
|
||||||
export * from "./platform";
|
|
||||||
export * from "./strings";
|
|
||||||
export * from "./user-config";
|
|
||||||
export * from "./workflow-config";
|
|
|
@ -1,7 +1,7 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import type http from "http";
|
import type http from "http";
|
||||||
import { CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../constants";
|
import { CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../constants.js";
|
||||||
import { swaCLIEnv } from "../env";
|
import { swaCLIEnv } from "../env.js";
|
||||||
|
|
||||||
const SENSITIVE_KEYS = ["DEPLOYMENT_TOKEN", "SWA_CLI_DEPLOYMENT_TOKEN", "--deployment-token", "deploymentToken"];
|
const SENSITIVE_KEYS = ["DEPLOYMENT_TOKEN", "SWA_CLI_DEPLOYMENT_TOKEN", "--deployment-token", "deploymentToken"];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
jest.mock("../constants", () => {});
|
jest.mock("../constants", () => {});
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
import { address, hostnameToIpAdress, isHttpsUrl, parsePort, parseUrl, response } from "./net";
|
import { address, hostnameToIpAdress, isHttpsUrl, parsePort, parseUrl, response } from "./net.js";
|
||||||
|
|
||||||
describe("net utilities", () => {
|
describe("net utilities", () => {
|
||||||
describe("response()", () => {
|
describe("response()", () => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import getPort from "get-port";
|
import getPort from "get-port";
|
||||||
import net from "net";
|
import net from "node:net";
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
import waitOn from "wait-on";
|
import waitOn from "wait-on";
|
||||||
import { confirmChooseRandomPort } from "../prompts";
|
import { confirmChooseRandomPort } from "../prompts.js";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
const VALID_PORT_MIN = 1024;
|
const VALID_PORT_MIN = 1024;
|
||||||
const VALID_PORT_MAX = 65535;
|
const VALID_PORT_MAX = 65535;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { swaCliConfigFilename } from "./cli-config";
|
import { swaCliConfigFilename } from "./cli-config.js";
|
||||||
import { parsePort } from "./net";
|
import { parsePort } from "./net.js";
|
||||||
import { parseServerTimeout } from "./cli";
|
import { parseServerTimeout } from "./cli.js";
|
||||||
import { configureOptions, getUserOptions } from "./options";
|
import { configureOptions, getUserOptions } from "./options.js";
|
||||||
import { DEFAULT_CONFIG } from "../../config";
|
import { DEFAULT_CONFIG } from "../../config.js";
|
||||||
|
|
||||||
describe("configureOptions()", () => {
|
describe("configureOptions()", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Command, OptionValues, program } from "commander";
|
import { Command, OptionValues, program } from "commander";
|
||||||
import { DEFAULT_CONFIG } from "../../config";
|
import { DEFAULT_CONFIG } from "../../config.js";
|
||||||
import { SWACommand, SWA_COMMANDS } from "../constants";
|
import { SWACommand, SWA_COMMANDS } from "../constants.js";
|
||||||
import { getConfigFileOptions } from "./cli-config";
|
import { getConfigFileOptions } from "./cli-config.js";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
let userDefinedOptions: SWACLIConfig = {};
|
let userDefinedOptions: SWACLIConfig = {};
|
||||||
let configFileDefinedOptions: SWACLIConfig = {};
|
let configFileDefinedOptions: SWACLIConfig = {};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getPlatform } from "./platform";
|
import { getPlatform } from "./platform.js";
|
||||||
import os from "os";
|
import os from "node:os";
|
||||||
|
|
||||||
describe("getPlatform", () => {
|
describe("getPlatform", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { dasherize, hasSpaces, removeTrailingPathSep, stripJsonComments } from "./strings";
|
import { dasherize, hasSpaces, removeTrailingPathSep, stripJsonComments } from "./strings.js";
|
||||||
|
|
||||||
describe("string utilities", () => {
|
describe("string utilities", () => {
|
||||||
describe("dasherize()", () => {
|
describe("dasherize()", () => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
jest.spyOn(logger, "silly").mockImplementation();
|
jest.spyOn(logger, "silly").mockImplementation();
|
||||||
jest.spyOn(logger, "warn").mockImplementation();
|
jest.spyOn(logger, "warn").mockImplementation();
|
||||||
|
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { findSWAConfigFile, traverseFolder } from "./user-config";
|
import { findSWAConfigFile, traverseFolder } from "./user-config.js";
|
||||||
import * as userConfigModule from "./user-config";
|
import * as userConfigModule from "./user-config.js";
|
||||||
|
|
||||||
describe("userConfig", () => {
|
describe("userConfig", () => {
|
||||||
describe("traverseFolder()", () => {
|
describe("traverseFolder()", () => {
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import Ajv4, { JSONSchemaType, ValidateFunction } from "ajv-draft-04";
|
import { Ajv, JSONSchemaType, ValidateFunction } from "ajv";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import jsonMap from "json-source-map";
|
import jsonMap from "json-source-map";
|
||||||
import fetch, { RequestInit } from "node-fetch";
|
import fetch, { RequestInit } from "node-fetch";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import {
|
import {
|
||||||
SWA_CONFIG_FILENAME,
|
SWA_CONFIG_FILENAME,
|
||||||
SWA_CONFIG_FILENAME_LEGACY,
|
SWA_CONFIG_FILENAME_LEGACY,
|
||||||
SWA_RUNTIME_CONFIG_MAX_SIZE_IN_KB,
|
SWA_RUNTIME_CONFIG_MAX_SIZE_IN_KB,
|
||||||
SWA_CONFIG_SCHEME_URL,
|
SWA_CONFIG_SCHEME_URL,
|
||||||
SWA_CONFIG_SCHEME_FALLBACK_PATH,
|
SWA_CONFIG_SCHEME_FALLBACK_PATH,
|
||||||
} from "../constants";
|
} from "../constants.js";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
import { isHttpUrl } from "./net";
|
import { isHttpUrl } from "./net.js";
|
||||||
const { readdir, readFile, stat } = fs.promises;
|
const { readdir, readFile, stat } = fs.promises;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +103,7 @@ export async function findSWAConfigFile(folder: string): Promise<{ filepath: str
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function validateRuntimeConfigAndGetData(filepath: string): Promise<SWAConfigFile | null> {
|
export async function validateRuntimeConfigAndGetData(filepath: string): Promise<SWAConfigFile | null> {
|
||||||
const ajv4 = new Ajv4({
|
const ajv4 = new Ajv({
|
||||||
strict: false,
|
strict: false,
|
||||||
allErrors: true,
|
allErrors: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
jest.mock("../constants", () => {});
|
jest.mock("../constants", () => {});
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { convertToNativePaths } from "../../jest.helpers";
|
import { convertToNativePaths } from "../../jest.helpers.js";
|
||||||
import { readWorkflowFile } from "./workflow-config";
|
import { readWorkflowFile } from "./workflow-config.js";
|
||||||
|
|
||||||
jest.mock("../../config", () => {
|
jest.mock("../../config", () => {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
import { DEFAULT_CONFIG } from "../../config";
|
import { DEFAULT_CONFIG } from "../../config.js";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger.js";
|
||||||
import { isHttpUrl } from "./net";
|
import { isHttpUrl } from "./net.js";
|
||||||
import { validateUserWorkflowConfig } from "./user-config";
|
import { validateUserWorkflowConfig } from "./user-config.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read and parse the project workflow configuration (if available).
|
* Read and parse the project workflow configuration (if available).
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { logger, response as newResponse, serializeCookie } from "../../core";
|
import { serializeCookie } from "../../core/utils/cookie.js";
|
||||||
|
import { logger } from "../../core/utils/logger.js";
|
||||||
|
import { response as newResponse } from "../../core/utils/net.js";
|
||||||
|
|
||||||
function getAuthPaths(isCustomAuth: boolean): Path[] {
|
function getAuthPaths(isCustomAuth: boolean): Path[] {
|
||||||
const paths: Path[] = [];
|
const paths: Path[] = [];
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import { CookiesManager, decodeAuthContextCookie, parseUrl, response, validateAuthContextCookie } from "../../../core";
|
import * as http from "node:http";
|
||||||
import * as http from "http";
|
import * as https from "node:https";
|
||||||
import * as https from "https";
|
import * as querystring from "node:querystring";
|
||||||
import * as querystring from "querystring";
|
|
||||||
import { SWA_CLI_API_URI, SWA_CLI_APP_PROTOCOL } from "../../../core/constants";
|
import { CookiesManager, decodeAuthContextCookie, validateAuthContextCookie } from "../../../core/utils/cookie.js";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { parseUrl, response } from "../../../core/utils/net.js";
|
||||||
import { encryptAndSign, hashStateGuid, isNonceExpired } from "../../../core/utils/auth";
|
import { SWA_CLI_API_URI, SWA_CLI_APP_PROTOCOL } from "../../../core/constants.js";
|
||||||
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
|
import { encryptAndSign, hashStateGuid, isNonceExpired } from "../../../core/utils/auth.js";
|
||||||
|
|
||||||
const getGithubAuthToken = function (codeValue: string, clientId: string, clientSecret: string) {
|
const getGithubAuthToken = function (codeValue: string, clientId: string, clientSecret: string) {
|
||||||
const data = querystring.stringify({
|
const data = querystring.stringify({
|
||||||
|
@ -37,7 +39,7 @@ const getGithubAuthToken = function (codeValue: string, clientId: string, client
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on("error", (err) => {
|
req.on("error", (err: Error) => {
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { CookiesManager, response } from "../../../core";
|
import { IncomingMessage } from "node:http";
|
||||||
import * as http from "http";
|
import { CookiesManager } from "../../../core/utils/cookie.js";
|
||||||
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants";
|
import { response } from "../../../core/utils/net.js";
|
||||||
import { DEFAULT_CONFIG } from "../../../config";
|
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants.js";
|
||||||
import { encryptAndSign, extractPostLoginRedirectUri, hashStateGuid, newNonceWithExpiration } from "../../../core/utils/auth";
|
import { DEFAULT_CONFIG } from "../../../config.js";
|
||||||
|
import { encryptAndSign, extractPostLoginRedirectUri, hashStateGuid, newNonceWithExpiration } from "../../../core/utils/auth.js";
|
||||||
|
|
||||||
const httpTrigger = async function (context: Context, request: http.IncomingMessage, customAuth?: SWAConfigFileAuth) {
|
const httpTrigger = async function (context: Context, request: IncomingMessage, customAuth?: SWAConfigFileAuth) {
|
||||||
await Promise.resolve();
|
await Promise.resolve();
|
||||||
|
|
||||||
const providerName = context.bindingData?.provider?.toLowerCase() || "";
|
const providerName = context.bindingData?.provider?.toLowerCase() || "";
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { IncomingMessage } from "http";
|
import { IncomingMessage } from "node:http";
|
||||||
import { CookiesManager, response } from "../../../core";
|
import { CookiesManager } from "../../../core/utils/cookie.js";
|
||||||
|
import { response } from "../../../core/utils/net.js";
|
||||||
|
|
||||||
const fs = require("fs").promises;
|
const fs = require("fs").promises;
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
|
@ -3,8 +3,8 @@ jest.mock("../../../core/constants", () => {
|
||||||
SWA_CLI_APP_PROTOCOL: "https",
|
SWA_CLI_APP_PROTOCOL: "https",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import httpTrigger from "./auth-logout";
|
import httpTrigger from "./auth-logout.js";
|
||||||
|
|
||||||
describe("auth-logout-https", () => {
|
describe("auth-logout-https", () => {
|
||||||
let context: Context;
|
let context: Context;
|
||||||
|
|
|
@ -3,8 +3,8 @@ jest.mock("../../../core/constants", () => {
|
||||||
SWA_CLI_APP_PROTOCOL: "http",
|
SWA_CLI_APP_PROTOCOL: "http",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
import { IncomingMessage } from "http";
|
import { IncomingMessage } from "node:http";
|
||||||
import httpTrigger from "./auth-logout";
|
import httpTrigger from "./auth-logout.js";
|
||||||
|
|
||||||
describe("auth_logout", () => {
|
describe("auth_logout", () => {
|
||||||
let context: Context;
|
let context: Context;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { CookiesManager, response } from "../../../core";
|
import { CookiesManager } from "../../../core/utils/cookie.js";
|
||||||
// import { response } from "../../../core";
|
import { response } from "../../../core/utils/net.js";
|
||||||
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants";
|
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants.js";
|
||||||
|
|
||||||
export default async function (context: Context, req: http.IncomingMessage) {
|
export default async function (context: Context, req: http.IncomingMessage) {
|
||||||
const headers = req?.headers;
|
const headers = req?.headers;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { IncomingMessage } from "http";
|
import { IncomingMessage } from "node:http";
|
||||||
import { decodeCookie, response, validateCookie } from "../../../core";
|
import { decodeCookie, validateCookie } from "../../../core/utils/cookie.js";
|
||||||
|
import { response } from "../../../core/utils/net.js";
|
||||||
|
|
||||||
const httpTrigger = async function (context: Context, req: IncomingMessage) {
|
const httpTrigger = async function (context: Context, req: IncomingMessage) {
|
||||||
const { cookie } = req.headers;
|
const { cookie } = req.headers;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { logger, logRequest } from "../../core";
|
import { logger, logRequest } from "../../core/utils/logger.js";
|
||||||
import { processAuth } from "../auth";
|
import { processAuth } from "../auth/index.js";
|
||||||
import { handleErrorPage } from "./error-page.handler";
|
import { handleErrorPage } from "./error-page.handler.js";
|
||||||
|
|
||||||
export async function handleAuthRequest(
|
export async function handleAuthRequest(
|
||||||
req: http.IncomingMessage,
|
req: http.IncomingMessage,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import http from "http";
|
import http from "node:http";
|
||||||
import { injectHeaders, isDataApiRequest } from "./dab.handler";
|
import { injectHeaders, isDataApiRequest } from "./dab.handler.js";
|
||||||
|
|
||||||
describe("isDataApiRequest", () => {
|
describe("isDataApiRequest", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import httpProxy from "http-proxy";
|
import httpProxy from "http-proxy";
|
||||||
import { decodeCookie, logger, logRequest, registerProcessExit, validateCookie } from "../../core";
|
import { registerProcessExit } from "../../core/utils/cli.js";
|
||||||
import { SWA_CLI_DATA_API_URI } from "../../core/constants";
|
import { decodeCookie, validateCookie } from "../../core/utils/cookie.js";
|
||||||
import { onConnectionLost } from "../middlewares/request.middleware";
|
import { logger, logRequest } from "../../core/utils/logger.js";
|
||||||
|
import { SWA_CLI_DATA_API_URI } from "../../core/constants.js";
|
||||||
|
import { onConnectionLost } from "../middlewares/request.middleware.js";
|
||||||
|
|
||||||
const proxyApi = httpProxy.createProxyServer({ autoRewrite: true });
|
const proxyApi = httpProxy.createProxyServer({ autoRewrite: true });
|
||||||
registerProcessExit(() => {
|
registerProcessExit(() => {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { logRequest } from "../../core";
|
import { logRequest } from "../../core/utils/logger.js";
|
||||||
import { SWA_CLI_APP_PROTOCOL } from "../../core/constants";
|
import { SWA_CLI_APP_PROTOCOL } from "../../core/constants.js";
|
||||||
import { responseOverrides } from "../routes-engine";
|
import { responseOverrides } from "../routes-engine/rules/response-overrides.js";
|
||||||
import { isCustomUrl } from "../routes-engine/route-processor";
|
import { isCustomUrl } from "../routes-engine/route-processor.js";
|
||||||
|
|
||||||
export function handleErrorPage(
|
export function handleErrorPage(
|
||||||
req: http.IncomingMessage,
|
req: http.IncomingMessage,
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import httpProxy from "http-proxy";
|
import httpProxy from "http-proxy";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { decodeCookie, logger, logRequest, registerProcessExit, validateCookie } from "../../core";
|
|
||||||
import { HAS_API, SWA_CLI_API_URI } from "../../core/constants";
|
import { decodeCookie, validateCookie } from "../../core/utils/cookie.js";
|
||||||
import { parseUrl } from "../../core/utils/net";
|
import { registerProcessExit } from "../../core/utils/cli.js";
|
||||||
import { onConnectionLost } from "../middlewares/request.middleware";
|
import { logger, logRequest } from "../../core/utils/logger.js";
|
||||||
|
import { parseUrl } from "../../core/utils/net.js";
|
||||||
|
import { HAS_API, SWA_CLI_API_URI } from "../../core/constants.js";
|
||||||
|
import { onConnectionLost } from "../middlewares/request.middleware.js";
|
||||||
|
|
||||||
const proxyApi = httpProxy.createProxyServer({ autoRewrite: true });
|
const proxyApi = httpProxy.createProxyServer({ autoRewrite: true });
|
||||||
registerProcessExit(() => {
|
registerProcessExit(() => {
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import finalhandler from "finalhandler";
|
import finalhandler from "finalhandler";
|
||||||
import fs from "fs";
|
import fs from "node:fs";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import httpProxy from "http-proxy";
|
import httpProxy from "http-proxy";
|
||||||
import type net from "net";
|
import type net from "node:net";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import serveStatic from "serve-static";
|
import serveStatic from "serve-static";
|
||||||
import { DEFAULT_CONFIG } from "../../config";
|
|
||||||
import { findSWAConfigFile, logger, logRequest } from "../../core";
|
|
||||||
import { AUTH_STATUS, CUSTOM_URL_SCHEME, IS_APP_DEV_SERVER, SWA_PUBLIC_DIR } from "../../core/constants";
|
|
||||||
import { parseUrl } from "../../core/utils/net";
|
|
||||||
import waitOn from "wait-on";
|
import waitOn from "wait-on";
|
||||||
import { getAuthBlockResponse, handleAuthRequest, isAuthRequest, isLoginRequest, isLogoutRequest } from "../handlers/auth.handler";
|
import { DEFAULT_CONFIG } from "../../config.js";
|
||||||
import { isDataApiRequest } from "../handlers/dab.handler";
|
import { logger, logRequest } from "../../core/utils/logger.js";
|
||||||
import { handleErrorPage } from "../handlers/error-page.handler";
|
import { findSWAConfigFile } from "../../core/utils/user-config.js";
|
||||||
import { isFunctionRequest } from "../handlers/function.handler";
|
import { parseUrl } from "../../core/utils/net.js";
|
||||||
import { isRequestMethodValid, isRouteRequiringUserRolesCheck, tryGetMatchingRoute } from "../routes-engine";
|
import { AUTH_STATUS, CUSTOM_URL_SCHEME, IS_APP_DEV_SERVER, SWA_PUBLIC_DIR } from "../../core/constants.js";
|
||||||
import { isCustomUrl, parseQueryParams } from "../routes-engine/route-processor";
|
import { getAuthBlockResponse, handleAuthRequest, isAuthRequest, isLoginRequest, isLogoutRequest } from "../handlers/auth.handler.js";
|
||||||
import { getResponse } from "./response.middleware";
|
import { isDataApiRequest } from "../handlers/dab.handler.js";
|
||||||
|
import { handleErrorPage } from "../handlers/error-page.handler.js";
|
||||||
|
import { isFunctionRequest } from "../handlers/function.handler.js";
|
||||||
|
import { isRequestMethodValid, isRouteRequiringUserRolesCheck, tryGetMatchingRoute } from "../routes-engine/rules/routes.js";
|
||||||
|
import { isCustomUrl, parseQueryParams } from "../routes-engine/route-processor.js";
|
||||||
|
import { getResponse } from "./response.middleware.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On connection lost handler. Called when a connection to a target host cannot be made or if the remote target is down.
|
* On connection lost handler. Called when a connection to a target host cannot be made or if the remote target is down.
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { isHttpUrl, isSWAConfigFileUrl, logger } from "../../core";
|
import { isHttpUrl } from "../../core/utils/net.js";
|
||||||
import { IS_APP_DEV_SERVER } from "../../core/constants";
|
import { logger } from "../../core/utils/logger.js";
|
||||||
import { handleDataApiRequest } from "../handlers/dab.handler";
|
import { isSWAConfigFileUrl } from "../../core/utils/user-config.js";
|
||||||
import { handleErrorPage } from "../handlers/error-page.handler";
|
import { IS_APP_DEV_SERVER } from "../../core/constants.js";
|
||||||
import { handleFunctionRequest, isFunctionRequest } from "../handlers/function.handler";
|
import { handleDataApiRequest } from "../handlers/dab.handler.js";
|
||||||
import {
|
import { handleErrorPage } from "../handlers/error-page.handler.js";
|
||||||
applyRedirectResponse,
|
import { handleFunctionRequest, isFunctionRequest } from "../handlers/function.handler.js";
|
||||||
getHeadersForRoute,
|
import { applyRedirectResponse, tryFindFileForRequest } from "../routes-engine/rules/routes.js";
|
||||||
getMimeTypeForExtension,
|
import { getHeadersForRoute, updateResponseHeaders } from "../routes-engine/rules/headers.js";
|
||||||
isRequestPathExcludedFromNavigationFallback,
|
import { getMimeTypeForExtension } from "../routes-engine/rules/mime-types.js";
|
||||||
tryFindFileForRequest,
|
import { isRequestPathExcludedFromNavigationFallback } from "../routes-engine/rules/navigation-fallback.js";
|
||||||
updateResponseHeaders,
|
import { parseQueryParams } from "../routes-engine/route-processor.js";
|
||||||
} from "../routes-engine";
|
|
||||||
import { parseQueryParams } from "../routes-engine/route-processor";
|
|
||||||
|
|
||||||
export function getResponse(
|
export function getResponse(
|
||||||
req: http.IncomingMessage,
|
req: http.IncomingMessage,
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
export * from "./rules/routes";
|
|
||||||
export * from "./rules/headers";
|
|
||||||
export * from "./rules/mime-types";
|
|
||||||
export * from "./rules/navigation-fallback";
|
|
||||||
export * from "./rules/response-overrides";
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { parseQueryParams } from "./route-processor";
|
import { parseQueryParams } from "./route-processor.js";
|
||||||
|
|
||||||
describe("parseQueryParams()", () => {
|
describe("parseQueryParams()", () => {
|
||||||
const req = {} as http.IncomingMessage;
|
const req = {} as http.IncomingMessage;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { logger } from "../../core";
|
import { logger } from "../../core/utils/logger.js";
|
||||||
import { AUTH_STATUS, CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../../core/constants";
|
import { globToRegExp, isValidGlobExpression } from "../../core/utils/glob.js";
|
||||||
import { globToRegExp, isValidGlobExpression } from "../../core/utils/glob";
|
import { AUTH_STATUS, CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../../core/constants.js";
|
||||||
import { getIndexHtml } from "./rules/routes";
|
import { getIndexHtml } from "./rules/routes.js";
|
||||||
|
|
||||||
export function doesRequestPathMatchRoute(
|
export function doesRequestPathMatchRoute(
|
||||||
requestPath: string,
|
requestPath: string,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import { HEADER_DELETE_KEYWORD } from "../../../core/constants";
|
import { HEADER_DELETE_KEYWORD } from "../../../core/constants.js";
|
||||||
import { getHeadersForRoute, getResponseHeaders, updateResponseHeaders } from "./headers";
|
import { getHeadersForRoute, getResponseHeaders, updateResponseHeaders } from "./headers.js";
|
||||||
|
|
||||||
describe("headers", () => {
|
describe("headers", () => {
|
||||||
describe("getHeadersForRoute()", () => {
|
describe("getHeadersForRoute()", () => {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import type http from "http";
|
import type http from "http";
|
||||||
import { logger } from "../../../core";
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
|
import { CACHE_CONTROL_MAX_AGE, HEADER_DELETE_KEYWORD } from "../../../core/constants.js";
|
||||||
import { CACHE_CONTROL_MAX_AGE, HEADER_DELETE_KEYWORD } from "../../../core/constants";
|
|
||||||
|
|
||||||
// // See: https://docs.microsoft.com/azure/static-web-apps/configuration#global-headers
|
// // See: https://docs.microsoft.com/azure/static-web-apps/configuration#global-headers
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
jest.mock("../../../core/constants", () => {});
|
jest.mock("../../../core/constants", () => {});
|
||||||
import { mimeTypes } from "./mime-types";
|
import { mimeTypes } from "./mime-types.js";
|
||||||
|
|
||||||
describe("mimeTypes()", () => {
|
describe("mimeTypes()", () => {
|
||||||
let req: any;
|
let req: any;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import type http from "http";
|
import type http from "node:http";
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { logger } from "../../../core";
|
import { logger } from "../../../core/utils/logger.js";
|
||||||
import { DEFAULT_MIME_TYPE, MIME_TYPE_LIST } from "../../../core/constants";
|
import { DEFAULT_MIME_TYPE, MIME_TYPE_LIST } from "../../../core/constants.js";
|
||||||
|
|
||||||
// See: https://docs.microsoft.com/azure/static-web-apps/configuration
|
// See: https://docs.microsoft.com/azure/static-web-apps/configuration
|
||||||
export async function mimeTypes(req: http.IncomingMessage, res: http.ServerResponse, mimeTypes: SWAConfigFileMimeTypes) {
|
export async function mimeTypes(req: http.IncomingMessage, res: http.ServerResponse, mimeTypes: SWAConfigFileMimeTypes) {
|
||||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче