зеркало из
1
0
Форкнуть 0

(#864) Convert to type=module in package.json

This commit is contained in:
Adrian Hall 2024-07-02 16:13:12 -07:00
Родитель 3c1ab13fbd
Коммит 12d4c75ccc
107 изменённых файлов: 552 добавлений и 1338 удалений

958
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -2,6 +2,7 @@
"name": "@azure/static-web-apps-cli",
"version": "1.1.10",
"description": "Azure Static Web Apps CLI",
"type": "module",
"scripts": {
"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",

Просмотреть файл

@ -1,6 +1,7 @@
const path = require("path");
const fs = require("fs");
const child_process = require("child_process");
import path from "node:path";
import fs from "node:fs";
import child_process from "node:child_process";
let branch = "";
let hash = "";
let build = "DEV";

Просмотреть файл

@ -1,7 +1,7 @@
import mockFs from "mock-fs";
import { build } from "./build";
import { DEFAULT_CONFIG } from "../../../config";
import { convertToNativePaths } from "../../../jest.helpers";
import { build } from "./build.js";
import { DEFAULT_CONFIG } from "../../../config.js";
import { convertToNativePaths } from "../../../jest.helpers.js";
jest.mock("child_process", () => ({
execSync: jest.fn(),

Просмотреть файл

@ -1,15 +1,12 @@
import path from "path";
import path from "node:path";
import chalk from "chalk";
import { detectProjectFolders, generateConfiguration } from "../../../core/frameworks";
import {
findUpPackageJsonDir,
isUserOrConfigOption,
logger,
pathExists,
readWorkflowFile,
runCommand,
swaCliConfigFilename,
} from "../../../core/utils";
import { detectProjectFolders, generateConfiguration } from "../../../core/frameworks/detect.js";
import { findUpPackageJsonDir, pathExists } from "../../../core/utils/file.js";
import { isUserOrConfigOption } from "../../../core/utils/options.js";
import { logger } from "../../../core/utils/logger.js";
import { readWorkflowFile } from "../../../core/utils/workflow-config.js";
import { runCommand } from "../../../core/utils/command.js";
import { swaCliConfigFilename } from "../../../core/utils/cli-config.js";
export async function build(options: SWACLIConfig) {
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 { DEFAULT_CONFIG } from "../../../config";
import { configureOptions, isUserOption, logger, matchLoadedConfigName } from "../../../core/utils";
import { build } from "./build";
import { DEFAULT_CONFIG } from "../../../config.js";
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
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) {
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 { init, isValidDatabaseType } from "./init";
import path from "path";
import path from "node:path";
import fs from "node:fs";
import { logger } from "../../../../core/utils/logger.js";
import { execFileCommand } from "../../../../core/utils/command.js";
import { init, isValidDatabaseType } from "./init.js";
import {
DATA_API_BUILDER_DATABASE_TYPES,
DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME,
DATA_API_BUILDER_DEFAULT_FOLDER,
} from "../../../../core/constants";
import fs from "fs";
} from "../../../../core/constants.js";
// Replace the imported functions with mocks for testing purposes
jest.mock("../../../../core/dataApiBuilder", () => ({

Просмотреть файл

@ -1,5 +1,5 @@
import fs from "fs";
import path from "path";
import fs from "node:fs";
import path from "node:path";
import {
DATA_API_BUILDER_BINARY_NAME,
DATA_API_BUILDER_DATABASE_TYPES,
@ -8,9 +8,10 @@ import {
DATA_API_BUILDER_DEFAULT_REST_PATH,
DATA_API_BUILDER_DEFAULT_SCHEMA_FILE_NAME,
DEFAULT_DATA_API_BUILDER_SCHEMA_CONTENT,
} from "../../../../core/constants";
import { execFileCommand, logger } from "../../../../core";
import { getDataApiBuilderBinaryPath } from "../../../../core/dataApiBuilder";
} from "../../../../core/constants.js";
import { execFileCommand } from "../../../../core/utils/command.js";
import { logger } from "../../../../core/utils/logger.js";
import { getDataApiBuilderBinaryPath } from "../../../../core/dataApiBuilder/index.js";
export async function init(options: SWACLIConfig) {
let { databaseType, connectionString, cosmosdb_nosqlContainer, cosmosdb_nosqlDatabase } = options;

Просмотреть файл

@ -1,7 +1,7 @@
import { Command } from "commander";
import { configureOptions } from "../../../../core/utils";
import { init } from "./init";
import { DEFAULT_CONFIG } from "../../../../config";
import { configureOptions } from "../../../../core/utils/options.js";
import { init } from "./init.js";
import { DEFAULT_CONFIG } from "../../../../config.js";
export default function registerCommand(program: Command) {
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 path from "path";
import { logger } from "../../../core";
import * as accountModule from "../../../core/account";
import * as deployClientModule from "../../../core/deploy-client";
import { deploy } from "./deploy";
import * as loginModule from "../login/login";
import path from "node:path";
import { logger } from "../../../core/utils/logger.js";
import * as accountModule from "../../../core/account.js";
import * as deployClientModule from "../../../core/deploy-client.js";
import { deploy } from "./deploy.js";
import * as loginModule from "../login/login.js";
const pkg = require(path.join(__dirname, "..", "..", "..", "..", "package.json"));

Просмотреть файл

@ -1,23 +1,19 @@
import chalk from "chalk";
import { spawn } from "child_process";
import fs from "fs";
import { spawn } from "node:child_process";
import fs from "node:fs";
import ora, { Ora } from "ora";
import path from "path";
import {
findSWAConfigFile,
getCurrentSwaCliConfigFromFile,
isUserOrConfigOption,
logger,
logGitHubIssueMessageAndExit,
readWorkflowFile,
updateSwaCliConfigFile,
} from "../../../core";
import { chooseOrCreateProjectDetails, getStaticSiteDeployment } from "../../../core/account";
import { DEFAULT_RUNTIME_LANGUAGE } from "../../../core/constants";
import { cleanUp, getDeployClientPath } from "../../../core/deploy-client";
import { swaCLIEnv } from "../../../core/env";
import { getDefaultVersion } from "../../../core/functions-versions";
import { login } from "../login";
import path from "node:path";
import { findSWAConfigFile } from "../../../core/utils/user-config.js";
import { getCurrentSwaCliConfigFromFile, updateSwaCliConfigFile } from "../../../core/utils/cli-config.js";
import { logger, logGitHubIssueMessageAndExit } from "../../../core/utils/logger.js";
import { isUserOrConfigOption } from "../../../core/utils/options.js";
import { readWorkflowFile } from "../../../core/utils/workflow-config.js";
import { chooseOrCreateProjectDetails, getStaticSiteDeployment } from "../../../core/account.js";
import { DEFAULT_RUNTIME_LANGUAGE } from "../../../core/constants.js";
import { cleanUp, getDeployClientPath } from "../../../core/deploy-client.js";
import { swaCLIEnv } from "../../../core/env.js";
import { getDefaultVersion } from "../../../core/functions-versions.js";
import { login } from "../login/login.js";
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 { DEFAULT_CONFIG } from "../../../config";
import { configureOptions, isUserOption, logger, matchLoadedConfigName } from "../../../core";
import { addSharedLoginOptionsToCommand } from "../login";
import { deploy } from "./deploy";
import { DEFAULT_CONFIG } from "../../../config.js";
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
import { logger } from "../../../core/utils/logger.js";
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) {
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 { init } from "./init";
import { DEFAULT_CONFIG } from "../../../config";
import { swaCliConfigFilename } from "../../../core/utils";
import { convertToNativePaths, convertToUnixPaths } from "../../../jest.helpers";
import { init } from "./init.js";
import { DEFAULT_CONFIG } from "../../../config.js";
import { swaCliConfigFilename } from "../../../core/utils/cli-config.js";
import { convertToNativePaths, convertToUnixPaths } from "../../../jest.helpers.js";
jest.mock("prompts", () => jest.fn());

Просмотреть файл

@ -1,17 +1,12 @@
import chalk from "chalk";
import path from "path";
import process from "process";
import { promptOrUseDefault } from "../../../core/prompts";
import {
dasherize,
hasConfigurationNameInConfigFile,
logger,
swaCliConfigFileExists,
swaCliConfigFilename,
writeConfigFile,
} from "../../../core/utils";
import { detectDbConfigFiles, detectProjectFolders, generateConfiguration, isDescendantPath } from "../../../core/frameworks";
import { getChoicesForApiLanguage } from "../../../core/functions-versions";
import path from "node:path";
import process from "node:process";
import { promptOrUseDefault } from "../../../core/prompts.js";
import { dasherize } from "../../../core/utils/strings.js";
import { hasConfigurationNameInConfigFile, swaCliConfigFileExists, swaCliConfigFilename, writeConfigFile } from "../../../core/utils/cli-config.js";
import { logger } from "../../../core/utils/logger.js";
import { detectDbConfigFiles, detectProjectFolders, generateConfiguration, isDescendantPath } from "../../../core/frameworks/detect.js";
import { getChoicesForApiLanguage } from "../../../core/functions-versions.js";
export async function init(options: SWACLIConfig, showHints: boolean = true) {
const configFilePath = options.config!;

Просмотреть файл

@ -1,7 +1,8 @@
import { Command } from "commander";
import process from "process";
import { configureOptions, isUserOption, logger } from "../../../core/utils";
import { init } from "./init";
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
import { logger } from "../../../core/utils/logger.js";
import { init } from "./init.js";
export default function registerCommand(program: Command) {
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 chalk from "chalk";
import dotenv from "dotenv";
import { existsSync, promises as fsPromises } from "fs";
import path from "path";
import { logger, logGitHubIssueMessageAndExit } from "../../../core";
import { authenticateWithAzureIdentity, listSubscriptions, listTenants } from "../../../core/account";
import { ENV_FILENAME } from "../../../core/constants";
import { updateGitIgnore } from "../../../core/git";
import { chooseSubscription, chooseTenant } from "../../../core/prompts";
import { Environment } from "../../../core/swa-cli-persistence-plugin/impl/azure-environment";
const { readFile, writeFile } = fsPromises;
import { existsSync, promises as fs } from "node:fs";
import path from "node:path";
import { logger, logGitHubIssueMessageAndExit } from "../../../core/utils/logger.js";
import { authenticateWithAzureIdentity, listSubscriptions, listTenants } from "../../../core/account.js";
import { ENV_FILENAME } from "../../../core/constants.js";
import { updateGitIgnore } from "../../../core/git.js";
import { chooseSubscription, chooseTenant } from "../../../core/prompts.js";
import { Environment } from "../../../core/swa-cli-persistence-plugin/impl/azure-environment.js";
const defaultScope = `${Environment.AzureCloud.resourceManagerEndpointUrl}/.default`;
@ -112,7 +111,7 @@ async function storeProjectCredentialsInEnvFile(
) {
const envFile = path.join(process.cwd(), ENV_FILENAME);
const envFileExists = existsSync(envFile);
const envFileContent = envFileExists ? await readFile(envFile, "utf8") : "";
const envFileContent = envFileExists ? await fs.readFile(envFile, "utf8") : "";
const buf = Buffer.from(envFileContent);
// 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
if (newEnvFileLines.length > 0) {
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.`));

Просмотреть файл

@ -1,7 +1,7 @@
import { Command } from "commander";
import { DEFAULT_CONFIG } from "../../../config";
import { configureOptions } from "../../../core";
import { loginCommand as login } from "./login";
import { DEFAULT_CONFIG } from "../../../config.js";
import { configureOptions } from "../../../core/utils/options.js";
import { loginCommand as login } from "./login.js";
export function addSharedLoginOptionsToCommand(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 { Command } from "commander";
import { DEFAULT_CONFIG } from "../../../config";
import { configureOptions, isHttpUrl, isUserOption, logger, matchLoadedConfigName, parseServerTimeout, parsePort } from "../../../core";
import { start } from "./start";
import { DEFAULT_CONFIG } from "../../../config.js";
import { configureOptions, isUserOption } from "../../../core/utils/options.js";
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) {
program

Просмотреть файл

@ -1,23 +1,22 @@
import concurrently, { CloseEvent } from "concurrently";
import { concurrently, CloseEvent, ConcurrentlyOptions } from "concurrently";
import fs from "node:fs";
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 {
askNewPort,
createStartupScriptCommand,
detectTargetCoreToolsVersion,
getCoreToolsBinary,
getNodeMajorVersion,
isAcceptingTcpConnections,
isCoreToolsVersionCompatible,
logger,
parseUrl,
readWorkflowFile,
} from "../../../core";
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../../../core/constants";
import { getDataApiBuilderBinaryPath } from "../../../core/dataApiBuilder";
import { swaCLIEnv } from "../../../core/env";
import { getCertificate } from "../../../core/ssl";
getCoreToolsBinary,
detectTargetCoreToolsVersion,
} from "../../../core/func-core-tools.js";
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../../../core/constants.js";
import { getDataApiBuilderBinaryPath } from "../../../core/dataApiBuilder/index.js";
import { swaCLIEnv } from "../../../core/env.js";
import { getCertificate } from "../../../core/ssl.js";
const packageInfo = require("../../../../package.json");
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
.then(
@ -372,7 +372,7 @@ export async function start(options: SWACLIConfig) {
logger.error(`SWA emulator stopped because ${commandMessage}.`, true);
}
)
.catch((err) => {
.catch((err: Error) => {
logger.error(err.message, true);
});
}

Просмотреть файл

@ -1,7 +1,7 @@
import { program } from "commander";
import { UpdateNotifier } from "update-notifier";
import mockFs from "mock-fs";
import { run } from "./index";
import { run } from "./index.js";
jest.mock("./commands/build/build", () => ({
build: jest.fn(),

Просмотреть файл

@ -1,23 +1,26 @@
import dotenv from "dotenv";
dotenv.config();
import process from "process";
import process from "node:process";
import chalk from "chalk";
import { Command, Option, program } from "commander";
import path from "path";
import path from "node:path";
import updateNotifier from "update-notifier";
import { DEFAULT_CONFIG } from "../config";
import { configureOptions, getCurrentSwaCliConfigFromFile, getNodeMajorVersion, logger, runCommand, swaCliConfigFilename } from "../core";
import { registerDeploy } from "./commands/deploy";
import { registerInit } from "./commands/init";
import { registerLogin } from "./commands/login";
import { registerStart } from "./commands/start";
import { registerBuild } from "./commands/build";
import { registerDocs } from "./commands/docs";
import { registerDb } from "./commands/db/init";
import { promptOrUseDefault } from "../core/prompts";
export * from "./commands";
import { DEFAULT_CONFIG } from "../config.js";
import { configureOptions } from "../core/utils/options.js";
import { getCurrentSwaCliConfigFromFile, swaCliConfigFilename } from "../core/utils/cli-config.js";
import { getNodeMajorVersion } from "../core/func-core-tools.js";
import { logger } from "../core/utils/logger.js";
import { runCommand } from "../core/utils/command.js";
import { default as registerDeploy } from "./commands/deploy/register.js";
import { default as registerInit } from "./commands/init/register.js";
import { default as registerLogin } from "./commands/login/register.js";
import { default as registerStart } from "./commands/start/register.js";
import { default as registerBuild } from "./commands/build/register.js";
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");

Просмотреть файл

@ -1,5 +1,5 @@
import { useEnvVarOrUseDefault, swaCLIEnv } from "./core/env";
import { isRunningInDocker } from "./core/utils/docker";
import { useEnvVarOrUseDefault, swaCLIEnv } from "./core/env.js";
import { isRunningInDocker } from "./core/utils/docker.js";
const {
SWA_CLI_APP_LOCATION,

Просмотреть файл

@ -14,13 +14,20 @@ import {
} from "@azure/identity";
import chalk from "chalk";
import ora from "ora";
import path from "path";
import { swaCLIEnv } from "./env";
import { chooseProjectName, chooseProjectSku, chooseStaticSite, wouldYouLikeToCreateStaticSite, wouldYouLikeToOverrideStaticSite } from "./prompts";
import { swaCliPersistencePlugin } from "./swa-cli-persistence-plugin";
import { SWACLIPersistenceCachePlugin } from "./swa-cli-persistence-plugin/persistence-cache-plugin";
import { dasherize, logger } from "./utils";
import { isRunningInDocker } from "./utils/docker";
import path from "node:path";
import { swaCLIEnv } from "./env.js";
import {
chooseProjectName,
chooseProjectSku,
chooseStaticSite,
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";

Просмотреть файл

@ -1,7 +1,7 @@
import path from "path";
import { DEFAULT_CONFIG } from "../config";
import { address, isHttpUrl } from "./utils/net";
import os from "os";
import os from "node:os";
import path from "node:path";
import { DEFAULT_CONFIG } from "../config.js";
import { address, isHttpUrl } from "./utils/net.js";
// StaticSiteClient related constants
export const DEPLOY_BINARY_NAME = "StaticSitesClient";

Просмотреть файл

@ -1,5 +1,5 @@
import { DEFAULT_DATA_API_BUILDER_BINARY } from "../constants";
import { getDefaultDataApiBuilderBinaryForOS } from "./dab";
import { DEFAULT_DATA_API_BUILDER_BINARY } from "../constants.js";
import { getDefaultDataApiBuilderBinaryForOS } from "./dab.js";
describe("getDefaultDataApiBuilderBinaryForOS", () => {
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_RELEASE_METADATA_URL,
DEFAULT_DATA_API_BUILDER_BINARY,
} from "../constants";
} from "../constants.js";
import fetch from "node-fetch";
import { promisify } from "util";
import { exec } from "child_process";
import fs from "fs";
import os from "os";
import { promisify } from "node:util";
import { exec } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import AdmZip from "adm-zip";
import path from "path";
import { getPlatform, logger } from "../utils";
import { downloadAndValidateBinary } from "../download-binary-helper";
import path from "node:path";
import { logger } from "../utils/logger.js";
import { getPlatform } from "../utils/platform.js";
import { downloadAndValidateBinary } from "../download-binary-helper.js";
/**
* Gets the filepath where the Microsoft.DataApiBuilder.exe is located

Просмотреть файл

@ -1,6 +1,6 @@
import { DATA_API_BUILDER_BINARY_NAME } from "../constants";
import { logger } from "../utils";
import { installAndGetDataApiBuilder } from "./dab";
import { DATA_API_BUILDER_BINARY_NAME } from "../constants.js";
import { logger } from "../utils/logger.js";
import { installAndGetDataApiBuilder } from "./dab.js";
/**
* This function gets the Data-Api Builder binary path and returns it

Просмотреть файл

@ -1,9 +1,9 @@
import mockFs from "mock-fs";
import os from "os";
import path from "path";
import { DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants";
import { fetchClientVersionDefinition, getLocalClientMetadata } from "./deploy-client";
import { getPlatform } from "./utils";
import os from "node:os";
import path from "node:path";
import { DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants.js";
import { fetchClientVersionDefinition, getLocalClientMetadata } from "./deploy-client.js";
import { getPlatform } from "./utils/platform.js";
jest.mock("node-fetch", () => jest.fn());
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 os from "os";
import path from "path";
import { STATIC_SITE_CLIENT_RELEASE_METADATA_URL, DEPLOY_BINARY_NAME, DEPLOY_FOLDER, DEPLOY_BINARY_STABLE_TAG } from "./constants";
import { downloadAndValidateBinary } from "./download-binary-helper";
import { swaCLIEnv } from "./env";
import { getPlatform, logger } from "./utils";
import os from "node:os";
import path from "node:path";
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.js";
import { swaCLIEnv } from "./env.js";
import { logger } from "./utils/logger.js";
import { getPlatform } from "./utils/platform.js";
type StaticSiteClientLocalMetadata = {
metadata: StaticSiteClientReleaseMetadata;

Просмотреть файл

@ -1,12 +1,12 @@
import chalk from "chalk";
import crypto from "crypto";
import fs from "fs";
import crypto from "node:crypto";
import fs from "node:fs";
import fetch from "node-fetch";
import ora from "ora";
import path from "path";
import { PassThrough } from "stream";
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_FOLDER, DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants";
import { logger } from "./utils";
import path from "node:path";
import { PassThrough } from "node:stream";
import { DATA_API_BUILDER_BINARY_NAME, DATA_API_BUILDER_FOLDER, DEPLOY_BINARY_NAME, DEPLOY_FOLDER } from "./constants.js";
import { logger } from "./utils/logger.js";
/**
* Downloads the binary to the given output folder

Просмотреть файл

@ -1,4 +1,4 @@
import { swaCLIEnv } from "./env";
import { swaCLIEnv } from "./env.js";
describe("swaCLIEnv()", () => {
const OLD_ENV = process.env;

Просмотреть файл

@ -1,5 +1,5 @@
import { convertToUnixPaths } from "../../jest.helpers";
import { detectDbConfigFiles, detectProjectFolders, formatDetectedFolders, generateConfiguration } from "./detect";
import { convertToUnixPaths } from "../../jest.helpers.js";
import { detectDbConfigFiles, detectProjectFolders, formatDetectedFolders, generateConfiguration } from "./detect.js";
describe("framework detection", () => {
describe("detectProjectFolders()", () => {

Просмотреть файл

@ -1,10 +1,12 @@
import { promises as fs } from "fs";
import globrex from "globrex";
import path from "path";
import { DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../constants";
import { DEFAULT_CONFIG } from "../../config";
import { hasSpaces, logger, removeTrailingPathSep, safeReadFile, safeReadJson } from "../utils";
import { apiFrameworks, appFrameworks } from "./frameworks";
import { DATA_API_BUILDER_DEFAULT_CONFIG_FILE_NAME } from "../constants.js";
import { DEFAULT_CONFIG } from "../../config.js";
import { hasSpaces, removeTrailingPathSep } from "../utils/strings.js";
import { logger } from "../utils/logger.js";
import { safeReadFile, safeReadJson } from "../utils/file.js";
import { apiFrameworks, appFrameworks } from "./frameworks.js";
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 { sep } from "path";
import { Readable } from "stream";
import { sep } from "node:path";
import { Readable } from "node:stream";
import {
detectTargetCoreToolsVersion,
downloadCoreTools,
getCoreToolsBinary,
getLatestCoreToolsRelease,
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, "warn").mockImplementation();
jest.spyOn(logger, "error").mockImplementation();

Просмотреть файл

@ -1,15 +1,15 @@
import os from "os";
import fs from "fs";
import path from "path";
import process from "process";
import { exec } from "child_process";
import { promisify } from "util";
import { PassThrough } from "stream";
import crypto from "crypto";
import os from "node:os";
import fs from "node:fs";
import path from "node:path";
import process from "node:process";
import { exec } from "node:child_process";
import { promisify } from "node:util";
import { PassThrough } from "node:stream";
import crypto from "node:crypto";
import fetch from "node-fetch";
import AdmZip from "adm-zip";
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 DEFAULT_FUNC_BINARY = "func";

Просмотреть файл

@ -1,5 +1,5 @@
import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "./constants";
import { logger } from "./utils/logger";
import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "./constants.js";
import { logger } from "./utils/logger.js";
export function getDefaultVersion(apiLanguage: string): string {
let apiVersion;

Просмотреть файл

@ -1,6 +1,6 @@
import fs from "fs";
import fs from "node:fs";
import mockFs from "mock-fs";
import { isGitProject, updateGitIgnore } from "./git";
import { isGitProject, updateGitIgnore } from "./git.js";
describe("git", () => {
beforeEach(() => {

Просмотреть файл

@ -1,11 +1,10 @@
import path from "path";
import fs from "fs";
import { logger } from "./utils";
const { readFile, writeFile } = fs.promises;
import path from "node:path";
import { promises as fs, existsSync } from "node:fs";
import { logger } from "./utils/logger.js";
export async function isGitProject() {
const gitFolder = path.join(process.cwd(), ".git");
return fs.existsSync(gitFolder);
return existsSync(gitFolder);
}
export async function updateGitIgnore(entry: string) {
@ -19,14 +18,14 @@ export async function updateGitIgnore(entry: string) {
}
const gitIgnoreFile = path.join(process.cwd(), ".gitignore");
const gitIgnoreFileExists = fs.existsSync(gitIgnoreFile);
const gitIgnoreFileExists = existsSync(gitIgnoreFile);
if (!gitIgnoreFileExists) {
logger.silly(`No .gitignore file found. Skip updating .gitignore`);
return false;
}
const gitIgnoreFileContent = await readFile(gitIgnoreFile, "utf8");
const gitIgnoreFileContent = await fs.readFile(gitIgnoreFile, "utf8");
const gitIgnoreFileLines = gitIgnoreFileContent.length ? gitIgnoreFileContent.split("\n") : [];
const gitIgnoreFileLinesBeforeUpdate = gitIgnoreFileLines.length;
@ -36,7 +35,7 @@ export async function updateGitIgnore(entry: string) {
}
const gitIgnoreFileContentWithProjectDetails = gitIgnoreFileLines.join("\n");
await writeFile(gitIgnoreFile, gitIgnoreFileContentWithProjectDetails, "utf8");
await fs.writeFile(gitIgnoreFile, gitIgnoreFileContentWithProjectDetails, "utf8");
if (gitIgnoreFileLinesBeforeUpdate < gitIgnoreFileLines.length) {
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 chalk from "chalk";
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>(
disablePrompts: boolean,

Просмотреть файл

@ -1,10 +1,8 @@
import baseFs from "fs";
import os from "os";
import path from "path";
import { promises as fs } from "node:fs";
import os from "node:os";
import path from "node:path";
import pem from "pem";
import { logger } from "./utils";
const fs = baseFs.promises;
const { mkdir, writeFile } = fs;
import { logger } from "./utils/logger.js";
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");
await mkdir(cacheDir, { recursive: true });
await writeFile(cachePath, pemContent);
await fs.mkdir(cacheDir, { recursive: true });
await fs.writeFile(cachePath, pemContent);
return cachePath;
}

Просмотреть файл

@ -1,7 +1,9 @@
import { TokenCachePersistenceOptions } from "@azure/identity";
import os from "os";
import os from "node:os";
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");

Просмотреть файл

@ -1,5 +1,5 @@
import crypto from "crypto";
import { logger } from "../../utils";
import crypto from "node:crypto";
import { logger } from "../../utils/logger.js";
interface Encryption {
encrypt(key: string, value: string): Promise<string>;

Просмотреть файл

@ -1,6 +1,6 @@
import crypto from "crypto";
import { networkInterfaces } from "os";
import { logger } from "../../utils";
import crypto from "node:crypto";
import { networkInterfaces } from "node:os";
import { logger } from "../../utils/logger.js";
let machineId: Promise<string>;

Просмотреть файл

@ -1,7 +1,7 @@
import { TokenCachePersistenceOptions } from "@azure/identity";
import { logger } from "../../utils";
import { NativeCredentialsStore } from "./credentials-store";
import { CryptoService } from "./crypto";
import { logger } from "../../utils/logger.js";
import { NativeCredentialsStore } from "./credentials-store.js";
import { CryptoService } from "./crypto.js";
export class SecretStorage {
private secretStoragePrefix: Promise<string>;

Просмотреть файл

@ -1,7 +1,7 @@
import { IdentityPlugin, TokenCachePersistenceOptions } from "@azure/identity";
import { ICachePlugin } from "@azure/msal-common";
import { logger } from "../utils";
import { SWACLIPersistenceCachePlugin } from "./persistence-cache-plugin";
import { logger } from "../utils/logger.js";
import { SWACLIPersistenceCachePlugin } from "./persistence-cache-plugin.js";
/**
* Plugin context entries for controlling cache plugins.

Просмотреть файл

@ -1,11 +1,11 @@
import { TokenCachePersistenceOptions } from "@azure/identity";
import { ICachePlugin, TokenCacheContext } from "@azure/msal-common";
import { logger } from "../utils";
import { Environment } from "./impl/azure-environment";
import { NativeCredentialsStore } from "./impl/credentials-store";
import { CryptoService } from "./impl/crypto";
import { getMachineId } from "./impl/machine-identifier";
import { SecretStorage } from "./impl/secret-storage";
import { logger } from "../utils/logger.js";
import { Environment } from "./impl/azure-environment.js";
import { NativeCredentialsStore } from "./impl/credentials-store.js";
import { CryptoService } from "./impl/crypto.js";
import { getMachineId } from "./impl/machine-identifier.js";
import { SecretStorage } from "./impl/secret-storage.js";
export interface SWACLIPersistenceCacheOptions {
enableCache: boolean;

Просмотреть файл

@ -1,4 +1,5 @@
import mockFs from "mock-fs";
// 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, "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");
import * as path from "path";
import { logger } from "../../core";
import * as cliConfigModule from "./cli-config";
import { getConfigFileOptions, updateSwaCliConfigFile, writeConfigFile } from "./cli-config";
import * as path from "node:path";
import { logger } from "./logger.js";
import * as cliConfigModule from "./cli-config.js";
import { getConfigFileOptions, updateSwaCliConfigFile, writeConfigFile } from "./cli-config.js";
const mockConfig1 = {
$schema: "../../../schema/swa-cli.config.schema.json",

Просмотреть файл

@ -1,8 +1,8 @@
import chalk from "chalk";
import { existsSync, promises as fsPromises } from "fs";
import * as path from "path";
import * as process from "process";
import { logger } from "./logger";
import { existsSync, promises as fsPromises } from "node:fs";
import * as path from "node:path";
import * as process from "node:process";
import { logger } from "./logger.js";
const { readFile, writeFile } = fsPromises;
export const swaCliConfigSchemaUrl = "https://aka.ms/azure/static-web-apps-cli/schema";

Просмотреть файл

@ -1,8 +1,8 @@
jest.mock("../constants", () => {});
import mockFs from "mock-fs";
import path from "path";
import { argv, createStartupScriptCommand, parseServerTimeout } from "./cli";
import { logger } from "./logger";
import path from "node:path";
import { argv, createStartupScriptCommand, parseServerTimeout } from "./cli.js";
import { logger } from "./logger.js";
describe("argv()", () => {
it("process.argv = []", () => {

Просмотреть файл

@ -1,6 +1,6 @@
import path from "path";
import fs from "fs";
import { logger } from "./logger";
import path from "node:path";
import fs from "node:fs";
import { logger } from "./logger.js";
/**
* Parse process.argv and retrieve a specific flag value.

Просмотреть файл

@ -3,7 +3,7 @@ jest.mock("./logger", () => {
silly: jest.fn();
}
});
import { validateCookie } from "./cookie";
import { validateCookie } from "./cookie.js";
describe("validateCookie()", () => {
it("cookies = ''", () => {

Просмотреть файл

@ -1,8 +1,8 @@
import chalk from "chalk";
import cookie from "cookie";
import { SWA_AUTH_CONTEXT_COOKIE, SWA_AUTH_COOKIE } from "../constants";
import { isValueEncryptedAndSigned, validateSignatureAndDecrypt } from "./auth";
import { logger } from "./logger";
import { SWA_AUTH_CONTEXT_COOKIE, SWA_AUTH_COOKIE } from "../constants.js";
import { isValueEncryptedAndSigned, validateSignatureAndDecrypt } from "./auth.js";
import { logger } from "./logger.js";
/**
* 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 { convertToNativePaths } from "../../jest.helpers";
import { findUpPackageJsonDir, pathExists, safeReadFile, safeReadJson } from "./file";
import { convertToNativePaths } from "../../jest.helpers.js";
import { findUpPackageJsonDir, pathExists, safeReadFile, safeReadJson } from "./file.js";
describe("file utilities", () => {
describe("safeReadJson()", () => {

Просмотреть файл

@ -1,7 +1,7 @@
import { promises as fs } from "fs";
import path from "path";
import { logger } from "./logger";
import { stripJsonComments } from "./strings";
import { promises as fs } from "node:fs";
import path from "node:path";
import { logger } from "./logger.js";
import { stripJsonComments } from "./strings.js";
export async function safeReadJson(path: string): Promise<JsonData | undefined> {
try {

Просмотреть файл

@ -1,4 +1,4 @@
import { globToRegExp, isBalancedCurlyBrackets, isValidGlobExpression } from "./glob";
import { globToRegExp, isBalancedCurlyBrackets, isValidGlobExpression } from "./glob.js";
describe("glob functions", () => {
describe("globToRegExp()", () => {

Просмотреть файл

@ -1,5 +1,5 @@
import chalk from "chalk";
import { logger } from "./logger";
import { logger } from "./logger.js";
/**
* 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 type http from "http";
import { CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../constants";
import { swaCLIEnv } from "../env";
import { CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../constants.js";
import { swaCLIEnv } from "../env.js";
const SENSITIVE_KEYS = ["DEPLOYMENT_TOKEN", "SWA_CLI_DEPLOYMENT_TOKEN", "--deployment-token", "deploymentToken"];

Просмотреть файл

@ -1,6 +1,6 @@
jest.mock("../constants", () => {});
import { logger } from "./logger";
import { address, hostnameToIpAdress, isHttpsUrl, parsePort, parseUrl, response } from "./net";
import { logger } from "./logger.js";
import { address, hostnameToIpAdress, isHttpsUrl, parsePort, parseUrl, response } from "./net.js";
describe("net utilities", () => {
describe("response()", () => {

Просмотреть файл

@ -1,10 +1,10 @@
import chalk from "chalk";
import getPort from "get-port";
import net from "net";
import net from "node:net";
import ora from "ora";
import waitOn from "wait-on";
import { confirmChooseRandomPort } from "../prompts";
import { logger } from "./logger";
import { confirmChooseRandomPort } from "../prompts.js";
import { logger } from "./logger.js";
const VALID_PORT_MIN = 1024;
const VALID_PORT_MAX = 65535;

Просмотреть файл

@ -1,10 +1,10 @@
import { Command } from "commander";
import mockFs from "mock-fs";
import { swaCliConfigFilename } from "./cli-config";
import { parsePort } from "./net";
import { parseServerTimeout } from "./cli";
import { configureOptions, getUserOptions } from "./options";
import { DEFAULT_CONFIG } from "../../config";
import { swaCliConfigFilename } from "./cli-config.js";
import { parsePort } from "./net.js";
import { parseServerTimeout } from "./cli.js";
import { configureOptions, getUserOptions } from "./options.js";
import { DEFAULT_CONFIG } from "../../config.js";
describe("configureOptions()", () => {
afterEach(() => {

Просмотреть файл

@ -1,8 +1,8 @@
import { Command, OptionValues, program } from "commander";
import { DEFAULT_CONFIG } from "../../config";
import { SWACommand, SWA_COMMANDS } from "../constants";
import { getConfigFileOptions } from "./cli-config";
import { logger } from "./logger";
import { DEFAULT_CONFIG } from "../../config.js";
import { SWACommand, SWA_COMMANDS } from "../constants.js";
import { getConfigFileOptions } from "./cli-config.js";
import { logger } from "./logger.js";
let userDefinedOptions: SWACLIConfig = {};
let configFileDefinedOptions: SWACLIConfig = {};

Просмотреть файл

@ -1,5 +1,5 @@
import { getPlatform } from "./platform";
import os from "os";
import { getPlatform } from "./platform.js";
import os from "node:os";
describe("getPlatform", () => {
beforeEach(() => {

Просмотреть файл

@ -1,4 +1,4 @@
import { dasherize, hasSpaces, removeTrailingPathSep, stripJsonComments } from "./strings";
import { dasherize, hasSpaces, removeTrailingPathSep, stripJsonComments } from "./strings.js";
describe("string utilities", () => {
describe("dasherize()", () => {
@ -33,9 +33,9 @@ describe("string utilities", () => {
"but": "not // this or /* this */ or /* this"
}`)
).toBe(`{
"hello": "world",
"but": "not // this or /* this */ or /* this"
}`);
});

Просмотреть файл

@ -1,12 +1,12 @@
import { logger } from "./logger";
import { logger } from "./logger.js";
jest.spyOn(logger, "silly").mockImplementation();
jest.spyOn(logger, "warn").mockImplementation();
import mockFs from "mock-fs";
import path from "path";
import { findSWAConfigFile, traverseFolder } from "./user-config";
import * as userConfigModule from "./user-config";
import path from "node:path";
import { findSWAConfigFile, traverseFolder } from "./user-config.js";
import * as userConfigModule from "./user-config.js";
describe("userConfig", () => {
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 fs from "fs";
import type http from "http";
import fs from "node:fs";
import type http from "node:http";
import jsonMap from "json-source-map";
import fetch, { RequestInit } from "node-fetch";
import path from "path";
import path from "node:path";
import {
SWA_CONFIG_FILENAME,
SWA_CONFIG_FILENAME_LEGACY,
SWA_RUNTIME_CONFIG_MAX_SIZE_IN_KB,
SWA_CONFIG_SCHEME_URL,
SWA_CONFIG_SCHEME_FALLBACK_PATH,
} from "../constants";
import { logger } from "./logger";
import { isHttpUrl } from "./net";
} from "../constants.js";
import { logger } from "./logger.js";
import { isHttpUrl } from "./net.js";
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> {
const ajv4 = new Ajv4({
const ajv4 = new Ajv({
strict: false,
allErrors: true,
});

Просмотреть файл

@ -1,8 +1,8 @@
jest.mock("../constants", () => {});
import mockFs from "mock-fs";
import path from "path";
import { convertToNativePaths } from "../../jest.helpers";
import { readWorkflowFile } from "./workflow-config";
import { convertToNativePaths } from "../../jest.helpers.js";
import { readWorkflowFile } from "./workflow-config.js";
jest.mock("../../config", () => {
return {

Просмотреть файл

@ -1,10 +1,10 @@
import fs from "fs";
import path from "path";
import fs from "node:fs";
import path from "node:path";
import YAML from "yaml";
import { DEFAULT_CONFIG } from "../../config";
import { logger } from "./logger";
import { isHttpUrl } from "./net";
import { validateUserWorkflowConfig } from "./user-config";
import { DEFAULT_CONFIG } from "../../config.js";
import { logger } from "./logger.js";
import { isHttpUrl } from "./net.js";
import { validateUserWorkflowConfig } from "./user-config.js";
/**
* Read and parse the project workflow configuration (if available).

Просмотреть файл

@ -1,5 +1,7 @@
import type http from "http";
import { logger, response as newResponse, serializeCookie } from "../../core";
import type http from "node:http";
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[] {
const paths: Path[] = [];

Просмотреть файл

@ -1,10 +1,12 @@
import { CookiesManager, decodeAuthContextCookie, parseUrl, response, validateAuthContextCookie } from "../../../core";
import * as http from "http";
import * as https from "https";
import * as querystring from "querystring";
import { SWA_CLI_API_URI, SWA_CLI_APP_PROTOCOL } from "../../../core/constants";
import { DEFAULT_CONFIG } from "../../../config";
import { encryptAndSign, hashStateGuid, isNonceExpired } from "../../../core/utils/auth";
import * as http from "node:http";
import * as https from "node:https";
import * as querystring from "node:querystring";
import { CookiesManager, decodeAuthContextCookie, validateAuthContextCookie } from "../../../core/utils/cookie.js";
import { parseUrl, response } from "../../../core/utils/net.js";
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 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);
});

Просмотреть файл

@ -1,10 +1,11 @@
import { CookiesManager, response } from "../../../core";
import * as http from "http";
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants";
import { DEFAULT_CONFIG } from "../../../config";
import { encryptAndSign, extractPostLoginRedirectUri, hashStateGuid, newNonceWithExpiration } from "../../../core/utils/auth";
import { IncomingMessage } from "node:http";
import { CookiesManager } from "../../../core/utils/cookie.js";
import { response } from "../../../core/utils/net.js";
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants.js";
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();
const providerName = context.bindingData?.provider?.toLowerCase() || "";

Просмотреть файл

@ -1,5 +1,6 @@
import { IncomingMessage } from "http";
import { CookiesManager, response } from "../../../core";
import { IncomingMessage } from "node:http";
import { CookiesManager } from "../../../core/utils/cookie.js";
import { response } from "../../../core/utils/net.js";
const fs = require("fs").promises;
const path = require("path");

Просмотреть файл

@ -3,8 +3,8 @@ jest.mock("../../../core/constants", () => {
SWA_CLI_APP_PROTOCOL: "https",
};
});
import type http from "http";
import httpTrigger from "./auth-logout";
import type http from "node:http";
import httpTrigger from "./auth-logout.js";
describe("auth-logout-https", () => {
let context: Context;

Просмотреть файл

@ -3,8 +3,8 @@ jest.mock("../../../core/constants", () => {
SWA_CLI_APP_PROTOCOL: "http",
};
});
import { IncomingMessage } from "http";
import httpTrigger from "./auth-logout";
import { IncomingMessage } from "node:http";
import httpTrigger from "./auth-logout.js";
describe("auth_logout", () => {
let context: Context;

Просмотреть файл

@ -1,7 +1,7 @@
import type http from "http";
import { CookiesManager, response } from "../../../core";
// import { response } from "../../../core";
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants";
import type http from "node:http";
import { CookiesManager } from "../../../core/utils/cookie.js";
import { response } from "../../../core/utils/net.js";
import { SWA_CLI_APP_PROTOCOL } from "../../../core/constants.js";
export default async function (context: Context, req: http.IncomingMessage) {
const headers = req?.headers;

Просмотреть файл

@ -1,5 +1,6 @@
import { IncomingMessage } from "http";
import { decodeCookie, response, validateCookie } from "../../../core";
import { IncomingMessage } from "node:http";
import { decodeCookie, validateCookie } from "../../../core/utils/cookie.js";
import { response } from "../../../core/utils/net.js";
const httpTrigger = async function (context: Context, req: IncomingMessage) {
const { cookie } = req.headers;

Просмотреть файл

@ -1,7 +1,7 @@
import type http from "http";
import { logger, logRequest } from "../../core";
import { processAuth } from "../auth";
import { handleErrorPage } from "./error-page.handler";
import type http from "node:http";
import { logger, logRequest } from "../../core/utils/logger.js";
import { processAuth } from "../auth/index.js";
import { handleErrorPage } from "./error-page.handler.js";
export async function handleAuthRequest(
req: http.IncomingMessage,

Просмотреть файл

@ -1,5 +1,5 @@
import http from "http";
import { injectHeaders, isDataApiRequest } from "./dab.handler";
import http from "node:http";
import { injectHeaders, isDataApiRequest } from "./dab.handler.js";
describe("isDataApiRequest", () => {
beforeEach(() => {

Просмотреть файл

@ -1,9 +1,11 @@
import chalk from "chalk";
import type http from "http";
import type http from "node:http";
import httpProxy from "http-proxy";
import { decodeCookie, logger, logRequest, registerProcessExit, validateCookie } from "../../core";
import { SWA_CLI_DATA_API_URI } from "../../core/constants";
import { onConnectionLost } from "../middlewares/request.middleware";
import { registerProcessExit } from "../../core/utils/cli.js";
import { decodeCookie, validateCookie } from "../../core/utils/cookie.js";
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 });
registerProcessExit(() => {

Просмотреть файл

@ -1,8 +1,8 @@
import type http from "http";
import { logRequest } from "../../core";
import { SWA_CLI_APP_PROTOCOL } from "../../core/constants";
import { responseOverrides } from "../routes-engine";
import { isCustomUrl } from "../routes-engine/route-processor";
import type http from "node:http";
import { logRequest } from "../../core/utils/logger.js";
import { SWA_CLI_APP_PROTOCOL } from "../../core/constants.js";
import { responseOverrides } from "../routes-engine/rules/response-overrides.js";
import { isCustomUrl } from "../routes-engine/route-processor.js";
export function handleErrorPage(
req: http.IncomingMessage,

Просмотреть файл

@ -1,11 +1,14 @@
import chalk from "chalk";
import type http from "http";
import type http from "node:http";
import httpProxy from "http-proxy";
import fetch from "node-fetch";
import { decodeCookie, logger, logRequest, registerProcessExit, validateCookie } from "../../core";
import { HAS_API, SWA_CLI_API_URI } from "../../core/constants";
import { parseUrl } from "../../core/utils/net";
import { onConnectionLost } from "../middlewares/request.middleware";
import { decodeCookie, validateCookie } from "../../core/utils/cookie.js";
import { registerProcessExit } from "../../core/utils/cli.js";
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 });
registerProcessExit(() => {

Просмотреть файл

@ -1,23 +1,24 @@
import chalk from "chalk";
import finalhandler from "finalhandler";
import fs from "fs";
import type http from "http";
import fs from "node:fs";
import type http from "node:http";
import httpProxy from "http-proxy";
import type net from "net";
import path from "path";
import type net from "node:net";
import path from "node:path";
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 { getAuthBlockResponse, handleAuthRequest, isAuthRequest, isLoginRequest, isLogoutRequest } from "../handlers/auth.handler";
import { isDataApiRequest } from "../handlers/dab.handler";
import { handleErrorPage } from "../handlers/error-page.handler";
import { isFunctionRequest } from "../handlers/function.handler";
import { isRequestMethodValid, isRouteRequiringUserRolesCheck, tryGetMatchingRoute } from "../routes-engine";
import { isCustomUrl, parseQueryParams } from "../routes-engine/route-processor";
import { getResponse } from "./response.middleware";
import { DEFAULT_CONFIG } from "../../config.js";
import { logger, logRequest } from "../../core/utils/logger.js";
import { findSWAConfigFile } from "../../core/utils/user-config.js";
import { parseUrl } from "../../core/utils/net.js";
import { AUTH_STATUS, CUSTOM_URL_SCHEME, IS_APP_DEV_SERVER, SWA_PUBLIC_DIR } from "../../core/constants.js";
import { getAuthBlockResponse, handleAuthRequest, isAuthRequest, isLoginRequest, isLogoutRequest } from "../handlers/auth.handler.js";
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.

Просмотреть файл

@ -1,19 +1,17 @@
import chalk from "chalk";
import type http from "http";
import { isHttpUrl, isSWAConfigFileUrl, logger } from "../../core";
import { IS_APP_DEV_SERVER } from "../../core/constants";
import { handleDataApiRequest } from "../handlers/dab.handler";
import { handleErrorPage } from "../handlers/error-page.handler";
import { handleFunctionRequest, isFunctionRequest } from "../handlers/function.handler";
import {
applyRedirectResponse,
getHeadersForRoute,
getMimeTypeForExtension,
isRequestPathExcludedFromNavigationFallback,
tryFindFileForRequest,
updateResponseHeaders,
} from "../routes-engine";
import { parseQueryParams } from "../routes-engine/route-processor";
import type http from "node:http";
import { isHttpUrl } from "../../core/utils/net.js";
import { logger } from "../../core/utils/logger.js";
import { isSWAConfigFileUrl } from "../../core/utils/user-config.js";
import { IS_APP_DEV_SERVER } from "../../core/constants.js";
import { handleDataApiRequest } from "../handlers/dab.handler.js";
import { handleErrorPage } from "../handlers/error-page.handler.js";
import { handleFunctionRequest, isFunctionRequest } from "../handlers/function.handler.js";
import { applyRedirectResponse, tryFindFileForRequest } from "../routes-engine/rules/routes.js";
import { getHeadersForRoute, updateResponseHeaders } from "../routes-engine/rules/headers.js";
import { getMimeTypeForExtension } from "../routes-engine/rules/mime-types.js";
import { isRequestPathExcludedFromNavigationFallback } from "../routes-engine/rules/navigation-fallback.js";
import { parseQueryParams } from "../routes-engine/route-processor.js";
export function getResponse(
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 { parseQueryParams } from "./route-processor";
import type http from "node:http";
import { parseQueryParams } from "./route-processor.js";
describe("parseQueryParams()", () => {
const req = {} as http.IncomingMessage;

Просмотреть файл

@ -1,9 +1,9 @@
import chalk from "chalk";
import type http from "http";
import { logger } from "../../core";
import { AUTH_STATUS, CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../../core/constants";
import { globToRegExp, isValidGlobExpression } from "../../core/utils/glob";
import { getIndexHtml } from "./rules/routes";
import type http from "node:http";
import { logger } from "../../core/utils/logger.js";
import { globToRegExp, isValidGlobExpression } from "../../core/utils/glob.js";
import { AUTH_STATUS, CUSTOM_URL_SCHEME, SWA_CLI_APP_PROTOCOL } from "../../core/constants.js";
import { getIndexHtml } from "./rules/routes.js";
export function doesRequestPathMatchRoute(
requestPath: string,

Просмотреть файл

@ -1,6 +1,6 @@
import type http from "http";
import { HEADER_DELETE_KEYWORD } from "../../../core/constants";
import { getHeadersForRoute, getResponseHeaders, updateResponseHeaders } from "./headers";
import type http from "node:http";
import { HEADER_DELETE_KEYWORD } from "../../../core/constants.js";
import { getHeadersForRoute, getResponseHeaders, updateResponseHeaders } from "./headers.js";
describe("headers", () => {
describe("getHeadersForRoute()", () => {

Просмотреть файл

@ -1,7 +1,6 @@
import type http from "http";
import { logger } from "../../../core";
import { CACHE_CONTROL_MAX_AGE, HEADER_DELETE_KEYWORD } from "../../../core/constants";
import { logger } from "../../../core/utils/logger.js";
import { CACHE_CONTROL_MAX_AGE, HEADER_DELETE_KEYWORD } from "../../../core/constants.js";
// // See: https://docs.microsoft.com/azure/static-web-apps/configuration#global-headers

Просмотреть файл

@ -1,5 +1,5 @@
jest.mock("../../../core/constants", () => {});
import { mimeTypes } from "./mime-types";
import { mimeTypes } from "./mime-types.js";
describe("mimeTypes()", () => {
let req: any;

Просмотреть файл

@ -1,8 +1,8 @@
import chalk from "chalk";
import type http from "http";
import path from "path";
import { logger } from "../../../core";
import { DEFAULT_MIME_TYPE, MIME_TYPE_LIST } from "../../../core/constants";
import type http from "node:http";
import path from "node:path";
import { logger } from "../../../core/utils/logger.js";
import { DEFAULT_MIME_TYPE, MIME_TYPE_LIST } from "../../../core/constants.js";
// See: https://docs.microsoft.com/azure/static-web-apps/configuration
export async function mimeTypes(req: http.IncomingMessage, res: http.ServerResponse, mimeTypes: SWAConfigFileMimeTypes) {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше