From 03ae2ebcf798b1ab96763d89dc7619b23be0c95b Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:26:13 +0900 Subject: [PATCH 1/9] Add .js suffix to migrate to ESM --- .../src/bin/autify-mobile-generate-fake-app.ts | 2 +- integration-test/src/bin/autify-with-proxy.ts | 2 +- .../src/test/golden/mobileBuildUpload.test.ts | 2 +- .../test/golden/mobileBuildUploadIos.test.ts | 2 +- .../test/golden/mobileBuildUploadJson.test.ts | 2 +- .../src/test/golden/mobileTestRun.test.ts | 2 +- .../test/golden/mobileTestRunAndroid.test.ts | 2 +- .../golden/mobileTestRunAndroidWait.test.ts | 2 +- .../src/test/golden/mobileTestRunIos.test.ts | 2 +- .../test/golden/mobileTestRunIosWait.test.ts | 2 +- .../src/test/golden/mobileTestRunWait.test.ts | 2 +- .../src/test/golden/webTestRun.test.ts | 2 +- .../webTestRunAutifyConnectClient.test.ts | 2 +- .../src/test/golden/webTestRunTestPlan.test.ts | 2 +- ...bTestRunTestPlanAutifyConnectClient.test.ts | 2 +- .../test/golden/webTestRunTestPlanWait.test.ts | 2 +- .../golden/webTestRunUrlReplacements.test.ts | 2 +- ...webTestRunUrlReplacementsDeprecated.test.ts | 2 +- .../src/test/golden/webTestRunWait.test.ts | 2 +- .../src/test/helpers/testAutifyCliSnapshot.ts | 2 +- src/autify/connect/accessPointConfig.ts | 2 +- .../connect/client-manager/ClientManager.ts | 18 +++++++++--------- .../client-manager/DebugServerClient.ts | 2 +- .../connect/client-manager/StateMachine.ts | 2 +- src/autify/connect/installClient.ts | 2 +- src/autify/getWaitIntervalSecond.ts | 2 +- src/autify/mobile/getBuildDetailUrl.ts | 2 +- src/autify/mobile/getMobileClient.ts | 2 +- src/autify/mobile/getTestResultUrl.ts | 2 +- src/autify/mobile/inspectBuildFile.ts | 2 +- src/autify/mobile/uploadBuild.ts | 2 +- src/autify/web/getTestResultUrl.ts | 2 +- src/autify/web/getWebClient.ts | 2 +- src/autify/web/runTest.ts | 2 +- src/commands/connect/access-point/create.ts | 4 ++-- src/commands/connect/access-point/set.ts | 2 +- src/commands/connect/client/install.ts | 2 +- src/commands/connect/client/start.ts | 2 +- .../mobile/api/describe-test-result.ts | 2 +- src/commands/mobile/api/list-test-results.ts | 2 +- src/commands/mobile/api/run-test-plan.ts | 2 +- src/commands/mobile/api/upload-build.ts | 2 +- src/commands/mobile/auth/login.ts | 2 +- src/commands/mobile/build/upload.ts | 6 +++--- src/commands/mobile/test/run.ts | 10 +++++----- src/commands/mobile/test/wait.ts | 10 +++++----- src/commands/web/api/create-access-point.ts | 2 +- src/commands/web/api/create-url-replacement.ts | 2 +- src/commands/web/api/delete-access-point.ts | 2 +- src/commands/web/api/delete-url-replacement.ts | 2 +- src/commands/web/api/describe-result.ts | 2 +- src/commands/web/api/describe-scenario.ts | 2 +- src/commands/web/api/execute-scenarios.ts | 2 +- src/commands/web/api/execute-schedule.ts | 2 +- src/commands/web/api/list-access-points.ts | 2 +- src/commands/web/api/list-capabilities.ts | 2 +- src/commands/web/api/list-results.ts | 2 +- src/commands/web/api/list-scenarios.ts | 2 +- src/commands/web/api/list-url-replacements.ts | 2 +- src/commands/web/api/update-url-replacement.ts | 2 +- src/commands/web/auth/login.ts | 2 +- src/commands/web/test/run.ts | 12 ++++++------ src/commands/web/test/wait.ts | 10 +++++----- 63 files changed, 91 insertions(+), 91 deletions(-) diff --git a/integration-test/src/bin/autify-mobile-generate-fake-app.ts b/integration-test/src/bin/autify-mobile-generate-fake-app.ts index a208d7bc..33f9af18 100644 --- a/integration-test/src/bin/autify-mobile-generate-fake-app.ts +++ b/integration-test/src/bin/autify-mobile-generate-fake-app.ts @@ -1,6 +1,6 @@ import { existsSync, mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; -import { androidBuildPath, iosBuildPath } from "../commands"; +import { androidBuildPath, iosBuildPath } from "../commands.js"; // https://commons.wikimedia.org/wiki/File:Transparent.gif const tinyBinary = Buffer.from( diff --git a/integration-test/src/bin/autify-with-proxy.ts b/integration-test/src/bin/autify-with-proxy.ts index b1510336..61e949e4 100644 --- a/integration-test/src/bin/autify-with-proxy.ts +++ b/integration-test/src/bin/autify-with-proxy.ts @@ -10,7 +10,7 @@ import path from "node:path"; import { argv, env, exit } from "node:process"; import { existsSync } from "node:fs"; import which from "which"; -import { normalizeCommand } from "../commands"; +import { normalizeCommand } from "../commands.js"; Polly.register(NodeHttpAdapter); Polly.register(FSPersister); diff --git a/integration-test/src/test/golden/mobileBuildUpload.test.ts b/integration-test/src/test/golden/mobileBuildUpload.test.ts index af0a44da..9940531b 100644 --- a/integration-test/src/test/golden/mobileBuildUpload.test.ts +++ b/integration-test/src/test/golden/mobileBuildUpload.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile build upload /path/to/app-debug.apk --workspace-id AAA" diff --git a/integration-test/src/test/golden/mobileBuildUploadIos.test.ts b/integration-test/src/test/golden/mobileBuildUploadIos.test.ts index 719e8c77..4a00a518 100644 --- a/integration-test/src/test/golden/mobileBuildUploadIos.test.ts +++ b/integration-test/src/test/golden/mobileBuildUploadIos.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile build upload /path/to/ios.app --workspace-id AAA" diff --git a/integration-test/src/test/golden/mobileBuildUploadJson.test.ts b/integration-test/src/test/golden/mobileBuildUploadJson.test.ts index 0d2529e8..85386c4b 100644 --- a/integration-test/src/test/golden/mobileBuildUploadJson.test.ts +++ b/integration-test/src/test/golden/mobileBuildUploadJson.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile build upload /path/to/app-debug.apk --workspace-id AAA --json" diff --git a/integration-test/src/test/golden/mobileTestRun.test.ts b/integration-test/src/test/golden/mobileTestRun.test.ts index 94659209..b583c2e1 100644 --- a/integration-test/src/test/golden/mobileTestRun.test.ts +++ b/integration-test/src/test/golden/mobileTestRun.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-id CCC" diff --git a/integration-test/src/test/golden/mobileTestRunAndroid.test.ts b/integration-test/src/test/golden/mobileTestRunAndroid.test.ts index 95ac98e2..78f26965 100644 --- a/integration-test/src/test/golden/mobileTestRunAndroid.test.ts +++ b/integration-test/src/test/golden/mobileTestRunAndroid.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/app-debug.apk" diff --git a/integration-test/src/test/golden/mobileTestRunAndroidWait.test.ts b/integration-test/src/test/golden/mobileTestRunAndroidWait.test.ts index d00f183e..09bf8806 100644 --- a/integration-test/src/test/golden/mobileTestRunAndroidWait.test.ts +++ b/integration-test/src/test/golden/mobileTestRunAndroidWait.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/app-debug.apk --wait" diff --git a/integration-test/src/test/golden/mobileTestRunIos.test.ts b/integration-test/src/test/golden/mobileTestRunIos.test.ts index a840dbf0..edec14a2 100644 --- a/integration-test/src/test/golden/mobileTestRunIos.test.ts +++ b/integration-test/src/test/golden/mobileTestRunIos.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/MyApp.app" diff --git a/integration-test/src/test/golden/mobileTestRunIosWait.test.ts b/integration-test/src/test/golden/mobileTestRunIosWait.test.ts index c46e2fdb..34c98c54 100644 --- a/integration-test/src/test/golden/mobileTestRunIosWait.test.ts +++ b/integration-test/src/test/golden/mobileTestRunIosWait.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/MyApp.app --wait" diff --git a/integration-test/src/test/golden/mobileTestRunWait.test.ts b/integration-test/src/test/golden/mobileTestRunWait.test.ts index c1e2cef6..80f2b850 100644 --- a/integration-test/src/test/golden/mobileTestRunWait.test.ts +++ b/integration-test/src/test/golden/mobileTestRunWait.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-id CCC --wait" diff --git a/integration-test/src/test/golden/webTestRun.test.ts b/integration-test/src/test/golden/webTestRun.test.ts index 1f4f7cab..36b214b8 100644 --- a/integration-test/src/test/golden/webTestRun.test.ts +++ b/integration-test/src/test/golden/webTestRun.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "web test run https://app.autify.com/projects/0000/scenarios/0000" diff --git a/integration-test/src/test/golden/webTestRunAutifyConnectClient.test.ts b/integration-test/src/test/golden/webTestRunAutifyConnectClient.test.ts index 29282994..bd91463f 100644 --- a/integration-test/src/test/golden/webTestRunAutifyConnectClient.test.ts +++ b/integration-test/src/test/golden/webTestRunAutifyConnectClient.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "web test run https://app.autify.com/projects/0000/scenarios/0000 --wait --autify-connect-client" diff --git a/integration-test/src/test/golden/webTestRunTestPlan.test.ts b/integration-test/src/test/golden/webTestRunTestPlan.test.ts index cb8a0e59..bf3ffee6 100644 --- a/integration-test/src/test/golden/webTestRunTestPlan.test.ts +++ b/integration-test/src/test/golden/webTestRunTestPlan.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "web test run https://app.autify.com/projects/0000/test_plans/0000" diff --git a/integration-test/src/test/golden/webTestRunTestPlanAutifyConnectClient.test.ts b/integration-test/src/test/golden/webTestRunTestPlanAutifyConnectClient.test.ts index 8a91dfdd..ab6018e7 100644 --- a/integration-test/src/test/golden/webTestRunTestPlanAutifyConnectClient.test.ts +++ b/integration-test/src/test/golden/webTestRunTestPlanAutifyConnectClient.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "web test run https://app.autify.com/projects/0000/test_plans/0000 --wait --autify-connect-client" diff --git a/integration-test/src/test/golden/webTestRunTestPlanWait.test.ts b/integration-test/src/test/golden/webTestRunTestPlanWait.test.ts index d627b47a..40f1353b 100644 --- a/integration-test/src/test/golden/webTestRunTestPlanWait.test.ts +++ b/integration-test/src/test/golden/webTestRunTestPlanWait.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "web test run https://app.autify.com/projects/0000/test_plans/0000 --wait" diff --git a/integration-test/src/test/golden/webTestRunUrlReplacements.test.ts b/integration-test/src/test/golden/webTestRunUrlReplacements.test.ts index 3fd9fb09..9c0c44d8 100644 --- a/integration-test/src/test/golden/webTestRunUrlReplacements.test.ts +++ b/integration-test/src/test/golden/webTestRunUrlReplacements.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( 'web test run https://app.autify.com/projects/0000/scenarios/0000 -r "https://example.com https://example.net?foo=bar"' diff --git a/integration-test/src/test/golden/webTestRunUrlReplacementsDeprecated.test.ts b/integration-test/src/test/golden/webTestRunUrlReplacementsDeprecated.test.ts index 396b385a..015a27ab 100644 --- a/integration-test/src/test/golden/webTestRunUrlReplacementsDeprecated.test.ts +++ b/integration-test/src/test/golden/webTestRunUrlReplacementsDeprecated.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( 'web test run https://app.autify.com/projects/0000/scenarios/0000 -r "https://example.com=https://example.net?foo=bar"' diff --git a/integration-test/src/test/golden/webTestRunWait.test.ts b/integration-test/src/test/golden/webTestRunWait.test.ts index a102a9c9..afced5d7 100644 --- a/integration-test/src/test/golden/webTestRunWait.test.ts +++ b/integration-test/src/test/golden/webTestRunWait.test.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot"; +import { testAutifyCliSnapshot } from "../helpers/testAutifyCliSnapshot.js"; testAutifyCliSnapshot( "web test run https://app.autify.com/projects/0000/scenarios/0000 --wait" diff --git a/integration-test/src/test/helpers/testAutifyCliSnapshot.ts b/integration-test/src/test/helpers/testAutifyCliSnapshot.ts index 40cebe0f..bad934d7 100644 --- a/integration-test/src/test/helpers/testAutifyCliSnapshot.ts +++ b/integration-test/src/test/helpers/testAutifyCliSnapshot.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { execAutifyCli } from "../helpers/execAutifyCli"; +import { execAutifyCli } from "../helpers/execAutifyCli.js"; export const testAutifyCliSnapshot = (command: string): void => { test(`autify ${command}`, async () => { diff --git a/src/autify/connect/accessPointConfig.ts b/src/autify/connect/accessPointConfig.ts index eb463c5c..c5dc918e 100644 --- a/src/autify/connect/accessPointConfig.ts +++ b/src/autify/connect/accessPointConfig.ts @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case */ import { CLIError } from "@oclif/errors"; import inquirer from "inquirer"; -import { get, set } from "../../config"; +import { get, set } from "../../config.js"; export const confirmOverwriteAccessPoint = async ( configDir: string diff --git a/src/autify/connect/client-manager/ClientManager.ts b/src/autify/connect/client-manager/ClientManager.ts index ef3197c4..790aeb87 100644 --- a/src/autify/connect/client-manager/ClientManager.ts +++ b/src/autify/connect/client-manager/ClientManager.ts @@ -3,33 +3,33 @@ import { WebClient } from "@autifyhq/autify-sdk"; import { CLIError } from "@oclif/errors"; import { ChildProcessWithoutNullStreams, spawn } from "node:child_process"; import { env } from "node:process"; -import { EventEmitter } from "node:stream"; +import { EventEmitter } from "node:events"; import { Logger } from "winston"; -import { get } from "../../../config"; +import { get } from "../../../config.js"; import { AccessPoint, createEphemeralAccessPointForWeb, createStaticAccessPoint, -} from "./AccessPoint"; +} from "./AccessPoint.js"; import { AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION, ConnectClientVersionMismatchError, getInstallPath, getInstallVersion, validateVersion, -} from "../installClient"; -import { waitFor } from "xstate/lib/waitFor"; -import { DebugServerClient } from "./DebugServerClient"; -import { ClientStateMachineService, createService } from "./StateMachine"; +} from "../installClient.js"; +import { waitFor } from "xstate/lib/waitFor.js"; +import { DebugServerClient } from "./DebugServerClient.js"; +import { ClientStateMachineService, createService } from "./StateMachine.js"; import { createClientLogger, createManagerLogger, setupClientOutputLogger, -} from "./Logger"; +} from "./Logger.js"; import { join } from "node:path"; import TypedEmitter from "typed-emitter"; import getPort from "get-port"; -import { getWebClient } from "../../web/getWebClient"; +import { getWebClient } from "../../web/getWebClient.js"; import { parse } from "shell-quote"; export type ClientEvents = TypedEmitter<{ diff --git a/src/autify/connect/client-manager/DebugServerClient.ts b/src/autify/connect/client-manager/DebugServerClient.ts index 41df656f..6fe8f37b 100644 --- a/src/autify/connect/client-manager/DebugServerClient.ts +++ b/src/autify/connect/client-manager/DebugServerClient.ts @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case */ import { CLIError } from "@oclif/errors"; import fetch from "node-fetch"; -import { ClientEvents } from "./ClientManager"; +import { ClientEvents } from "./ClientManager.js"; import AbortController from "abort-controller"; type DebugServerRequest = Readonly<{ diff --git a/src/autify/connect/client-manager/StateMachine.ts b/src/autify/connect/client-manager/StateMachine.ts index c23f6a4e..4bb30b44 100644 --- a/src/autify/connect/client-manager/StateMachine.ts +++ b/src/autify/connect/client-manager/StateMachine.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ import { assign, createMachine, interpret, Interpreter } from "xstate"; -import { StateMachineTimeoutError, ProcessExit } from "./ClientManager"; +import { StateMachineTimeoutError, ProcessExit } from "./ClientManager.js"; type ClientStateMachineContext = { spawn: (debugServerPort: number) => void; diff --git a/src/autify/connect/installClient.ts b/src/autify/connect/installClient.ts index 24f8bb77..027dc493 100644 --- a/src/autify/connect/installClient.ts +++ b/src/autify/connect/installClient.ts @@ -17,7 +17,7 @@ import { basename, dirname, join } from "node:path"; import { Extract } from "unzip-stream"; import { execFile } from "node:child_process"; import tar from "tar"; -import { get } from "../../config"; +import { get } from "../../config.js"; // Update whenever to bump supported version. export const AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION = "v1.0.2"; diff --git a/src/autify/getWaitIntervalSecond.ts b/src/autify/getWaitIntervalSecond.ts index 27f58d17..f83714b4 100644 --- a/src/autify/getWaitIntervalSecond.ts +++ b/src/autify/getWaitIntervalSecond.ts @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -import { get } from "../config"; +import { get } from "../config.js"; const DEFAULT_INTERVAL_SECOND = 1; diff --git a/src/autify/mobile/getBuildDetailUrl.ts b/src/autify/mobile/getBuildDetailUrl.ts index 48f761a8..2410edcc 100644 --- a/src/autify/mobile/getBuildDetailUrl.ts +++ b/src/autify/mobile/getBuildDetailUrl.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ import { MOBILE_BASE_PATH } from "@autifyhq/autify-sdk"; -import { get } from "../../config"; +import { get } from "../../config.js"; export const getBuildDetailUrl = ( configDir: string, diff --git a/src/autify/mobile/getMobileClient.ts b/src/autify/mobile/getMobileClient.ts index bdc5f347..0dd436be 100644 --- a/src/autify/mobile/getMobileClient.ts +++ b/src/autify/mobile/getMobileClient.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ import { MobileClient } from "@autifyhq/autify-sdk"; -import { get, getOrThrow } from "../../config"; +import { get, getOrThrow } from "../../config.js"; export const getMobileClient = ( configDir: string, diff --git a/src/autify/mobile/getTestResultUrl.ts b/src/autify/mobile/getTestResultUrl.ts index dee74a3e..57929db3 100644 --- a/src/autify/mobile/getTestResultUrl.ts +++ b/src/autify/mobile/getTestResultUrl.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ import { MOBILE_BASE_PATH } from "@autifyhq/autify-sdk"; -import { get } from "../../config"; +import { get } from "../../config.js"; export const getMobileTestResultUrl = ( configDir: string, diff --git a/src/autify/mobile/inspectBuildFile.ts b/src/autify/mobile/inspectBuildFile.ts index cdd008c6..d17d00ae 100644 --- a/src/autify/mobile/inspectBuildFile.ts +++ b/src/autify/mobile/inspectBuildFile.ts @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case */ import { CLIError } from "@oclif/errors"; import { lstatSync } from "node:fs"; -import { createZip } from "./createZip"; +import { createZip } from "./createZip.js"; const isIosApp = (buildPath: string) => { return ( diff --git a/src/autify/mobile/uploadBuild.ts b/src/autify/mobile/uploadBuild.ts index 87268103..4b2dcc25 100644 --- a/src/autify/mobile/uploadBuild.ts +++ b/src/autify/mobile/uploadBuild.ts @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case */ import { MobileClient } from "@autifyhq/autify-sdk"; import { CLIError } from "@oclif/errors"; -import { inspectBuildFile } from "./inspectBuildFile"; +import { inspectBuildFile } from "./inspectBuildFile.js"; export const uploadBuild = async ( client: MobileClient, diff --git a/src/autify/web/getTestResultUrl.ts b/src/autify/web/getTestResultUrl.ts index fdefcdd1..fa39ce01 100644 --- a/src/autify/web/getTestResultUrl.ts +++ b/src/autify/web/getTestResultUrl.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ import { WEB_BASE_PATH } from "@autifyhq/autify-sdk"; -import { get } from "../../config"; +import { get } from "../../config.js"; export const getWebTestResultUrl = ( configDir: string, diff --git a/src/autify/web/getWebClient.ts b/src/autify/web/getWebClient.ts index 4324f2a3..8ac1e319 100644 --- a/src/autify/web/getWebClient.ts +++ b/src/autify/web/getWebClient.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ import { WebClient } from "@autifyhq/autify-sdk"; -import { get, getOrThrow } from "../../config"; +import { get, getOrThrow } from "../../config.js"; export const getWebClient = ( configDir: string, diff --git a/src/autify/web/runTest.ts b/src/autify/web/runTest.ts index df2f0382..4cb92082 100644 --- a/src/autify/web/runTest.ts +++ b/src/autify/web/runTest.ts @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case */ import { CLIError } from "@oclif/errors"; import { WebClient } from "@autifyhq/autify-sdk"; -import { TestPlan, TestScenario } from "./parseAutifyTestUrl"; +import { TestPlan, TestScenario } from "./parseAutifyTestUrl.js"; type CapabilityOption = Parameters< WebClient["executeScenarios"] diff --git a/src/commands/connect/access-point/create.ts b/src/commands/connect/access-point/create.ts index 9edd1d35..8c0af84b 100644 --- a/src/commands/connect/access-point/create.ts +++ b/src/commands/connect/access-point/create.ts @@ -2,8 +2,8 @@ import { Command, Flags } from "@oclif/core"; import { confirmOverwriteAccessPoint, saveAccessPoint, -} from "../../../autify/connect/accessPointConfig"; -import { getWebClient } from "../../../autify/web/getWebClient"; +} from "../../../autify/connect/accessPointConfig.js"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class ConnectAccessPointCreate extends Command { static description = "Create an Autify Connect Access Point"; diff --git a/src/commands/connect/access-point/set.ts b/src/commands/connect/access-point/set.ts index 3ba10648..6b8805ff 100644 --- a/src/commands/connect/access-point/set.ts +++ b/src/commands/connect/access-point/set.ts @@ -3,7 +3,7 @@ import * as inquirer from "inquirer"; import { confirmOverwriteAccessPoint, saveAccessPoint, -} from "../../../autify/connect/accessPointConfig"; +} from "../../../autify/connect/accessPointConfig.js"; export default class ConnectAccessPointSet extends Command { static description = "Set Autify Connect Access Point"; diff --git a/src/commands/connect/client/install.ts b/src/commands/connect/client/install.ts index fe68d2f5..bdd26e38 100644 --- a/src/commands/connect/client/install.ts +++ b/src/commands/connect/client/install.ts @@ -3,7 +3,7 @@ import { AUTIFY_CONNECT_CLIENT_SUPPORTED_VERSION, getConnectClientSourceUrl, installClient, -} from "../../../autify/connect/installClient"; +} from "../../../autify/connect/installClient.js"; export default class ConnectClientInstall extends Command { static description = "Install Autify Connect Client"; diff --git a/src/commands/connect/client/start.ts b/src/commands/connect/client/start.ts index d7177153..9ca84607 100644 --- a/src/commands/connect/client/start.ts +++ b/src/commands/connect/client/start.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { ClientManager } from "../../../autify/connect/client-manager/ClientManager"; +import { ClientManager } from "../../../autify/connect/client-manager/ClientManager.js"; export default class ConnectClientStart extends Command { static description = "Start Autify Connect Client"; diff --git a/src/commands/mobile/api/describe-test-result.ts b/src/commands/mobile/api/describe-test-result.ts index d8d4a5e4..35f69df6 100644 --- a/src/commands/mobile/api/describe-test-result.ts +++ b/src/commands/mobile/api/describe-test-result.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; export default class MobileApiDescribeTestResult extends Command { static description = "Get a test result."; diff --git a/src/commands/mobile/api/list-test-results.ts b/src/commands/mobile/api/list-test-results.ts index a14d7f9f..99af1469 100644 --- a/src/commands/mobile/api/list-test-results.ts +++ b/src/commands/mobile/api/list-test-results.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; export default class MobileApiListTestResults extends Command { static description = "List test results."; diff --git a/src/commands/mobile/api/run-test-plan.ts b/src/commands/mobile/api/run-test-plan.ts index 1a15b989..f95488b7 100644 --- a/src/commands/mobile/api/run-test-plan.ts +++ b/src/commands/mobile/api/run-test-plan.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; export default class MobileApiRunTestPlan extends Command { static description = "Run a test plan"; diff --git a/src/commands/mobile/api/upload-build.ts b/src/commands/mobile/api/upload-build.ts index cb95a160..91fb7b68 100644 --- a/src/commands/mobile/api/upload-build.ts +++ b/src/commands/mobile/api/upload-build.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; export default class MobileApiUploadBuild extends Command { static description = "Upload the build file."; diff --git a/src/commands/mobile/auth/login.ts b/src/commands/mobile/auth/login.ts index e9c22399..a91e8799 100644 --- a/src/commands/mobile/auth/login.ts +++ b/src/commands/mobile/auth/login.ts @@ -1,6 +1,6 @@ import { Command } from "@oclif/core"; import * as inquirer from "inquirer"; -import { set } from "../../../config"; +import { set } from "../../../config.js"; export default class MobileAuthLogin extends Command { static description = "Login to Autify for Mobile"; diff --git a/src/commands/mobile/build/upload.ts b/src/commands/mobile/build/upload.ts index c8810559..359119cd 100644 --- a/src/commands/mobile/build/upload.ts +++ b/src/commands/mobile/build/upload.ts @@ -1,8 +1,8 @@ import { Command, Args, Flags } from "@oclif/core"; import emoji from "node-emoji"; -import { getBuildDetailUrl } from "../../../autify/mobile/getBuildDetailUrl"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; -import { uploadBuild } from "../../../autify/mobile/uploadBuild"; +import { getBuildDetailUrl } from "../../../autify/mobile/getBuildDetailUrl.js"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; +import { uploadBuild } from "../../../autify/mobile/uploadBuild.js"; export default class MobileBuildUpload extends Command { static enableJsonFlag = true; diff --git a/src/commands/mobile/test/run.ts b/src/commands/mobile/test/run.ts index 7b738aed..f1c19d41 100644 --- a/src/commands/mobile/test/run.ts +++ b/src/commands/mobile/test/run.ts @@ -1,11 +1,11 @@ import { Command, Args, Flags } from "@oclif/core"; import { CLIError } from "@oclif/errors"; import emoji from "node-emoji"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; -import { getMobileTestResultUrl } from "../../../autify/mobile/getTestResultUrl"; -import { parseTestPlanUrl } from "../../../autify/mobile/parseTestPlanUrl"; -import MobileBuildUpload from "../build/upload"; -import MobileTestWait from "./wait"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; +import { getMobileTestResultUrl } from "../../../autify/mobile/getTestResultUrl.js"; +import { parseTestPlanUrl } from "../../../autify/mobile/parseTestPlanUrl.js"; +import MobileBuildUpload from "../build/upload.js"; +import MobileTestWait from "./wait.js"; export default class MobileTestRun extends Command { static description = "Run a test plan."; diff --git a/src/commands/mobile/test/wait.ts b/src/commands/mobile/test/wait.ts index 672c421a..429af969 100644 --- a/src/commands/mobile/test/wait.ts +++ b/src/commands/mobile/test/wait.ts @@ -1,10 +1,10 @@ import { Command, Args, Flags } from "@oclif/core"; import emoji from "node-emoji"; -import { getWaitIntervalSecond } from "../../../autify/getWaitIntervalSecond"; -import { getMobileClient } from "../../../autify/mobile/getMobileClient"; -import { getMobileTestResultUrl } from "../../../autify/mobile/getTestResultUrl"; -import { parseTestResultUrl } from "../../../autify/mobile/parseTestResultUrl"; -import { waitTestResult } from "../../../autify/mobile/waitTestResult"; +import { getWaitIntervalSecond } from "../../../autify/getWaitIntervalSecond.js"; +import { getMobileClient } from "../../../autify/mobile/getMobileClient.js"; +import { getMobileTestResultUrl } from "../../../autify/mobile/getTestResultUrl.js"; +import { parseTestResultUrl } from "../../../autify/mobile/parseTestResultUrl.js"; +import { waitTestResult } from "../../../autify/mobile/waitTestResult.js"; export default class MobileTestWait extends Command { static description = "Wait a test result until it finishes."; diff --git a/src/commands/web/api/create-access-point.ts b/src/commands/web/api/create-access-point.ts index 64af27b0..1cf84f50 100644 --- a/src/commands/web/api/create-access-point.ts +++ b/src/commands/web/api/create-access-point.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiCreateAccessPoint extends Command { static description = diff --git a/src/commands/web/api/create-url-replacement.ts b/src/commands/web/api/create-url-replacement.ts index d1e40769..4c7a8466 100644 --- a/src/commands/web/api/create-url-replacement.ts +++ b/src/commands/web/api/create-url-replacement.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiCreateUrlReplacement extends Command { static description = "Create a new url replacement for the test plan"; diff --git a/src/commands/web/api/delete-access-point.ts b/src/commands/web/api/delete-access-point.ts index bb6b195c..76d9b6c5 100644 --- a/src/commands/web/api/delete-access-point.ts +++ b/src/commands/web/api/delete-access-point.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiDeleteAccessPoint extends Command { static description = "You can delete an access point by passing in its name."; diff --git a/src/commands/web/api/delete-url-replacement.ts b/src/commands/web/api/delete-url-replacement.ts index 0e99cfa9..3ff36a05 100644 --- a/src/commands/web/api/delete-url-replacement.ts +++ b/src/commands/web/api/delete-url-replacement.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiDeleteUrlReplacement extends Command { static description = "Delete a url replacement for the test plan"; diff --git a/src/commands/web/api/describe-result.ts b/src/commands/web/api/describe-result.ts index e20cc721..295587e6 100644 --- a/src/commands/web/api/describe-result.ts +++ b/src/commands/web/api/describe-result.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiDescribeResult extends Command { static description = "Get a test result."; diff --git a/src/commands/web/api/describe-scenario.ts b/src/commands/web/api/describe-scenario.ts index 31e57e67..ee9d31c3 100644 --- a/src/commands/web/api/describe-scenario.ts +++ b/src/commands/web/api/describe-scenario.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiDescribeScenario extends Command { static description = "Get a scenario."; diff --git a/src/commands/web/api/execute-scenarios.ts b/src/commands/web/api/execute-scenarios.ts index bdafe4ac..5e6fe7d1 100644 --- a/src/commands/web/api/execute-scenarios.ts +++ b/src/commands/web/api/execute-scenarios.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiExecuteScenarios extends Command { static description = diff --git a/src/commands/web/api/execute-schedule.ts b/src/commands/web/api/execute-schedule.ts index 7fbac1c4..cddde5c1 100644 --- a/src/commands/web/api/execute-schedule.ts +++ b/src/commands/web/api/execute-schedule.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiExecuteSchedule extends Command { static description = diff --git a/src/commands/web/api/list-access-points.ts b/src/commands/web/api/list-access-points.ts index bc911949..b6211dd5 100644 --- a/src/commands/web/api/list-access-points.ts +++ b/src/commands/web/api/list-access-points.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiListAccessPoints extends Command { static description = "List access points for the project."; diff --git a/src/commands/web/api/list-capabilities.ts b/src/commands/web/api/list-capabilities.ts index 6742425d..813a04da 100644 --- a/src/commands/web/api/list-capabilities.ts +++ b/src/commands/web/api/list-capabilities.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiListCapabilities extends Command { static description = "List available Capabilities."; diff --git a/src/commands/web/api/list-results.ts b/src/commands/web/api/list-results.ts index fa1a07eb..2eda0b57 100644 --- a/src/commands/web/api/list-results.ts +++ b/src/commands/web/api/list-results.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiListResults extends Command { static description = "List test results."; diff --git a/src/commands/web/api/list-scenarios.ts b/src/commands/web/api/list-scenarios.ts index 1c66e509..5619c16a 100644 --- a/src/commands/web/api/list-scenarios.ts +++ b/src/commands/web/api/list-scenarios.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiListScenarios extends Command { static description = "List scenarios."; diff --git a/src/commands/web/api/list-url-replacements.ts b/src/commands/web/api/list-url-replacements.ts index b3bb6e24..b0e29560 100644 --- a/src/commands/web/api/list-url-replacements.ts +++ b/src/commands/web/api/list-url-replacements.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiListUrlReplacements extends Command { static description = "List url replacements for the test plan"; diff --git a/src/commands/web/api/update-url-replacement.ts b/src/commands/web/api/update-url-replacement.ts index d8331f95..d16bb780 100644 --- a/src/commands/web/api/update-url-replacement.ts +++ b/src/commands/web/api/update-url-replacement.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebApiUpdateUrlReplacement extends Command { static description = "Update a url replacement for the test plan"; diff --git a/src/commands/web/auth/login.ts b/src/commands/web/auth/login.ts index 48d584ed..3458aae4 100644 --- a/src/commands/web/auth/login.ts +++ b/src/commands/web/auth/login.ts @@ -1,6 +1,6 @@ import { Command } from "@oclif/core"; import * as inquirer from "inquirer"; -import { set } from "../../../config"; +import { set } from "../../../config.js"; export default class WebAuthLogin extends Command { static description = "Login to Autify for Web"; diff --git a/src/commands/web/test/run.ts b/src/commands/web/test/run.ts index f9d27ebb..9afc57da 100644 --- a/src/commands/web/test/run.ts +++ b/src/commands/web/test/run.ts @@ -1,12 +1,12 @@ import { Command, Args, Flags } from "@oclif/core"; import emoji from "node-emoji"; -import { runTest } from "../../../autify/web/runTest"; -import { getWebTestResultUrl } from "../../../autify/web/getTestResultUrl"; -import WebTestWait from "./wait"; +import { runTest } from "../../../autify/web/runTest.js"; +import { getWebTestResultUrl } from "../../../autify/web/getTestResultUrl.js"; +import WebTestWait from "./wait.js"; import { CLIError } from "@oclif/errors"; -import { parseAutifyTestUrl } from "../../../autify/web/parseAutifyTestUrl"; -import { ClientManager } from "../../../autify/connect/client-manager/ClientManager"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { parseAutifyTestUrl } from "../../../autify/web/parseAutifyTestUrl.js"; +import { ClientManager } from "../../../autify/connect/client-manager/ClientManager.js"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; const urlReplacementsToString = ( urlReplacements: { pattern_url: string; replacement_url: string }[] diff --git a/src/commands/web/test/wait.ts b/src/commands/web/test/wait.ts index e925cfe7..82ae3264 100644 --- a/src/commands/web/test/wait.ts +++ b/src/commands/web/test/wait.ts @@ -1,10 +1,10 @@ import { Command, Args, Flags } from "@oclif/core"; import emoji from "node-emoji"; -import { parseTestResultUrl } from "../../../autify/web/parseTestResultUrl"; -import { waitTestResult } from "../../../autify/web/waitTestResult"; -import { getWebTestResultUrl } from "../../../autify/web/getTestResultUrl"; -import { getWaitIntervalSecond } from "../../../autify/getWaitIntervalSecond"; -import { getWebClient } from "../../../autify/web/getWebClient"; +import { parseTestResultUrl } from "../../../autify/web/parseTestResultUrl.js"; +import { waitTestResult } from "../../../autify/web/waitTestResult.js"; +import { getWebTestResultUrl } from "../../../autify/web/getTestResultUrl.js"; +import { getWaitIntervalSecond } from "../../../autify/getWaitIntervalSecond.js"; +import { getWebClient } from "../../../autify/web/getWebClient.js"; export default class WebTestWait extends Command { static description = "Wait a test result until it finishes."; From 742f3db19751cabd3a4110c5bd69d5e973546390 Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:27:31 +0900 Subject: [PATCH 2/9] Migrate to .js --- bin/dev | 31 ------------------------------- bin/dev.cmd | 2 +- bin/dev.js | 36 ++++++++++++++++++++++++++++++++++++ bin/{run => run.js} | 9 ++++----- package-lock.json | 2 +- package.json | 10 +++++----- 6 files changed, 47 insertions(+), 43 deletions(-) delete mode 100755 bin/dev create mode 100755 bin/dev.js rename bin/{run => run.js} (58%) diff --git a/bin/dev b/bin/dev deleted file mode 100755 index 5a3c54d7..00000000 --- a/bin/dev +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env node - -const oclif = require("@oclif/core"); - -const path = require("path"); -const project = path.join(__dirname, "..", "tsconfig.json"); - -// In dev mode -> use ts-node and dev plugins -// When `bin/dev` is invoked in integration-test it'll be "test" -process.env.NODE_ENV ||= "development"; - -require("ts-node").register({ project }); - -// In dev mode, always show stack traces -// In test mode, stack traces shouldn't appeared in snapshot -if (process.env.NODE_ENV === "development") { - oclif.settings.debug = true; -} - -// Start the CLI -oclif - .run() - .then(oclif.flush) - .catch((error) => { - const oclifHandler = oclif.Errors.handle; - if (error.response?.data) - error.message = `${error.message}: ${JSON.stringify( - error.response.data - )}`; - return oclifHandler(error); - }); diff --git a/bin/dev.cmd b/bin/dev.cmd index f0ba823e..a3ba5716 100644 --- a/bin/dev.cmd +++ b/bin/dev.cmd @@ -14,4 +14,4 @@ IF EXIST "%dp0%\node.exe" ( SET PATHEXT=%PATHEXT:;.JS;=;% ) -endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\dev" %* +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\dev.js" %* diff --git a/bin/dev.js b/bin/dev.js new file mode 100755 index 00000000..262e145d --- /dev/null +++ b/bin/dev.js @@ -0,0 +1,36 @@ +#!/usr/bin/env ts-node + +import { settings, Errors, flush, run } from "@oclif/core"; +import path from "node:path"; +import url from "node:url"; +import { register } from "ts-node"; + +const project = path.join( + path.dirname(url.fileURLToPath(import.meta.url)), + "..", + "tsconfig.json" +); + +// In dev mode -> use ts-node and dev plugins +// When `bin/dev.js` is invoked in integration-test it'll be "test" +process.env.NODE_ENV ||= "development"; + +register({ project }); + +// In dev mode, always show stack traces +// In test mode, stack traces shouldn't appeared in snapshot +if (process.env.NODE_ENV === "development") { + settings.debug = true; +} + +// Start the CLI +run(process.argv.slice(2), import.meta.url) + .then(flush) + .catch((error) => { + const oclifHandler = Errors.handle; + if (error.response?.data) + error.message = `${error.message}: ${JSON.stringify( + error.response.data + )}`; + return oclifHandler(error); + }); diff --git a/bin/run b/bin/run.js similarity index 58% rename from bin/run rename to bin/run.js index bd4f3ecb..17334b29 100755 --- a/bin/run +++ b/bin/run.js @@ -1,12 +1,11 @@ #!/usr/bin/env node -const oclif = require("@oclif/core"); +import { run, Errors, flush } from "@oclif/core"; -oclif - .run() - .then(require("@oclif/core/flush")) +run(process.argv.slice(2), import.meta.url) + .then(flush) .catch((error) => { - const oclifHandler = require("@oclif/core/handle"); + const oclifHandler = Errors.handle; if (error.response?.data) error.message = `${error.message}: ${JSON.stringify( error.response.data diff --git a/package-lock.json b/package-lock.json index 8c5ad36b..624194a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "xstate": "^4.35.4" }, "bin": { - "autify": "bin/run" + "autify": "bin/run.js" }, "devDependencies": { "@autifyhq/autify-cli-integration-test": "*", diff --git a/package.json b/package.json index 5b397173..79520479 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Autify Command Line Interface (CLI)", "author": "Autify", "bin": { - "autify": "./bin/run" + "autify": "./bin/run.js" }, "homepage": "https://github.com/autifyhq/autify-cli", "license": "MIT", @@ -152,13 +152,13 @@ "prepack": "npm run build && oclif manifest && oclif readme", "release": "ts-node ./scripts/release.ts", "test:integration": "npm run build -w integration-test && autify-cli-integration-test", - "test:integration:dev": "npm run build -w integration-test && cross-env AUTIFY_CLI_PATH=../bin/dev autify-cli-integration-test", + "test:integration:dev": "npm run build -w integration-test && cross-env AUTIFY_CLI_PATH=../bin/dev.js autify-cli-integration-test", "test:integration:record": "npm run build -w integration-test && cross-env AUTIFY_CLI_INTEGRATION_TEST_RECORD=1 AUTIFY_CONNECT_CLIENT_MODE=real autify-cli-integration-test", - "test:integration:dev:record": "npm run build -w integration-test && cross-env AUTIFY_CLI_PATH=../bin/dev AUTIFY_CLI_INTEGRATION_TEST_RECORD=1 AUTIFY_CONNECT_CLIENT_MODE=real autify-cli-integration-test", + "test:integration:dev:record": "npm run build -w integration-test && cross-env AUTIFY_CLI_PATH=../bin/dev.js AUTIFY_CLI_INTEGRATION_TEST_RECORD=1 AUTIFY_CONNECT_CLIENT_MODE=real autify-cli-integration-test", "test:integration:connect": "AUTIFY_CONNECT_CLIENT_MODE=fake autify connect client install && npm run test:integration AutifyConnectClient", - "test:integration:connect:dev": "AUTIFY_CONNECT_CLIENT_MODE=fake ./bin/dev connect client install && npm run test:integration:dev AutifyConnectClient", + "test:integration:connect:dev": "AUTIFY_CONNECT_CLIENT_MODE=fake ./bin/dev.js connect client install && npm run test:integration:dev AutifyConnectClient", "test:integration:connect:record": "autify connect client install && npm run test:integration:record AutifyConnectClient", - "test:integration:connect:dev:record": "./bin/dev connect client install && npm run test:integration:dev:record AutifyConnectClient", + "test:integration:connect:dev:record": "./bin/dev.js connect client install && npm run test:integration:dev:record AutifyConnectClient", "version": "oclif readme && git add README.md", "prepare": "per-env || true", "prepare:development": "husky install", From c4fa98d18ee4df05b7204ca978f8068bea140b8f Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:28:02 +0900 Subject: [PATCH 3/9] Import assertion is required --- scripts/release.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.ts b/scripts/release.ts index a428bb4a..79695c71 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -8,7 +8,7 @@ import { } from "node:fs"; import { homedir, tmpdir } from "node:os"; import { join } from "node:path"; -import pkg from "../package.json"; +import pkg from "../package.json" assert { type: "json" }; const { version, oclif: oclifConfig } = pkg; From 2e6bd7cd008558efc9ebb95513b4607fd757475a Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:28:33 +0900 Subject: [PATCH 4/9] Migrate to module type project --- integration-test/package.json | 1 + integration-test/tsconfig.json | 8 ++++++-- package.json | 1 + tsconfig.json | 8 ++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/integration-test/package.json b/integration-test/package.json index 1610f70a..87aea3b0 100644 --- a/integration-test/package.json +++ b/integration-test/package.json @@ -8,6 +8,7 @@ "autify-mobile-generate-fake-app": "bin/autify-mobile-generate-fake-app.js", "autify-with-proxy": "bin/autify-with-proxy.js" }, + "type": "module", "homepage": "https://github.com/autifyhq/autify-cli", "license": "MIT", "repository": { diff --git a/integration-test/tsconfig.json b/integration-test/tsconfig.json index 1ba06daa..5ffce563 100644 --- a/integration-test/tsconfig.json +++ b/integration-test/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "declaration": true, "importHelpers": true, - "module": "commonjs", + "module": "ESNext", + "moduleResolution": "node", "outDir": "dist", "rootDir": "src", "strict": true, @@ -10,5 +11,8 @@ "esModuleInterop": true, "types": ["express", "jest", "node", "which"] }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "ts-node": { + "esm": true + } } diff --git a/package.json b/package.json index 79520479..6f8a2182 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "bin": { "autify": "./bin/run.js" }, + "type": "module", "homepage": "https://github.com/autifyhq/autify-cli", "license": "MIT", "main": "dist/index.js", diff --git a/tsconfig.json b/tsconfig.json index 504cf315..5ba435f9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "declaration": true, "importHelpers": true, - "module": "commonjs", + "module": "ESNext", + "moduleResolution": "node", "outDir": "dist", "rootDir": "src", "strict": true, @@ -12,5 +13,8 @@ "lib": ["es2021"], "types": ["chai", "inquirer", "listr", "node", "node-emoji"] }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "ts-node": { + "esm": true + } } From 3afb5e8f89d1a47ec9b90baee6c6661c3e2237dc Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:28:52 +0900 Subject: [PATCH 5/9] Disable node/no-missing-import since .js doesn't exist --- .eslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 4b739f23..0003fb35 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,6 +2,7 @@ "extends": ["oclif", "oclif-typescript", "prettier"], "rules": { "no-useless-constructor": "off", - "@typescript-eslint/no-useless-constructor": "error" + "@typescript-eslint/no-useless-constructor": "error", + "node/no-missing-import": ["off"] } } From 1d14aba638c72879fb37291faa934bf64f81d4ba Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:34:54 +0900 Subject: [PATCH 6/9] Fix `inquirer.prompt is not a function` --- src/commands/connect/access-point/set.ts | 2 +- src/commands/mobile/auth/login.ts | 2 +- src/commands/web/auth/login.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/connect/access-point/set.ts b/src/commands/connect/access-point/set.ts index 6b8805ff..64574150 100644 --- a/src/commands/connect/access-point/set.ts +++ b/src/commands/connect/access-point/set.ts @@ -1,5 +1,5 @@ import { Command, Flags } from "@oclif/core"; -import * as inquirer from "inquirer"; +import inquirer from "inquirer"; import { confirmOverwriteAccessPoint, saveAccessPoint, diff --git a/src/commands/mobile/auth/login.ts b/src/commands/mobile/auth/login.ts index a91e8799..f6218a68 100644 --- a/src/commands/mobile/auth/login.ts +++ b/src/commands/mobile/auth/login.ts @@ -1,5 +1,5 @@ import { Command } from "@oclif/core"; -import * as inquirer from "inquirer"; +import inquirer from "inquirer"; import { set } from "../../../config.js"; export default class MobileAuthLogin extends Command { diff --git a/src/commands/web/auth/login.ts b/src/commands/web/auth/login.ts index 3458aae4..6f3b402a 100644 --- a/src/commands/web/auth/login.ts +++ b/src/commands/web/auth/login.ts @@ -1,5 +1,5 @@ import { Command } from "@oclif/core"; -import * as inquirer from "inquirer"; +import inquirer from "inquirer"; import { set } from "../../../config.js"; export default class WebAuthLogin extends Command { From 6fb864124d6e8b4cdef66e54129588d56adbda37 Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 17:42:22 +0900 Subject: [PATCH 7/9] require -> import --- integration-test/bin/autify-cli-integration-test.js | 2 +- integration-test/bin/autify-mobile-generate-fake-app.js | 2 +- integration-test/bin/autify-with-proxy.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-test/bin/autify-cli-integration-test.js b/integration-test/bin/autify-cli-integration-test.js index 7fa63e7f..c033109a 100755 --- a/integration-test/bin/autify-cli-integration-test.js +++ b/integration-test/bin/autify-cli-integration-test.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -require("../dist/bin/autify-cli-integration-test.js"); +import "../dist/bin/autify-cli-integration-test.js"; diff --git a/integration-test/bin/autify-mobile-generate-fake-app.js b/integration-test/bin/autify-mobile-generate-fake-app.js index 8b35ded2..8af4b332 100755 --- a/integration-test/bin/autify-mobile-generate-fake-app.js +++ b/integration-test/bin/autify-mobile-generate-fake-app.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -require("../dist/bin/autify-mobile-generate-fake-app.js"); +import "../dist/bin/autify-mobile-generate-fake-app.js"; diff --git a/integration-test/bin/autify-with-proxy.js b/integration-test/bin/autify-with-proxy.js index 182fd34d..4ae67413 100755 --- a/integration-test/bin/autify-with-proxy.js +++ b/integration-test/bin/autify-with-proxy.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -require("../dist/bin/autify-with-proxy.js"); +import "../dist/bin/autify-with-proxy.js"; From f5b700f5a1e448f281c61210251d2ba68beaf8de Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Wed, 12 Apr 2023 18:01:39 +0900 Subject: [PATCH 8/9] Fix __dirname --- integration-test/src/bin/autify-cli-integration-test.ts | 4 ++-- integration-test/src/bin/autify-with-proxy.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-test/src/bin/autify-cli-integration-test.ts b/integration-test/src/bin/autify-cli-integration-test.ts index 351bab37..e353e73e 100644 --- a/integration-test/src/bin/autify-cli-integration-test.ts +++ b/integration-test/src/bin/autify-cli-integration-test.ts @@ -1,9 +1,9 @@ import { execSync } from "node:child_process"; import path from "node:path"; import { argv, env } from "node:process"; +import { fileURLToPath } from "node:url"; -// eslint-disable-next-line unicorn/prefer-module -const scriptDir = __dirname; +const scriptDir = fileURLToPath(new URL(".", import.meta.url)); const rootDir = path.join(scriptDir, "..", ".."); const isRecord = Boolean(env.AUTIFY_CLI_INTEGRATION_TEST_RECORD); const command = isRecord ? "test:record" : "test"; diff --git a/integration-test/src/bin/autify-with-proxy.ts b/integration-test/src/bin/autify-with-proxy.ts index 61e949e4..39b96a36 100644 --- a/integration-test/src/bin/autify-with-proxy.ts +++ b/integration-test/src/bin/autify-with-proxy.ts @@ -11,6 +11,7 @@ import { argv, env, exit } from "node:process"; import { existsSync } from "node:fs"; import which from "which"; import { normalizeCommand } from "../commands.js"; +import { fileURLToPath } from "node:url"; Polly.register(NodeHttpAdapter); Polly.register(FSPersister); @@ -71,8 +72,7 @@ const filterRecording = ({ request, response }: HarEntry) => { const createPolly = async (args: string[]) => { const mode = getPollyMode(); - // eslint-disable-next-line unicorn/prefer-module - const scriptDir = __dirname; + const scriptDir = fileURLToPath(new URL(".", import.meta.url)); const recordingsDir = path.join( scriptDir, "..", From 4e8cbed3d7fc2aa0fa77b4346857bc0f46c0536e Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Thu, 13 Apr 2023 13:38:26 +0900 Subject: [PATCH 9/9] wip --- .github/workflows/integration-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index c15b2719..e37eb960 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -7,6 +7,9 @@ permissions: id-token: write contents: read +env: + NODE_OPTIONS: --experimental-vm-modules + jobs: tarball: strategy: