@hubspot/cli 7.7.19-experimental.3 → 7.7.21-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/__tests__/migrate.test.d.ts +1 -0
- package/api/__tests__/migrate.test.js +181 -0
- package/api/migrate.js +14 -22
- package/bin/cli.js +92 -97
- package/bin/hs +2 -2
- package/bin/hscms +2 -2
- package/bin/silenceErrors.js +1 -2
- package/commands/__tests__/account.test.d.ts +1 -0
- package/commands/__tests__/account.test.js +69 -0
- package/commands/__tests__/auth.test.d.ts +1 -0
- package/commands/__tests__/auth.test.js +38 -0
- package/commands/__tests__/cms.test.d.ts +1 -0
- package/commands/__tests__/cms.test.js +44 -0
- package/commands/__tests__/config.test.d.ts +1 -0
- package/commands/__tests__/config.test.js +44 -0
- package/commands/__tests__/create.test.d.ts +1 -0
- package/commands/__tests__/create.test.js +33 -0
- package/commands/__tests__/customObject.test.d.ts +1 -0
- package/commands/__tests__/customObject.test.js +49 -0
- package/commands/__tests__/doctor.test.d.ts +1 -0
- package/commands/__tests__/doctor.test.js +134 -0
- package/commands/__tests__/feedback.test.d.ts +1 -0
- package/commands/__tests__/feedback.test.js +24 -0
- package/commands/__tests__/fetch.test.d.ts +1 -0
- package/commands/__tests__/fetch.test.js +57 -0
- package/commands/__tests__/filemanager.test.d.ts +1 -0
- package/commands/__tests__/filemanager.test.js +45 -0
- package/commands/__tests__/function.test.d.ts +1 -0
- package/commands/__tests__/function.test.js +46 -0
- package/commands/__tests__/getStarted.test.d.ts +1 -0
- package/commands/__tests__/getStarted.test.js +165 -0
- package/commands/__tests__/hubdb.test.d.ts +1 -0
- package/commands/__tests__/hubdb.test.js +50 -0
- package/commands/__tests__/init.test.d.ts +1 -0
- package/commands/__tests__/init.test.js +42 -0
- package/commands/__tests__/lint.test.d.ts +1 -0
- package/commands/__tests__/lint.test.js +33 -0
- package/commands/__tests__/list.test.d.ts +1 -0
- package/commands/__tests__/list.test.js +42 -0
- package/commands/__tests__/logs.test.d.ts +1 -0
- package/commands/__tests__/logs.test.js +71 -0
- package/commands/__tests__/mcp.test.d.ts +1 -0
- package/commands/__tests__/mcp.test.js +46 -0
- package/commands/__tests__/mv.test.d.ts +1 -0
- package/commands/__tests__/mv.test.js +46 -0
- package/commands/__tests__/open.test.d.ts +1 -0
- package/commands/__tests__/open.test.js +58 -0
- package/commands/__tests__/project.test.d.ts +1 -0
- package/commands/__tests__/project.test.js +95 -0
- package/commands/__tests__/remove.test.d.ts +1 -0
- package/commands/__tests__/remove.test.js +39 -0
- package/commands/__tests__/sandbox.test.d.ts +1 -0
- package/commands/__tests__/sandbox.test.js +44 -0
- package/commands/__tests__/secret.test.d.ts +1 -0
- package/commands/__tests__/secret.test.js +49 -0
- package/commands/__tests__/testAccount.test.d.ts +1 -0
- package/commands/__tests__/testAccount.test.js +55 -0
- package/commands/__tests__/theme.test.d.ts +1 -0
- package/commands/__tests__/theme.test.js +47 -0
- package/commands/account/__tests__/auth.test.d.ts +1 -0
- package/commands/account/__tests__/auth.test.js +26 -0
- package/commands/account/__tests__/clean.test.d.ts +1 -0
- package/commands/account/__tests__/clean.test.js +28 -0
- package/commands/account/__tests__/createOverride.test.d.ts +1 -0
- package/commands/account/__tests__/createOverride.test.js +32 -0
- package/commands/account/__tests__/info.test.d.ts +1 -0
- package/commands/account/__tests__/info.test.js +28 -0
- package/commands/account/__tests__/list.test.d.ts +1 -0
- package/commands/account/__tests__/list.test.js +28 -0
- package/commands/account/__tests__/remove.test.d.ts +1 -0
- package/commands/account/__tests__/remove.test.js +36 -0
- package/commands/account/__tests__/removeOverride.d.ts +1 -0
- package/commands/account/__tests__/removeOverride.js +25 -0
- package/commands/account/__tests__/rename.test.d.ts +1 -0
- package/commands/account/__tests__/rename.test.js +42 -0
- package/commands/account/__tests__/use.test.d.ts +1 -0
- package/commands/account/__tests__/use.test.js +32 -0
- package/commands/account/auth.d.ts +1 -1
- package/commands/account/auth.js +65 -67
- package/commands/account/clean.d.ts +1 -1
- package/commands/account/clean.js +55 -60
- package/commands/account/createOverride.d.ts +1 -1
- package/commands/account/createOverride.js +52 -57
- package/commands/account/info.d.ts +1 -1
- package/commands/account/info.js +33 -35
- package/commands/account/list.d.ts +1 -1
- package/commands/account/list.js +43 -45
- package/commands/account/remove.d.ts +1 -1
- package/commands/account/remove.js +37 -42
- package/commands/account/removeOverride.d.ts +1 -1
- package/commands/account/removeOverride.js +38 -43
- package/commands/account/rename.d.ts +1 -1
- package/commands/account/rename.js +18 -20
- package/commands/account/use.d.ts +1 -1
- package/commands/account/use.js +29 -31
- package/commands/account.d.ts +1 -1
- package/commands/account.js +23 -28
- package/commands/app/__tests__/migrate.test.d.ts +1 -0
- package/commands/app/__tests__/migrate.test.js +124 -0
- package/commands/app/migrate.d.ts +2 -2
- package/commands/app/migrate.js +40 -43
- package/commands/app/secret/__tests__/add.test.d.ts +1 -0
- package/commands/app/secret/__tests__/add.test.js +28 -0
- package/commands/app/secret/__tests__/delete.test.d.ts +1 -0
- package/commands/app/secret/__tests__/delete.test.js +28 -0
- package/commands/app/secret/__tests__/list.test.d.ts +1 -0
- package/commands/app/secret/__tests__/list.test.js +25 -0
- package/commands/app/secret/__tests__/update.test.d.ts +1 -0
- package/commands/app/secret/__tests__/update.test.js +28 -0
- package/commands/app/secret/add.d.ts +1 -1
- package/commands/app/secret/add.js +28 -30
- package/commands/app/secret/delete.d.ts +1 -1
- package/commands/app/secret/delete.js +34 -36
- package/commands/app/secret/list.d.ts +1 -1
- package/commands/app/secret/list.js +25 -27
- package/commands/app/secret/update.d.ts +1 -1
- package/commands/app/secret/update.js +32 -34
- package/commands/app/secret.d.ts +1 -1
- package/commands/app/secret.js +12 -17
- package/commands/app.d.ts +1 -1
- package/commands/app.js +6 -16
- package/commands/auth.d.ts +1 -1
- package/commands/auth.js +70 -72
- package/commands/cms/convertFields.d.ts +1 -1
- package/commands/cms/convertFields.js +34 -39
- package/commands/cms/getReactModule.d.ts +1 -1
- package/commands/cms/getReactModule.js +32 -37
- package/commands/cms/lighthouseScore.d.ts +1 -1
- package/commands/cms/lighthouseScore.js +67 -72
- package/commands/cms.d.ts +1 -1
- package/commands/cms.js +11 -16
- package/commands/completion.d.ts +1 -1
- package/commands/completion.js +10 -15
- package/commands/config/migrate.d.ts +1 -1
- package/commands/config/migrate.js +27 -32
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +23 -25
- package/commands/config.d.ts +1 -1
- package/commands/config.js +8 -13
- package/commands/create/api-sample.d.ts +1 -1
- package/commands/create/api-sample.js +28 -33
- package/commands/create/app.d.ts +1 -1
- package/commands/create/app.js +3 -5
- package/commands/create/function.d.ts +1 -1
- package/commands/create/function.js +9 -11
- package/commands/create/index.d.ts +1 -1
- package/commands/create/index.js +19 -24
- package/commands/create/module.d.ts +1 -1
- package/commands/create/module.js +12 -14
- package/commands/create/react-app.d.ts +1 -1
- package/commands/create/react-app.js +3 -5
- package/commands/create/template.d.ts +1 -1
- package/commands/create/template.js +12 -14
- package/commands/create/vue-app.d.ts +1 -1
- package/commands/create/vue-app.js +3 -5
- package/commands/create/webpack-serverless.d.ts +1 -1
- package/commands/create/webpack-serverless.js +3 -5
- package/commands/create/website-theme.d.ts +1 -1
- package/commands/create/website-theme.js +5 -7
- package/commands/create.d.ts +2 -2
- package/commands/create.js +30 -35
- package/commands/customObject/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/__tests__/create.test.js +40 -0
- package/commands/customObject/__tests__/schema.test.d.ts +1 -0
- package/commands/customObject/__tests__/schema.test.js +53 -0
- package/commands/customObject/create.d.ts +1 -1
- package/commands/customObject/create.js +28 -30
- package/commands/customObject/schema/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/create.test.js +28 -0
- package/commands/customObject/schema/__tests__/delete.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/delete.test.js +42 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.js +41 -0
- package/commands/customObject/schema/__tests__/fetch.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch.test.js +45 -0
- package/commands/customObject/schema/__tests__/list.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/list.test.js +29 -0
- package/commands/customObject/schema/__tests__/update.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/update.test.js +40 -0
- package/commands/customObject/schema/create.d.ts +1 -1
- package/commands/customObject/schema/create.js +28 -30
- package/commands/customObject/schema/delete.d.ts +1 -1
- package/commands/customObject/schema/delete.js +24 -26
- package/commands/customObject/schema/fetch-all.d.ts +1 -1
- package/commands/customObject/schema/fetch-all.js +22 -24
- package/commands/customObject/schema/fetch.d.ts +1 -1
- package/commands/customObject/schema/fetch.js +24 -26
- package/commands/customObject/schema/list.d.ts +1 -1
- package/commands/customObject/schema/list.js +13 -15
- package/commands/customObject/schema/update.d.ts +1 -1
- package/commands/customObject/schema/update.js +32 -34
- package/commands/customObject/schema.d.ts +1 -1
- package/commands/customObject/schema.js +17 -22
- package/commands/customObject.d.ts +1 -1
- package/commands/customObject.js +13 -18
- package/commands/doctor.d.ts +1 -1
- package/commands/doctor.js +28 -33
- package/commands/feedback.d.ts +1 -1
- package/commands/feedback.js +19 -24
- package/commands/fetch.d.ts +1 -1
- package/commands/fetch.js +28 -31
- package/commands/filemanager/__tests__/fetch.test.d.ts +1 -0
- package/commands/filemanager/__tests__/fetch.test.js +32 -0
- package/commands/filemanager/__tests__/upload.test.d.ts +1 -0
- package/commands/filemanager/__tests__/upload.test.js +30 -0
- package/commands/filemanager/fetch.d.ts +1 -1
- package/commands/filemanager/fetch.js +23 -25
- package/commands/filemanager/upload.d.ts +1 -1
- package/commands/filemanager/upload.js +39 -44
- package/commands/filemanager.d.ts +1 -1
- package/commands/filemanager.js +8 -13
- package/commands/function/deploy.d.ts +1 -1
- package/commands/function/deploy.js +35 -40
- package/commands/function/list.d.ts +1 -1
- package/commands/function/list.js +24 -29
- package/commands/function/server.d.ts +1 -1
- package/commands/function/server.js +15 -17
- package/commands/function.d.ts +1 -1
- package/commands/function.js +12 -18
- package/commands/getStarted.d.ts +1 -1
- package/commands/getStarted.js +124 -130
- package/commands/hubdb/__tests__/clear.test.d.ts +1 -0
- package/commands/hubdb/__tests__/clear.test.js +28 -0
- package/commands/hubdb/__tests__/create.test.d.ts +1 -0
- package/commands/hubdb/__tests__/create.test.js +28 -0
- package/commands/hubdb/__tests__/delete.test.d.ts +1 -0
- package/commands/hubdb/__tests__/delete.test.js +28 -0
- package/commands/hubdb/__tests__/fetch.test.d.ts +1 -0
- package/commands/hubdb/__tests__/fetch.test.js +28 -0
- package/commands/hubdb/__tests__/list.test.d.ts +1 -0
- package/commands/hubdb/__tests__/list.test.js +96 -0
- package/commands/hubdb/clear.d.ts +1 -1
- package/commands/hubdb/clear.js +20 -22
- package/commands/hubdb/create.d.ts +1 -1
- package/commands/hubdb/create.js +30 -35
- package/commands/hubdb/delete.d.ts +1 -1
- package/commands/hubdb/delete.js +24 -26
- package/commands/hubdb/fetch.d.ts +1 -1
- package/commands/hubdb/fetch.js +17 -19
- package/commands/hubdb/list.d.ts +1 -1
- package/commands/hubdb/list.js +33 -35
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +18 -24
- package/commands/init.d.ts +1 -1
- package/commands/init.js +83 -88
- package/commands/lint.d.ts +1 -1
- package/commands/lint.js +24 -26
- package/commands/list.d.ts +1 -1
- package/commands/list.js +32 -37
- package/commands/logs.d.ts +1 -1
- package/commands/logs.js +35 -38
- package/commands/mcp/__tests__/setup.test.d.ts +1 -0
- package/commands/mcp/__tests__/setup.test.js +26 -0
- package/commands/mcp/__tests__/start.test.d.ts +1 -0
- package/commands/mcp/__tests__/start.test.js +27 -0
- package/commands/mcp/setup.d.ts +1 -1
- package/commands/mcp/setup.js +17 -19
- package/commands/mcp/start.d.ts +1 -1
- package/commands/mcp/start.js +29 -34
- package/commands/mcp.d.ts +1 -1
- package/commands/mcp.js +7 -12
- package/commands/module/marketplace-validate.d.ts +1 -1
- package/commands/module/marketplace-validate.js +21 -26
- package/commands/module.d.ts +1 -1
- package/commands/module.js +7 -13
- package/commands/mv.d.ts +1 -1
- package/commands/mv.js +20 -22
- package/commands/open.d.ts +1 -1
- package/commands/open.js +19 -21
- package/commands/project/__tests__/add.test.d.ts +1 -0
- package/commands/project/__tests__/add.test.js +43 -0
- package/commands/project/__tests__/create.test.d.ts +1 -0
- package/commands/project/__tests__/create.test.js +40 -0
- package/commands/project/__tests__/deploy.test.d.ts +1 -0
- package/commands/project/__tests__/deploy.test.js +306 -0
- package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
- package/commands/project/__tests__/devUnifiedFlow.test.js +414 -0
- package/commands/project/__tests__/download.test.d.ts +1 -0
- package/commands/project/__tests__/download.test.js +39 -0
- package/commands/project/__tests__/fixtures/exampleProject.json +33 -0
- package/commands/project/__tests__/installDeps.test.d.ts +1 -0
- package/commands/project/__tests__/installDeps.test.js +142 -0
- package/commands/project/__tests__/listBuilds.test.d.ts +1 -0
- package/commands/project/__tests__/listBuilds.test.js +38 -0
- package/commands/project/__tests__/logs.test.d.ts +1 -0
- package/commands/project/__tests__/logs.test.js +208 -0
- package/commands/project/__tests__/migrate.test.d.ts +1 -0
- package/commands/project/__tests__/migrate.test.js +111 -0
- package/commands/project/__tests__/migrateApp.test.d.ts +1 -0
- package/commands/project/__tests__/migrateApp.test.js +82 -0
- package/commands/project/__tests__/open.test.d.ts +1 -0
- package/commands/project/__tests__/open.test.js +39 -0
- package/commands/project/__tests__/profile.test.d.ts +1 -0
- package/commands/project/__tests__/profile.test.js +42 -0
- package/commands/project/__tests__/upload.test.d.ts +1 -0
- package/commands/project/__tests__/upload.test.js +43 -0
- package/commands/project/__tests__/watch.test.d.ts +1 -0
- package/commands/project/__tests__/watch.test.js +35 -0
- package/commands/project/add.d.ts +1 -1
- package/commands/project/add.js +34 -36
- package/commands/project/cloneApp.d.ts +1 -1
- package/commands/project/cloneApp.js +67 -72
- package/commands/project/create.d.ts +2 -2
- package/commands/project/create.js +62 -67
- package/commands/project/deploy.d.ts +1 -1
- package/commands/project/deploy.js +72 -77
- package/commands/project/dev/deprecatedFlow.d.ts +2 -2
- package/commands/project/dev/deprecatedFlow.js +52 -58
- package/commands/project/dev/index.d.ts +1 -1
- package/commands/project/dev/index.js +44 -47
- package/commands/project/dev/unifiedFlow.d.ts +3 -3
- package/commands/project/dev/unifiedFlow.js +62 -68
- package/commands/project/download.d.ts +1 -1
- package/commands/project/download.js +35 -40
- package/commands/project/installDeps.d.ts +1 -1
- package/commands/project/installDeps.js +29 -34
- package/commands/project/listBuilds.d.ts +1 -1
- package/commands/project/listBuilds.js +40 -45
- package/commands/project/logs.d.ts +1 -1
- package/commands/project/logs.js +52 -54
- package/commands/project/migrate.d.ts +1 -1
- package/commands/project/migrate.js +24 -26
- package/commands/project/migrateApp.d.ts +2 -2
- package/commands/project/migrateApp.js +18 -20
- package/commands/project/open.d.ts +1 -1
- package/commands/project/open.js +25 -30
- package/commands/project/profile/add.d.ts +1 -1
- package/commands/project/profile/add.js +68 -73
- package/commands/project/profile/delete.d.ts +1 -1
- package/commands/project/profile/delete.js +51 -56
- package/commands/project/profile.d.ts +1 -1
- package/commands/project/profile.js +9 -14
- package/commands/project/upload.d.ts +1 -1
- package/commands/project/upload.js +50 -55
- package/commands/project/validate.d.ts +1 -1
- package/commands/project/validate.js +35 -40
- package/commands/project/watch.d.ts +1 -1
- package/commands/project/watch.js +59 -61
- package/commands/project.d.ts +1 -1
- package/commands/project.js +38 -43
- package/commands/remove.d.ts +1 -1
- package/commands/remove.js +15 -17
- package/commands/sandbox/__tests__/create.test.d.ts +1 -0
- package/commands/sandbox/__tests__/create.test.js +31 -0
- package/commands/sandbox/__tests__/delete.test.d.ts +1 -0
- package/commands/sandbox/__tests__/delete.test.js +31 -0
- package/commands/sandbox/create.d.ts +1 -1
- package/commands/sandbox/create.js +67 -69
- package/commands/sandbox/delete.d.ts +1 -1
- package/commands/sandbox/delete.js +94 -96
- package/commands/sandbox.d.ts +1 -1
- package/commands/sandbox.js +9 -14
- package/commands/secret/__tests__/addSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/addSecret.test.js +29 -0
- package/commands/secret/__tests__/deleteSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/deleteSecret.test.js +41 -0
- package/commands/secret/__tests__/listSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/listSecret.test.js +29 -0
- package/commands/secret/__tests__/updateSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/updateSecret.test.js +29 -0
- package/commands/secret/addSecret.d.ts +1 -1
- package/commands/secret/addSecret.js +26 -28
- package/commands/secret/deleteSecret.d.ts +1 -1
- package/commands/secret/deleteSecret.js +27 -29
- package/commands/secret/listSecret.d.ts +1 -1
- package/commands/secret/listSecret.js +19 -21
- package/commands/secret/updateSecret.d.ts +1 -1
- package/commands/secret/updateSecret.js +25 -27
- package/commands/secret.d.ts +1 -1
- package/commands/secret.js +13 -18
- package/commands/testAccount/__tests__/create.test.d.ts +1 -0
- package/commands/testAccount/__tests__/create.test.js +33 -0
- package/commands/testAccount/__tests__/createConfig.test.d.ts +1 -0
- package/commands/testAccount/__tests__/createConfig.test.js +35 -0
- package/commands/testAccount/__tests__/delete.test.d.ts +1 -0
- package/commands/testAccount/__tests__/delete.test.js +31 -0
- package/commands/testAccount/create.d.ts +1 -1
- package/commands/testAccount/create.js +62 -57
- package/commands/testAccount/createConfig.d.ts +2 -2
- package/commands/testAccount/createConfig.js +36 -41
- package/commands/testAccount/delete.d.ts +1 -1
- package/commands/testAccount/delete.js +17 -19
- package/commands/testAccount.d.ts +1 -1
- package/commands/testAccount.js +10 -15
- package/commands/theme/__tests__/generate-selectors.test.d.ts +1 -0
- package/commands/theme/__tests__/generate-selectors.test.js +28 -0
- package/commands/theme/__tests__/marketplace-validate.test.d.ts +1 -0
- package/commands/theme/__tests__/marketplace-validate.test.js +36 -0
- package/commands/theme/__tests__/preview.test.d.ts +1 -0
- package/commands/theme/__tests__/preview.test.js +60 -0
- package/commands/theme/generate-selectors.d.ts +1 -1
- package/commands/theme/generate-selectors.js +23 -28
- package/commands/theme/marketplace-validate.d.ts +1 -1
- package/commands/theme/marketplace-validate.js +19 -24
- package/commands/theme/preview.d.ts +1 -1
- package/commands/theme/preview.js +60 -65
- package/commands/theme.d.ts +1 -1
- package/commands/theme.js +11 -16
- package/commands/upload.d.ts +1 -1
- package/commands/upload.js +77 -82
- package/commands/watch.d.ts +1 -1
- package/commands/watch.js +45 -51
- package/lang/en.d.ts +5 -65
- package/lang/en.js +374 -440
- package/lib/__tests__/accountTypes.test.d.ts +1 -0
- package/lib/__tests__/accountTypes.test.js +98 -0
- package/lib/__tests__/buildAccount.test.d.ts +1 -0
- package/lib/__tests__/buildAccount.test.js +196 -0
- package/lib/__tests__/commonOpts.test.d.ts +1 -0
- package/lib/__tests__/commonOpts.test.js +85 -0
- package/lib/__tests__/dependencyManagement.test.d.ts +1 -0
- package/lib/__tests__/dependencyManagement.test.js +175 -0
- package/lib/__tests__/developerTestAccounts.test.d.ts +1 -0
- package/lib/__tests__/developerTestAccounts.test.js +145 -0
- package/lib/__tests__/hasFeature.test.d.ts +1 -0
- package/lib/__tests__/hasFeature.test.js +35 -0
- package/lib/__tests__/npm.test.d.ts +1 -0
- package/lib/__tests__/npm.test.js +57 -0
- package/lib/__tests__/oauth.test.d.ts +1 -0
- package/lib/__tests__/oauth.test.js +108 -0
- package/lib/__tests__/parsing.test.d.ts +1 -0
- package/lib/__tests__/parsing.test.js +34 -0
- package/lib/__tests__/polling.test.d.ts +1 -0
- package/lib/__tests__/polling.test.js +76 -0
- package/lib/__tests__/process.test.d.ts +1 -0
- package/lib/__tests__/process.test.js +85 -0
- package/lib/__tests__/projectProfiles.test.d.ts +1 -0
- package/lib/__tests__/projectProfiles.test.js +129 -0
- package/lib/__tests__/sandboxSync.test.d.ts +1 -0
- package/lib/__tests__/sandboxSync.test.js +126 -0
- package/lib/__tests__/sandboxes.test.d.ts +1 -0
- package/lib/__tests__/sandboxes.test.js +146 -0
- package/lib/__tests__/serverlessLogs.test.d.ts +1 -0
- package/lib/__tests__/serverlessLogs.test.js +149 -0
- package/lib/__tests__/usageTracking.test.d.ts +1 -0
- package/lib/__tests__/usageTracking.test.js +170 -0
- package/lib/__tests__/validation.test.d.ts +1 -0
- package/lib/__tests__/validation.test.js +143 -0
- package/lib/__tests__/yargsUtils.test.d.ts +1 -0
- package/lib/__tests__/yargsUtils.test.js +39 -0
- package/lib/accountTypes.js +24 -34
- package/lib/app/__tests__/migrate.test.d.ts +1 -0
- package/lib/app/__tests__/migrate.test.js +490 -0
- package/lib/app/__tests__/migrate_legacy.test.d.ts +1 -0
- package/lib/app/__tests__/migrate_legacy.test.js +134 -0
- package/lib/app/migrate.d.ts +3 -3
- package/lib/app/migrate.js +127 -145
- package/lib/app/migrate_legacy.d.ts +1 -1
- package/lib/app/migrate_legacy.js +72 -78
- package/lib/app/urls.js +5 -9
- package/lib/buildAccount.d.ts +2 -8
- package/lib/buildAccount.js +61 -119
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +42 -59
- package/lib/configMigrate.js +34 -38
- package/lib/configOptions.js +34 -40
- package/lib/constants.js +31 -34
- package/lib/customObject.js +2 -6
- package/lib/dependencyManagement.js +37 -45
- package/lib/developerTestAccounts.d.ts +1 -1
- package/lib/developerTestAccounts.js +34 -39
- package/lib/doctor/Diagnosis.d.ts +1 -1
- package/lib/doctor/Diagnosis.js +15 -19
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +30 -37
- package/lib/doctor/Doctor.d.ts +1 -1
- package/lib/doctor/Doctor.js +56 -63
- package/lib/doctor/__tests__/Diagnosis.test.d.ts +1 -0
- package/lib/doctor/__tests__/Diagnosis.test.js +82 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +1 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +167 -0
- package/lib/doctor/__tests__/Doctor.test.d.ts +1 -0
- package/lib/doctor/__tests__/Doctor.test.js +396 -0
- package/lib/enums/exitCodes.js +1 -4
- package/lib/errorHandlers/index.js +32 -41
- package/lib/errorHandlers/suppressError.d.ts +1 -1
- package/lib/errorHandlers/suppressError.js +28 -31
- package/lib/filesystem.js +8 -15
- package/lib/generateSelectors.js +18 -29
- package/lib/hasFeature.d.ts +1 -1
- package/lib/hasFeature.js +3 -6
- package/lib/interpolation.js +11 -18
- package/lib/lang.d.ts +1 -1
- package/lib/lang.js +22 -27
- package/lib/links.js +16 -24
- package/lib/marketplaceValidate.js +29 -39
- package/lib/mcp/setup.js +68 -80
- package/lib/middleware/__test__/configMiddleware.test.js +32 -67
- package/lib/middleware/__test__/gitMiddleware.test.js +11 -46
- package/lib/middleware/__test__/notificationsMiddleware.test.js +1 -3
- package/lib/middleware/__test__/requestMiddleware.test.js +8 -13
- package/lib/middleware/__test__/utils.test.js +9 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +16 -51
- package/lib/middleware/autoUpdateMiddleware.js +33 -40
- package/lib/middleware/configMiddleware.js +36 -42
- package/lib/middleware/fireAlarmMiddleware.js +12 -18
- package/lib/middleware/gitMiddleware.js +5 -8
- package/lib/middleware/notificationsMiddleware.js +7 -11
- package/lib/middleware/requestMiddleware.js +4 -10
- package/lib/middleware/utils.js +1 -4
- package/lib/middleware/yargsChecksMiddleware.js +10 -13
- package/lib/npm.js +14 -23
- package/lib/oauth.js +29 -35
- package/lib/parsing.js +3 -6
- package/lib/polling.js +11 -15
- package/lib/process.js +11 -19
- package/lib/projectProfiles.d.ts +2 -2
- package/lib/projectProfiles.js +32 -42
- package/lib/projects/ProjectLogsManager.js +18 -21
- package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/AppDevModeInterface.test.js +512 -0
- package/lib/projects/__tests__/LocalDevProcess.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +309 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +170 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +1 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.js +189 -0
- package/lib/projects/__tests__/buildAndDeploy.test.d.ts +1 -0
- package/lib/projects/__tests__/buildAndDeploy.test.js +23 -0
- package/lib/projects/__tests__/components.test.d.ts +1 -0
- package/lib/projects/__tests__/components.test.js +181 -0
- package/lib/projects/__tests__/projects.test.d.ts +1 -0
- package/lib/projects/__tests__/projects.test.js +84 -0
- package/lib/projects/__tests__/structure.test.d.ts +1 -0
- package/lib/projects/__tests__/structure.test.js +211 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +204 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.js +185 -0
- package/lib/projects/add/legacyAddComponent.d.ts +1 -1
- package/lib/projects/add/legacyAddComponent.js +23 -29
- package/lib/projects/add/v3AddComponent.d.ts +1 -1
- package/lib/projects/add/v3AddComponent.js +35 -41
- package/lib/projects/buildAndDeploy.d.ts +1 -1
- package/lib/projects/buildAndDeploy.js +88 -97
- package/lib/projects/components.js +19 -25
- package/lib/projects/config.d.ts +1 -1
- package/lib/projects/config.js +32 -41
- package/lib/projects/create/__tests__/legacy.test.d.ts +1 -0
- package/lib/projects/create/__tests__/legacy.test.js +91 -0
- package/lib/projects/create/__tests__/v3.test.d.ts +1 -0
- package/lib/projects/create/__tests__/v3.test.js +78 -0
- package/lib/projects/create/index.d.ts +3 -3
- package/lib/projects/create/index.js +19 -22
- package/lib/projects/create/legacy.d.ts +1 -1
- package/lib/projects/create/legacy.js +25 -31
- package/lib/projects/create/v3.d.ts +3 -3
- package/lib/projects/create/v3.js +49 -59
- package/lib/projects/ensureProjectExists.js +31 -37
- package/lib/projects/localDev/AppDevModeInterface.d.ts +3 -3
- package/lib/projects/localDev/AppDevModeInterface.js +58 -60
- package/lib/projects/localDev/DevServerManager.d.ts +1 -1
- package/lib/projects/localDev/DevServerManager.js +24 -27
- package/lib/projects/localDev/DevServerManagerV2.d.ts +2 -2
- package/lib/projects/localDev/DevServerManagerV2.js +17 -22
- package/lib/projects/localDev/LocalDevLogger.d.ts +1 -1
- package/lib/projects/localDev/LocalDevLogger.js +59 -64
- package/lib/projects/localDev/LocalDevManager.d.ts +1 -1
- package/lib/projects/localDev/LocalDevManager.js +106 -111
- package/lib/projects/localDev/LocalDevProcess.d.ts +4 -4
- package/lib/projects/localDev/LocalDevProcess.js +25 -30
- package/lib/projects/localDev/LocalDevState.d.ts +3 -3
- package/lib/projects/localDev/LocalDevState.js +3 -5
- package/lib/projects/localDev/LocalDevWatcher.d.ts +1 -1
- package/lib/projects/localDev/LocalDevWatcher.js +6 -11
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +1 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +25 -27
- package/lib/projects/localDev/helpers.d.ts +4 -4
- package/lib/projects/localDev/helpers.js +156 -174
- package/lib/projects/structure.d.ts +4 -4
- package/lib/projects/structure.js +32 -78
- package/lib/projects/ui.js +10 -13
- package/lib/projects/upload.d.ts +2 -3
- package/lib/projects/upload.js +55 -65
- package/lib/projects/urls.js +14 -24
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +48 -54
- package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +28 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +37 -0
- package/lib/prompts/accountNamePrompt.d.ts +1 -1
- package/lib/prompts/accountNamePrompt.js +26 -31
- package/lib/prompts/accountsPrompt.js +12 -15
- package/lib/prompts/cmsFieldPrompt.js +13 -19
- package/lib/prompts/createApiSamplePrompt.d.ts +1 -1
- package/lib/prompts/createApiSamplePrompt.js +9 -12
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +10 -9
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +52 -93
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.js +12 -15
- package/lib/prompts/createTemplatePrompt.js +5 -8
- package/lib/prompts/downloadProjectPrompt.js +17 -20
- package/lib/prompts/installAppPrompt.js +19 -26
- package/lib/prompts/personalAccessKeyPrompt.d.ts +2 -2
- package/lib/prompts/personalAccessKeyPrompt.js +40 -47
- package/lib/prompts/previewPrompt.js +15 -22
- package/lib/prompts/projectAddPrompt.d.ts +1 -1
- package/lib/prompts/projectAddPrompt.js +14 -18
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +48 -54
- package/lib/prompts/projectNameAndDestPrompt.d.ts +1 -1
- package/lib/prompts/projectNameAndDestPrompt.js +22 -29
- package/lib/prompts/projectNamePrompt.js +11 -14
- package/lib/prompts/projectsLogsPrompt.js +5 -8
- package/lib/prompts/promptUtils.d.ts +1 -1
- package/lib/prompts/promptUtils.js +15 -22
- package/lib/prompts/sandboxesPrompt.d.ts +1 -1
- package/lib/prompts/sandboxesPrompt.js +26 -30
- package/lib/prompts/secretPrompt.js +10 -15
- package/lib/prompts/selectAppPrompt.js +11 -14
- package/lib/prompts/selectHubDBTablePrompt.js +24 -30
- package/lib/prompts/selectProjectTemplatePrompt.d.ts +1 -1
- package/lib/prompts/selectProjectTemplatePrompt.js +10 -13
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +22 -25
- package/lib/prompts/setAsDefaultAccountPrompt.js +13 -16
- package/lib/prompts/uploadPrompt.js +11 -17
- package/lib/sandboxSync.d.ts +1 -1
- package/lib/sandboxSync.js +58 -65
- package/lib/sandboxes.d.ts +1 -1
- package/lib/sandboxes.js +68 -76
- package/lib/schema.js +12 -19
- package/lib/serverlessLogs.js +45 -52
- package/lib/testUtils.js +4 -8
- package/lib/ui/SpinniesManager.d.ts +1 -1
- package/lib/ui/SpinniesManager.js +29 -35
- package/lib/ui/boxen.js +11 -14
- package/lib/ui/git.js +14 -20
- package/lib/ui/index.js +55 -73
- package/lib/ui/logger.js +10 -13
- package/lib/ui/serverlessFunctionLogs.js +14 -20
- package/lib/ui/spinniesUtils.js +24 -39
- package/lib/ui/supportHyperlinks.js +3 -6
- package/lib/ui/supportsColor.js +11 -17
- package/lib/ui/table.js +6 -13
- package/lib/upload.js +15 -21
- package/lib/usageTracking.js +44 -50
- package/lib/utils/hasFlag.d.ts +1 -0
- package/lib/utils/hasFlag.js +9 -0
- package/lib/validation.js +48 -87
- package/lib/yargsUtils.d.ts +2 -1
- package/lib/yargsUtils.js +13 -26
- package/mcp-server/server.js +6 -8
- package/mcp-server/tools/index.js +13 -16
- package/mcp-server/tools/project/AddFeatureToProject.d.ts +1 -1
- package/mcp-server/tools/project/AddFeatureToProject.js +33 -37
- package/mcp-server/tools/project/CreateProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/CreateProjectTool.js +44 -48
- package/mcp-server/tools/project/DeployProject.d.ts +1 -1
- package/mcp-server/tools/project/DeployProject.js +16 -20
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +19 -23
- package/mcp-server/tools/project/UploadProjectTools.d.ts +1 -1
- package/mcp-server/tools/project/UploadProjectTools.js +10 -17
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/ValidateProjectTool.js +11 -15
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +150 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +127 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.js +118 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +125 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +106 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +109 -0
- package/mcp-server/tools/project/constants.js +3 -9
- package/mcp-server/types.js +1 -5
- package/mcp-server/utils/__tests__/command.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/command.test.js +45 -0
- package/mcp-server/utils/__tests__/project.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/project.test.js +76 -0
- package/mcp-server/utils/command.d.ts +1 -1
- package/mcp-server/utils/command.js +4 -11
- package/mcp-server/utils/content.d.ts +1 -1
- package/mcp-server/utils/content.js +2 -6
- package/mcp-server/utils/project.js +8 -14
- package/package.json +20 -16
- package/types/LocalDev.d.ts +4 -4
- package/types/LocalDev.js +1 -2
- package/types/ProjectComponents.d.ts +2 -2
- package/types/ProjectComponents.js +1 -2
- package/types/Projects.d.ts +1 -1
- package/types/Projects.js +2 -5
- package/types/Prompts.js +1 -2
- package/types/Yargs.js +1 -2
- package/types/{Cms.d.ts → cms.d.ts} +1 -1
- package/types/cms.js +1 -0
- package/types/sandboxes.js +1 -0
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -127
- package/types/Cms.js +0 -2
- package/types/Sandboxes.js +0 -2
- /package/types/{Sandboxes.d.ts → sandboxes.d.ts} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { getAccountId, getConfigAccounts } from '@hubspot/local-dev-lib/config';
|
|
2
|
+
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
|
+
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
4
|
+
import { fetchDeveloperTestAccounts } from '@hubspot/local-dev-lib/api/developerTestAccounts';
|
|
5
|
+
import { mockHubSpotHttpError } from '../testUtils.js';
|
|
6
|
+
import * as errorHandlers from '../errorHandlers/index.js';
|
|
7
|
+
import { getHasDevTestAccounts, handleDeveloperTestAccountCreateError, validateDevTestAccountUsageLimits, } from '../developerTestAccounts.js';
|
|
8
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/api/developerTestAccounts');
|
|
11
|
+
vi.mock('../errorHandlers');
|
|
12
|
+
const mockedGetAccountId = getAccountId;
|
|
13
|
+
const mockedGetConfigAccounts = getConfigAccounts;
|
|
14
|
+
const mockedFetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
|
|
15
|
+
const APP_DEVELOPER_ACCOUNT_1 = {
|
|
16
|
+
name: 'app-developer-1',
|
|
17
|
+
accountId: 123,
|
|
18
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER,
|
|
19
|
+
env: 'prod',
|
|
20
|
+
};
|
|
21
|
+
const APP_DEVELOPER_ACCOUNT_2 = {
|
|
22
|
+
name: 'app-developer-2',
|
|
23
|
+
accountId: 456,
|
|
24
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER,
|
|
25
|
+
env: 'prod',
|
|
26
|
+
};
|
|
27
|
+
const accounts = [
|
|
28
|
+
APP_DEVELOPER_ACCOUNT_1,
|
|
29
|
+
APP_DEVELOPER_ACCOUNT_2,
|
|
30
|
+
{
|
|
31
|
+
name: 'test-account',
|
|
32
|
+
accountId: 789,
|
|
33
|
+
parentAccountId: APP_DEVELOPER_ACCOUNT_1.accountId,
|
|
34
|
+
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
35
|
+
env: 'prod',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
describe('lib/developerTestAccounts', () => {
|
|
39
|
+
describe('getHasDevTestAccounts()', () => {
|
|
40
|
+
it('should return true if there are developer test accounts associated with the account', () => {
|
|
41
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
42
|
+
mockedGetConfigAccounts.mockReturnValueOnce(accounts);
|
|
43
|
+
const result = getHasDevTestAccounts(APP_DEVELOPER_ACCOUNT_1);
|
|
44
|
+
expect(result).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it('should return false if there are no developer test accounts associated with the account', () => {
|
|
47
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_2.accountId);
|
|
48
|
+
mockedGetConfigAccounts.mockReturnValueOnce(accounts);
|
|
49
|
+
const result = getHasDevTestAccounts(APP_DEVELOPER_ACCOUNT_2);
|
|
50
|
+
expect(result).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
it('should return false if there are no accounts configured', () => {
|
|
53
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
54
|
+
mockedGetConfigAccounts.mockReturnValueOnce(undefined);
|
|
55
|
+
const result = getHasDevTestAccounts(APP_DEVELOPER_ACCOUNT_1);
|
|
56
|
+
expect(result).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('validateDevTestAccountUsageLimits()', () => {
|
|
60
|
+
afterEach(() => {
|
|
61
|
+
mockedGetAccountId.mockRestore();
|
|
62
|
+
mockedFetchDeveloperTestAccounts.mockRestore();
|
|
63
|
+
});
|
|
64
|
+
it('should return null if the account id is not found', async () => {
|
|
65
|
+
mockedGetAccountId.mockReturnValueOnce(undefined);
|
|
66
|
+
const result = await validateDevTestAccountUsageLimits(APP_DEVELOPER_ACCOUNT_1);
|
|
67
|
+
expect(result).toBe(null);
|
|
68
|
+
});
|
|
69
|
+
it('should return null if there is no developer test account data', async () => {
|
|
70
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
71
|
+
mockedFetchDeveloperTestAccounts.mockResolvedValueOnce({
|
|
72
|
+
data: null,
|
|
73
|
+
});
|
|
74
|
+
const result = await validateDevTestAccountUsageLimits(APP_DEVELOPER_ACCOUNT_1);
|
|
75
|
+
expect(result).toBe(null);
|
|
76
|
+
});
|
|
77
|
+
it('should return the test account data if the account has not reached the limit', async () => {
|
|
78
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
79
|
+
const testAccountData = {
|
|
80
|
+
maxTestPortals: 10,
|
|
81
|
+
results: [],
|
|
82
|
+
};
|
|
83
|
+
mockedFetchDeveloperTestAccounts.mockResolvedValueOnce({
|
|
84
|
+
data: testAccountData,
|
|
85
|
+
});
|
|
86
|
+
const result = await validateDevTestAccountUsageLimits(APP_DEVELOPER_ACCOUNT_1);
|
|
87
|
+
expect(result).toEqual(expect.objectContaining(testAccountData));
|
|
88
|
+
});
|
|
89
|
+
it('should throw an error if the account has reached the limit', async () => {
|
|
90
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
91
|
+
mockedFetchDeveloperTestAccounts.mockResolvedValueOnce({
|
|
92
|
+
data: {
|
|
93
|
+
maxTestPortals: 0,
|
|
94
|
+
results: [{}],
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
await expect(validateDevTestAccountUsageLimits(APP_DEVELOPER_ACCOUNT_1)).rejects.toThrow();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe('handleDeveloperTestAccountCreateError()', () => {
|
|
101
|
+
let loggerErrorSpy;
|
|
102
|
+
let logErrorSpy;
|
|
103
|
+
beforeEach(() => {
|
|
104
|
+
loggerErrorSpy = vi.spyOn(logger, 'error');
|
|
105
|
+
logErrorSpy = vi.spyOn(errorHandlers, 'logError');
|
|
106
|
+
});
|
|
107
|
+
afterEach(() => {
|
|
108
|
+
loggerErrorSpy.mockRestore();
|
|
109
|
+
logErrorSpy.mockRestore();
|
|
110
|
+
});
|
|
111
|
+
it('should log and throw an error if the account is missing the required scopes', () => {
|
|
112
|
+
const missingScopesError = mockHubSpotHttpError('Missing scopes error', {
|
|
113
|
+
status: 403,
|
|
114
|
+
data: {
|
|
115
|
+
message: 'Missing scopes error',
|
|
116
|
+
category: 'MISSING_SCOPES',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
expect(() => handleDeveloperTestAccountCreateError(missingScopesError, APP_DEVELOPER_ACCOUNT_1.accountId, 'prod', 10)).toThrow('Missing scopes error');
|
|
120
|
+
expect(loggerErrorSpy).toHaveBeenCalled();
|
|
121
|
+
});
|
|
122
|
+
it('should log and throw an error if the account is missing the required scopes', () => {
|
|
123
|
+
const portalLimitReachedError = mockHubSpotHttpError('Portal limit reached error', {
|
|
124
|
+
status: 400,
|
|
125
|
+
data: {
|
|
126
|
+
message: 'Portal limit reached error',
|
|
127
|
+
errorType: 'TEST_PORTAL_LIMIT_REACHED',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
expect(() => handleDeveloperTestAccountCreateError(portalLimitReachedError, APP_DEVELOPER_ACCOUNT_1.accountId, 'prod', 10)).toThrow('Portal limit reached error');
|
|
131
|
+
expect(loggerErrorSpy).toHaveBeenCalled();
|
|
132
|
+
});
|
|
133
|
+
it('should log a generic error message for an unknown error type', () => {
|
|
134
|
+
const someUnknownError = mockHubSpotHttpError('Some unknown error', {
|
|
135
|
+
status: 400,
|
|
136
|
+
data: {
|
|
137
|
+
message: 'Some unknown error',
|
|
138
|
+
category: 'SOME_UNKNOWN_ERROR',
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
expect(() => handleDeveloperTestAccountCreateError(someUnknownError, APP_DEVELOPER_ACCOUNT_1.accountId, 'prod', 10)).toThrow('Some unknown error');
|
|
142
|
+
expect(logErrorSpy).toHaveBeenCalled();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { fetchEnabledFeatures } from '@hubspot/local-dev-lib/api/localDevAuth';
|
|
2
|
+
import { hasFeature } from '../hasFeature.js';
|
|
3
|
+
vi.mock('@hubspot/local-dev-lib/api/localDevAuth');
|
|
4
|
+
const mockedFetchEnabledFeatures = fetchEnabledFeatures;
|
|
5
|
+
describe('lib/hasFeature', () => {
|
|
6
|
+
describe('hasFeature()', () => {
|
|
7
|
+
const accountId = 123;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
mockedFetchEnabledFeatures.mockResolvedValueOnce({
|
|
10
|
+
data: {
|
|
11
|
+
enabledFeatures: {
|
|
12
|
+
'feature-1': true,
|
|
13
|
+
'feature-2': false,
|
|
14
|
+
'feature-3': true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it('should return true if the feature is enabled', async () => {
|
|
20
|
+
// @ts-expect-error test data
|
|
21
|
+
const result = await hasFeature(accountId, 'feature-1');
|
|
22
|
+
expect(result).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it('should return false if the feature is not enabled', async () => {
|
|
25
|
+
// @ts-expect-error test data
|
|
26
|
+
const result = await hasFeature(accountId, 'feature-2');
|
|
27
|
+
expect(result).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it('should return false if the feature is not present', async () => {
|
|
30
|
+
// @ts-expect-error test data
|
|
31
|
+
const result = await hasFeature(accountId, 'feature-4');
|
|
32
|
+
expect(result).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { isGloballyInstalled, getLatestCliVersion, DEFAULT_PACKAGE_MANAGER, } from '../npm.js';
|
|
3
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
4
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
5
|
+
vi.mock('../ui/SpinniesManager');
|
|
6
|
+
describe('lib/npm', () => {
|
|
7
|
+
let execMock;
|
|
8
|
+
function mockedPromisify(execMock) {
|
|
9
|
+
return vi
|
|
10
|
+
.fn()
|
|
11
|
+
.mockReturnValue(execMock);
|
|
12
|
+
}
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
execMock = vi.fn();
|
|
15
|
+
util.promisify = mockedPromisify(execMock);
|
|
16
|
+
});
|
|
17
|
+
describe('isGloballyInstalled()', () => {
|
|
18
|
+
it('should return true when exec is successful', async () => {
|
|
19
|
+
const actual = await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER);
|
|
20
|
+
expect(actual).toBe(true);
|
|
21
|
+
expect(execMock).toHaveBeenCalledTimes(1);
|
|
22
|
+
expect(execMock).toHaveBeenCalledWith(`${DEFAULT_PACKAGE_MANAGER} --version`);
|
|
23
|
+
});
|
|
24
|
+
it('should return false when exec is unsuccessful', async () => {
|
|
25
|
+
execMock.mockImplementationOnce(() => {
|
|
26
|
+
throw new Error('unsuccessful');
|
|
27
|
+
});
|
|
28
|
+
util.promisify = mockedPromisify(execMock);
|
|
29
|
+
const actual = await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER);
|
|
30
|
+
expect(actual).toBe(false);
|
|
31
|
+
expect(execMock).toHaveBeenCalledTimes(1);
|
|
32
|
+
expect(execMock).toHaveBeenCalledWith(`${DEFAULT_PACKAGE_MANAGER} --version`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('getLatestCliVersion()', () => {
|
|
36
|
+
it('should return the version correctly', async () => {
|
|
37
|
+
const latest = '1.0.0';
|
|
38
|
+
const next = '1.0.0.beta.1';
|
|
39
|
+
execMock.mockResolvedValueOnce({
|
|
40
|
+
stdout: JSON.stringify({ latest, next }),
|
|
41
|
+
});
|
|
42
|
+
util.promisify = mockedPromisify(execMock);
|
|
43
|
+
const actual = await getLatestCliVersion();
|
|
44
|
+
expect(actual).toEqual({ latest, next });
|
|
45
|
+
expect(execMock).toHaveBeenCalledWith(`npm info ${pkg.name} dist-tags --json`);
|
|
46
|
+
});
|
|
47
|
+
it('should throw any errors that encounter with the check', async () => {
|
|
48
|
+
const errorMessage = 'unsuccessful';
|
|
49
|
+
execMock.mockImplementationOnce(() => {
|
|
50
|
+
throw new Error(errorMessage);
|
|
51
|
+
});
|
|
52
|
+
util.promisify = mockedPromisify(execMock);
|
|
53
|
+
await expect(() => getLatestCliVersion()).rejects.toThrow(errorMessage);
|
|
54
|
+
expect(execMock).toHaveBeenCalledWith(`npm info ${pkg.name} dist-tags --json`);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import open from 'open';
|
|
3
|
+
import { OAuth2Manager } from '@hubspot/local-dev-lib/models/OAuth2Manager';
|
|
4
|
+
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
5
|
+
import { addOauthToAccountConfig } from '@hubspot/local-dev-lib/oauth';
|
|
6
|
+
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
7
|
+
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
8
|
+
import { DEFAULT_OAUTH_SCOPES } from '@hubspot/local-dev-lib/constants/auth';
|
|
9
|
+
import { authenticateWithOauth } from '../oauth.js';
|
|
10
|
+
vi.mock('express');
|
|
11
|
+
vi.mock('open');
|
|
12
|
+
vi.mock('@hubspot/local-dev-lib/models/OAuth2Manager');
|
|
13
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
14
|
+
vi.mock('@hubspot/local-dev-lib/oauth');
|
|
15
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
16
|
+
const mockedExpress = express;
|
|
17
|
+
const mockedOAuth2Manager = OAuth2Manager;
|
|
18
|
+
const mockedGetAccountConfig = getAccountConfig;
|
|
19
|
+
describe('lib/oauth', () => {
|
|
20
|
+
const mockExpressReq = {
|
|
21
|
+
query: { code: 'test-auth-code' },
|
|
22
|
+
};
|
|
23
|
+
const mockExpressResp = { send: vi.fn() };
|
|
24
|
+
const mockAccountConfig = {
|
|
25
|
+
accountId: 123,
|
|
26
|
+
clientId: 'test-client-id',
|
|
27
|
+
clientSecret: 'test-client-secret',
|
|
28
|
+
scopes: ['test-scope'],
|
|
29
|
+
env: ENVIRONMENTS.PROD,
|
|
30
|
+
};
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
mockedExpress.mockReturnValue({
|
|
33
|
+
get: vi.fn().mockImplementation((path, callback) => {
|
|
34
|
+
if (path === '/oauth-callback') {
|
|
35
|
+
callback(mockExpressReq, mockExpressResp);
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
listen: vi.fn().mockReturnValue({ close: vi.fn() }),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
vi.clearAllMocks();
|
|
43
|
+
});
|
|
44
|
+
describe('authenticateWithOauth()', () => {
|
|
45
|
+
it('should setup OAuth and authenticate successfully', async () => {
|
|
46
|
+
// Mock successful OAuth flow
|
|
47
|
+
const mockOAuth2Manager = {
|
|
48
|
+
account: mockAccountConfig,
|
|
49
|
+
exchangeForTokens: vi.fn().mockResolvedValue({}),
|
|
50
|
+
};
|
|
51
|
+
mockedOAuth2Manager.mockImplementation(() => mockOAuth2Manager);
|
|
52
|
+
mockedGetAccountConfig.mockReturnValue({
|
|
53
|
+
env: ENVIRONMENTS.PROD,
|
|
54
|
+
});
|
|
55
|
+
await authenticateWithOauth(mockAccountConfig);
|
|
56
|
+
// Verify OAuth2Manager was initialized correctly
|
|
57
|
+
expect(mockedOAuth2Manager).toHaveBeenCalledWith({
|
|
58
|
+
...mockAccountConfig,
|
|
59
|
+
env: ENVIRONMENTS.PROD,
|
|
60
|
+
});
|
|
61
|
+
// Verify logger was called
|
|
62
|
+
expect(logger.log).toHaveBeenCalledWith('Authorizing');
|
|
63
|
+
// Verify OAuth tokens were added to config
|
|
64
|
+
expect(addOauthToAccountConfig).toHaveBeenCalledWith(mockOAuth2Manager);
|
|
65
|
+
});
|
|
66
|
+
it('should handle missing clientId', async () => {
|
|
67
|
+
const invalidConfig = {
|
|
68
|
+
...mockAccountConfig,
|
|
69
|
+
clientId: undefined,
|
|
70
|
+
};
|
|
71
|
+
mockedOAuth2Manager.mockImplementation(() => ({
|
|
72
|
+
account: invalidConfig,
|
|
73
|
+
}));
|
|
74
|
+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
75
|
+
throw new Error('exit');
|
|
76
|
+
});
|
|
77
|
+
await expect(authenticateWithOauth(invalidConfig)).rejects.toThrow('exit');
|
|
78
|
+
expect(logger.error).toHaveBeenCalled();
|
|
79
|
+
expect(exitSpy).toHaveBeenCalled();
|
|
80
|
+
exitSpy.mockRestore();
|
|
81
|
+
});
|
|
82
|
+
it('should use default scopes when none provided', async () => {
|
|
83
|
+
const configWithoutScopes = {
|
|
84
|
+
...mockAccountConfig,
|
|
85
|
+
scopes: undefined,
|
|
86
|
+
};
|
|
87
|
+
const mockOAuth2Manager = {
|
|
88
|
+
account: configWithoutScopes,
|
|
89
|
+
exchangeForTokens: vi.fn().mockResolvedValue({}),
|
|
90
|
+
};
|
|
91
|
+
mockedOAuth2Manager.mockImplementation(() => mockOAuth2Manager);
|
|
92
|
+
await authenticateWithOauth(configWithoutScopes);
|
|
93
|
+
// Verify default scopes were used
|
|
94
|
+
expect(open).toHaveBeenCalledWith(expect.stringContaining(encodeURIComponent(DEFAULT_OAUTH_SCOPES.join(' '))), expect.anything());
|
|
95
|
+
});
|
|
96
|
+
it('should handle OAuth exchange failure', async () => {
|
|
97
|
+
const mockOAuth2Manager = {
|
|
98
|
+
account: mockAccountConfig,
|
|
99
|
+
exchangeForTokens: vi
|
|
100
|
+
.fn()
|
|
101
|
+
.mockRejectedValue(new Error('Exchange failed')),
|
|
102
|
+
};
|
|
103
|
+
mockedOAuth2Manager.mockImplementation(() => mockOAuth2Manager);
|
|
104
|
+
await authenticateWithOauth(mockAccountConfig);
|
|
105
|
+
expect(mockExpressResp.send).toHaveBeenCalledWith(expect.stringContaining('Authorization failed'));
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { parseStringToNumber } from '../parsing.js';
|
|
2
|
+
describe('lib/parsing', () => {
|
|
3
|
+
describe('parseStringToNumber', () => {
|
|
4
|
+
it('should parse valid integer strings', () => {
|
|
5
|
+
expect(parseStringToNumber('123')).toBe(123);
|
|
6
|
+
expect(parseStringToNumber('0')).toBe(0);
|
|
7
|
+
expect(parseStringToNumber('-456')).toBe(-456);
|
|
8
|
+
expect(parseStringToNumber('999')).toBe(999);
|
|
9
|
+
});
|
|
10
|
+
it('should parse strings with leading zeros', () => {
|
|
11
|
+
expect(parseStringToNumber('007')).toBe(7);
|
|
12
|
+
expect(parseStringToNumber('0123')).toBe(123);
|
|
13
|
+
});
|
|
14
|
+
it('should throw error for strings with leading whitespace', () => {
|
|
15
|
+
expect(() => parseStringToNumber(' 42')).toThrow('Unable to parse string to number');
|
|
16
|
+
expect(() => parseStringToNumber('\t123')).toThrow('Unable to parse string to number');
|
|
17
|
+
});
|
|
18
|
+
it('should throw error for invalid number strings', () => {
|
|
19
|
+
expect(() => parseStringToNumber('abc')).toThrow('Unable to parse string to number');
|
|
20
|
+
expect(() => parseStringToNumber('')).toThrow('Unable to parse string to number');
|
|
21
|
+
expect(() => parseStringToNumber('NaN')).toThrow('Unable to parse string to number');
|
|
22
|
+
});
|
|
23
|
+
it('should throw error for strings with non-numeric characters', () => {
|
|
24
|
+
expect(() => parseStringToNumber('123abc')).toThrow('Unable to parse string to number');
|
|
25
|
+
expect(() => parseStringToNumber('456def')).toThrow('Unable to parse string to number');
|
|
26
|
+
expect(() => parseStringToNumber('12.34')).toThrow('Unable to parse string to number');
|
|
27
|
+
});
|
|
28
|
+
it('should throw error for strings with mixed content', () => {
|
|
29
|
+
expect(() => parseStringToNumber('123 456')).toThrow('Unable to parse string to number');
|
|
30
|
+
expect(() => parseStringToNumber('1,234')).toThrow('Unable to parse string to number');
|
|
31
|
+
expect(() => parseStringToNumber('1.23e4')).toThrow('Unable to parse string to number');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { poll, DEFAULT_POLLING_STATES } from '../polling.js';
|
|
2
|
+
import { DEFAULT_POLLING_DELAY } from '../constants.js';
|
|
3
|
+
// Helper to create a mock polling callback
|
|
4
|
+
const createMockCallback = (responses) => {
|
|
5
|
+
let callCount = 0;
|
|
6
|
+
return vi.fn(() => {
|
|
7
|
+
const response = responses[callCount];
|
|
8
|
+
callCount++;
|
|
9
|
+
return Promise.resolve({ data: response });
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
describe('lib/polling', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.useFakeTimers();
|
|
15
|
+
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
vi.useRealTimers();
|
|
18
|
+
});
|
|
19
|
+
describe('poll()', () => {
|
|
20
|
+
it('should resolve when status is SUCCESS', async () => {
|
|
21
|
+
const mockCallback = createMockCallback([
|
|
22
|
+
{ status: DEFAULT_POLLING_STATES.STARTED },
|
|
23
|
+
{ status: DEFAULT_POLLING_STATES.SUCCESS },
|
|
24
|
+
]);
|
|
25
|
+
const pollPromise = poll(mockCallback);
|
|
26
|
+
// Fast-forward through two polling intervals
|
|
27
|
+
vi.advanceTimersByTime(DEFAULT_POLLING_DELAY * 2);
|
|
28
|
+
const result = await pollPromise;
|
|
29
|
+
expect(result.status).toBe(DEFAULT_POLLING_STATES.SUCCESS);
|
|
30
|
+
expect(mockCallback).toHaveBeenCalledTimes(2);
|
|
31
|
+
});
|
|
32
|
+
it('should reject when status is ERROR', async () => {
|
|
33
|
+
const mockCallback = createMockCallback([
|
|
34
|
+
{ status: DEFAULT_POLLING_STATES.STARTED },
|
|
35
|
+
{ status: DEFAULT_POLLING_STATES.ERROR },
|
|
36
|
+
]);
|
|
37
|
+
const pollPromise = poll(mockCallback);
|
|
38
|
+
vi.advanceTimersByTime(DEFAULT_POLLING_DELAY * 2);
|
|
39
|
+
await expect(pollPromise).rejects.toEqual({
|
|
40
|
+
status: DEFAULT_POLLING_STATES.ERROR,
|
|
41
|
+
});
|
|
42
|
+
expect(mockCallback).toHaveBeenCalledTimes(2);
|
|
43
|
+
});
|
|
44
|
+
it('should reject when status is FAILURE', async () => {
|
|
45
|
+
const mockCallback = createMockCallback([
|
|
46
|
+
{ status: DEFAULT_POLLING_STATES.STARTED },
|
|
47
|
+
{ status: DEFAULT_POLLING_STATES.FAILURE },
|
|
48
|
+
]);
|
|
49
|
+
const pollPromise = poll(mockCallback);
|
|
50
|
+
vi.advanceTimersByTime(DEFAULT_POLLING_DELAY * 2);
|
|
51
|
+
await expect(pollPromise).rejects.toEqual({
|
|
52
|
+
status: DEFAULT_POLLING_STATES.FAILURE,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it('should reject when status is REVERTED', async () => {
|
|
56
|
+
const mockCallback = createMockCallback([
|
|
57
|
+
{ status: DEFAULT_POLLING_STATES.STARTED },
|
|
58
|
+
{ status: DEFAULT_POLLING_STATES.REVERTED },
|
|
59
|
+
]);
|
|
60
|
+
const pollPromise = poll(mockCallback);
|
|
61
|
+
vi.advanceTimersByTime(DEFAULT_POLLING_DELAY * 2);
|
|
62
|
+
await expect(pollPromise).rejects.toEqual({
|
|
63
|
+
status: DEFAULT_POLLING_STATES.REVERTED,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it('should reject when callback throws an error', async () => {
|
|
67
|
+
const mockCallback = vi
|
|
68
|
+
.fn()
|
|
69
|
+
.mockRejectedValue(new Error('Network error'));
|
|
70
|
+
const pollPromise = poll(mockCallback);
|
|
71
|
+
vi.advanceTimersByTime(DEFAULT_POLLING_DELAY);
|
|
72
|
+
await expect(pollPromise).rejects.toThrow('Network error');
|
|
73
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import readline from 'readline';
|
|
2
|
+
import { logger, setLogLevel, LOG_LEVEL } from '@hubspot/local-dev-lib/logger';
|
|
3
|
+
import { handleExit, handleKeypress, TERMINATION_SIGNALS } from '../process.js';
|
|
4
|
+
vi.mock('readline');
|
|
5
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
6
|
+
const mockedReadline = readline;
|
|
7
|
+
const mockedLogger = logger;
|
|
8
|
+
const mockedSetLogLevel = setLogLevel;
|
|
9
|
+
const processRemoveListenerSpy = vi.spyOn(process, 'removeAllListeners');
|
|
10
|
+
const processOnSpy = vi.spyOn(process, 'on');
|
|
11
|
+
describe('lib/process', () => {
|
|
12
|
+
describe('handleExit()', () => {
|
|
13
|
+
const mockCallback = vi.fn();
|
|
14
|
+
it('should set up listeners for all termination signals', () => {
|
|
15
|
+
handleExit(mockCallback);
|
|
16
|
+
TERMINATION_SIGNALS.forEach(signal => {
|
|
17
|
+
expect(processRemoveListenerSpy).toHaveBeenCalledWith(signal);
|
|
18
|
+
expect(processOnSpy).toHaveBeenCalledWith(signal, expect.any(Function));
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
it('should handle SIGHUP signal correctly', async () => {
|
|
22
|
+
handleExit(mockCallback);
|
|
23
|
+
// Get the callback function passed to process.on for SIGHUP
|
|
24
|
+
const sighupCallback = processOnSpy.mock.calls.find(call => call[0] === 'SIGHUP')?.[1];
|
|
25
|
+
expect(sighupCallback).toBeDefined();
|
|
26
|
+
sighupCallback();
|
|
27
|
+
expect(mockedSetLogLevel).toHaveBeenCalledWith(LOG_LEVEL.NONE);
|
|
28
|
+
expect(mockCallback).toHaveBeenCalledWith({ isSIGHUP: true });
|
|
29
|
+
expect(mockedLogger.debug).toHaveBeenCalledWith(expect.stringContaining('SIGHUP'));
|
|
30
|
+
});
|
|
31
|
+
it('should handle non-SIGHUP signals correctly', async () => {
|
|
32
|
+
handleExit(mockCallback);
|
|
33
|
+
// Get the callback function passed to process.on for SIGINT
|
|
34
|
+
const sigintCallback = processOnSpy.mock.calls.find(call => call[0] === 'SIGINT')?.[1];
|
|
35
|
+
expect(sigintCallback).toBeDefined();
|
|
36
|
+
sigintCallback();
|
|
37
|
+
expect(mockedSetLogLevel).not.toHaveBeenCalled();
|
|
38
|
+
expect(mockCallback).toHaveBeenCalledWith({ isSIGHUP: false });
|
|
39
|
+
expect(mockedLogger.debug).toHaveBeenCalledWith(expect.stringContaining('SIGINT'));
|
|
40
|
+
});
|
|
41
|
+
it('should prevent duplicate exit handling', async () => {
|
|
42
|
+
handleExit(mockCallback);
|
|
43
|
+
// Get the callback function passed to process.on for SIGINT
|
|
44
|
+
const sigintCallback = processOnSpy.mock.calls.find(call => call[0] === 'SIGINT')?.[1];
|
|
45
|
+
expect(sigintCallback).toBeDefined();
|
|
46
|
+
sigintCallback();
|
|
47
|
+
sigintCallback(); // Second call should be ignored
|
|
48
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('handleKeypress()', () => {
|
|
52
|
+
const mockCallback = vi.fn();
|
|
53
|
+
it('should set up keypress handling correctly', () => {
|
|
54
|
+
// Mock process.stdin
|
|
55
|
+
Object.defineProperty(process, 'stdin', {
|
|
56
|
+
value: {
|
|
57
|
+
isTTY: true,
|
|
58
|
+
setRawMode: vi.fn(),
|
|
59
|
+
on: vi.fn(),
|
|
60
|
+
removeAllListeners: vi.fn(),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
mockedReadline.createInterface.mockReturnValue({});
|
|
64
|
+
mockedReadline.emitKeypressEvents.mockImplementation(() => { });
|
|
65
|
+
handleKeypress(mockCallback);
|
|
66
|
+
expect(mockedReadline.createInterface).toHaveBeenCalledWith(process.stdin, process.stdout);
|
|
67
|
+
expect(mockedReadline.emitKeypressEvents).toHaveBeenCalledWith(process.stdin);
|
|
68
|
+
expect(process.stdin.setRawMode).toHaveBeenCalledWith(true);
|
|
69
|
+
expect(process.stdin.removeAllListeners).toHaveBeenCalledWith('keypress');
|
|
70
|
+
expect(process.stdin.on).toHaveBeenCalledWith('keypress', expect.any(Function));
|
|
71
|
+
});
|
|
72
|
+
it('should not set raw mode when stdin is not TTY', () => {
|
|
73
|
+
// Mock process.stdin as non-TTY
|
|
74
|
+
Object.defineProperty(process, 'stdin', {
|
|
75
|
+
value: {
|
|
76
|
+
isTTY: false,
|
|
77
|
+
on: vi.fn(),
|
|
78
|
+
removeAllListeners: vi.fn(),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
handleKeypress(mockCallback);
|
|
82
|
+
expect(process.stdin.setRawMode).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|