movehat 0.1.9 → 0.2.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/README.md +2 -2
- package/dist/__tests__/deployContract.test.d.ts +2 -0
- package/dist/__tests__/deployContract.test.d.ts.map +1 -0
- package/dist/__tests__/deployContract.test.js +368 -0
- package/dist/__tests__/deployContract.test.js.map +1 -0
- package/dist/__tests__/errors.test.d.ts +2 -0
- package/dist/__tests__/errors.test.d.ts.map +1 -0
- package/dist/__tests__/errors.test.js +46 -0
- package/dist/__tests__/errors.test.js.map +1 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts +24 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts.map +1 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.js +82 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.js.map +1 -0
- package/dist/__tests__/fork/api.test.d.ts +2 -0
- package/dist/__tests__/fork/api.test.d.ts.map +1 -0
- package/dist/__tests__/fork/api.test.js +110 -0
- package/dist/__tests__/fork/api.test.js.map +1 -0
- package/dist/__tests__/harness/Harness.createLive.test.d.ts +2 -0
- package/dist/__tests__/harness/Harness.createLive.test.d.ts.map +1 -0
- package/dist/__tests__/harness/Harness.createLive.test.js +53 -0
- package/dist/__tests__/harness/Harness.createLive.test.js.map +1 -0
- package/dist/__tests__/harness/Harness.proxy.test.d.ts +2 -0
- package/dist/__tests__/harness/Harness.proxy.test.d.ts.map +1 -0
- package/dist/__tests__/harness/Harness.proxy.test.js +93 -0
- package/dist/__tests__/harness/Harness.proxy.test.js.map +1 -0
- package/dist/__tests__/harness/_fixture.d.ts +54 -0
- package/dist/__tests__/harness/_fixture.d.ts.map +1 -0
- package/dist/__tests__/harness/_fixture.js +69 -0
- package/dist/__tests__/harness/_fixture.js.map +1 -0
- package/dist/__tests__/harness/codeObject.deploy.test.d.ts +2 -0
- package/dist/__tests__/harness/codeObject.deploy.test.d.ts.map +1 -0
- package/dist/__tests__/harness/codeObject.deploy.test.js +288 -0
- package/dist/__tests__/harness/codeObject.deploy.test.js.map +1 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.d.ts +2 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.d.ts.map +1 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.js +138 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.js.map +1 -0
- package/dist/__tests__/harness/script.test.d.ts +2 -0
- package/dist/__tests__/harness/script.test.d.ts.map +1 -0
- package/dist/__tests__/harness/script.test.js +219 -0
- package/dist/__tests__/harness/script.test.js.map +1 -0
- package/dist/__tests__/harness/view.test.d.ts +2 -0
- package/dist/__tests__/harness/view.test.d.ts.map +1 -0
- package/dist/__tests__/harness/view.test.js +92 -0
- package/dist/__tests__/harness/view.test.js.map +1 -0
- package/dist/__tests__/runtime.test.d.ts +2 -0
- package/dist/__tests__/runtime.test.d.ts.map +1 -0
- package/dist/__tests__/runtime.test.js +141 -0
- package/dist/__tests__/runtime.test.js.map +1 -0
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/__tests__/compile.test.d.ts +2 -0
- package/dist/commands/__tests__/compile.test.d.ts.map +1 -0
- package/dist/commands/__tests__/compile.test.js +351 -0
- package/dist/commands/__tests__/compile.test.js.map +1 -0
- package/dist/commands/__tests__/init.test.d.ts +2 -0
- package/dist/commands/__tests__/init.test.d.ts.map +1 -0
- package/dist/commands/__tests__/init.test.js +101 -0
- package/dist/commands/__tests__/init.test.js.map +1 -0
- package/dist/commands/__tests__/run.test.d.ts +2 -0
- package/dist/commands/__tests__/run.test.d.ts.map +1 -0
- package/dist/commands/__tests__/run.test.js +166 -0
- package/dist/commands/__tests__/run.test.js.map +1 -0
- package/dist/commands/__tests__/test-move.test.d.ts +2 -0
- package/dist/commands/__tests__/test-move.test.d.ts.map +1 -0
- package/dist/commands/__tests__/test-move.test.js +59 -0
- package/dist/commands/__tests__/test-move.test.js.map +1 -0
- package/dist/commands/__tests__/test.test.d.ts +2 -0
- package/dist/commands/__tests__/test.test.d.ts.map +1 -0
- package/dist/commands/__tests__/test.test.js +168 -0
- package/dist/commands/__tests__/test.test.js.map +1 -0
- package/dist/commands/__tests__/update.test.d.ts +2 -0
- package/dist/commands/__tests__/update.test.d.ts.map +1 -0
- package/dist/commands/__tests__/update.test.js +176 -0
- package/dist/commands/__tests__/update.test.js.map +1 -0
- package/dist/commands/compile.d.ts +7 -1
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +150 -33
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/fork/__tests__/create.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/create.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/create.test.js +108 -0
- package/dist/commands/fork/__tests__/create.test.js.map +1 -0
- package/dist/commands/fork/__tests__/fund.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/fund.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/fund.test.js +72 -0
- package/dist/commands/fork/__tests__/fund.test.js.map +1 -0
- package/dist/commands/fork/__tests__/list.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/list.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/list.test.js +119 -0
- package/dist/commands/fork/__tests__/list.test.js.map +1 -0
- package/dist/commands/fork/__tests__/serve.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/serve.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/serve.test.js +97 -0
- package/dist/commands/fork/__tests__/serve.test.js.map +1 -0
- package/dist/commands/fork/__tests__/view-resource.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/view-resource.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/view-resource.test.js +77 -0
- package/dist/commands/fork/__tests__/view-resource.test.js.map +1 -0
- package/dist/commands/fork/create.d.ts +1 -1
- package/dist/commands/fork/create.d.ts.map +1 -1
- package/dist/commands/fork/create.js +3 -2
- package/dist/commands/fork/create.js.map +1 -1
- package/dist/commands/fork/fund.d.ts.map +1 -1
- package/dist/commands/fork/fund.js +15 -8
- package/dist/commands/fork/fund.js.map +1 -1
- package/dist/commands/fork/list.d.ts.map +1 -1
- package/dist/commands/fork/list.js +2 -1
- package/dist/commands/fork/list.js.map +1 -1
- package/dist/commands/fork/serve.d.ts +1 -0
- package/dist/commands/fork/serve.d.ts.map +1 -1
- package/dist/commands/fork/serve.js +4 -2
- package/dist/commands/fork/serve.js.map +1 -1
- package/dist/commands/fork/view-resource.d.ts.map +1 -1
- package/dist/commands/fork/view-resource.js +10 -5
- package/dist/commands/fork/view-resource.js.map +1 -1
- package/dist/commands/run.d.ts +15 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +50 -27
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/test-move.d.ts.map +1 -1
- package/dist/commands/test-move.js +3 -2
- package/dist/commands/test-move.js.map +1 -1
- package/dist/commands/test.js +52 -46
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +15 -13
- package/dist/commands/update.js.map +1 -1
- package/dist/core/AccountManager.d.ts +1 -1
- package/dist/core/AccountManager.d.ts.map +1 -1
- package/dist/core/AccountManager.js +20 -7
- package/dist/core/AccountManager.js.map +1 -1
- package/dist/core/Publisher.d.ts +31 -0
- package/dist/core/Publisher.d.ts.map +1 -0
- package/dist/core/Publisher.js +248 -0
- package/dist/core/Publisher.js.map +1 -0
- package/dist/core/__tests__/AccountManager.test.d.ts +2 -0
- package/dist/core/__tests__/AccountManager.test.d.ts.map +1 -0
- package/dist/core/__tests__/AccountManager.test.js +239 -0
- package/dist/core/__tests__/AccountManager.test.js.map +1 -0
- package/dist/core/__tests__/config.test.d.ts +2 -0
- package/dist/core/__tests__/config.test.d.ts.map +1 -0
- package/dist/core/__tests__/config.test.js +311 -0
- package/dist/core/__tests__/config.test.js.map +1 -0
- package/dist/core/__tests__/deployments.test.d.ts +2 -0
- package/dist/core/__tests__/deployments.test.d.ts.map +1 -0
- package/dist/core/__tests__/deployments.test.js +201 -0
- package/dist/core/__tests__/deployments.test.js.map +1 -0
- package/dist/core/__tests__/shell.test.d.ts +2 -0
- package/dist/core/__tests__/shell.test.d.ts.map +1 -0
- package/dist/core/__tests__/shell.test.js +107 -0
- package/dist/core/__tests__/shell.test.js.map +1 -0
- package/dist/core/config.d.ts +13 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +80 -11
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.d.ts +1 -1
- package/dist/core/contract.d.ts.map +1 -1
- package/dist/core/contract.js +15 -4
- package/dist/core/contract.js.map +1 -1
- package/dist/core/deployments.d.ts +2 -2
- package/dist/core/deployments.d.ts.map +1 -1
- package/dist/core/deployments.js +8 -6
- package/dist/core/deployments.js.map +1 -1
- package/dist/core/movementProfile.d.ts +34 -0
- package/dist/core/movementProfile.d.ts.map +1 -0
- package/dist/core/movementProfile.js +150 -0
- package/dist/core/movementProfile.js.map +1 -0
- package/dist/core/shell.d.ts +23 -7
- package/dist/core/shell.d.ts.map +1 -1
- package/dist/core/shell.js +32 -14
- package/dist/core/shell.js.map +1 -1
- package/dist/errors.d.ts +35 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +54 -0
- package/dist/errors.js.map +1 -1
- package/dist/fork/__tests__/manager.test.d.ts +2 -0
- package/dist/fork/__tests__/manager.test.d.ts.map +1 -0
- package/dist/fork/__tests__/manager.test.js +309 -0
- package/dist/fork/__tests__/manager.test.js.map +1 -0
- package/dist/fork/__tests__/server.test.d.ts +2 -0
- package/dist/fork/__tests__/server.test.d.ts.map +1 -0
- package/dist/fork/__tests__/server.test.js +54 -0
- package/dist/fork/__tests__/server.test.js.map +1 -0
- package/dist/fork/__tests__/storage.test.d.ts +2 -0
- package/dist/fork/__tests__/storage.test.d.ts.map +1 -0
- package/dist/fork/__tests__/storage.test.js +222 -0
- package/dist/fork/__tests__/storage.test.js.map +1 -0
- package/dist/fork/__tests__/test.test.d.ts +2 -0
- package/dist/fork/__tests__/test.test.d.ts.map +1 -0
- package/dist/fork/__tests__/test.test.js +81 -0
- package/dist/fork/__tests__/test.test.js.map +1 -0
- package/dist/fork/api.d.ts +14 -3
- package/dist/fork/api.d.ts.map +1 -1
- package/dist/fork/api.js +25 -14
- package/dist/fork/api.js.map +1 -1
- package/dist/fork/manager.d.ts +23 -9
- package/dist/fork/manager.d.ts.map +1 -1
- package/dist/fork/manager.js +79 -36
- package/dist/fork/manager.js.map +1 -1
- package/dist/fork/server.d.ts +11 -3
- package/dist/fork/server.d.ts.map +1 -1
- package/dist/fork/server.js +45 -13
- package/dist/fork/server.js.map +1 -1
- package/dist/fork/storage.d.ts +4 -4
- package/dist/fork/storage.d.ts.map +1 -1
- package/dist/fork/storage.js +7 -9
- package/dist/fork/storage.js.map +1 -1
- package/dist/fork/test.d.ts +13 -4
- package/dist/fork/test.d.ts.map +1 -1
- package/dist/fork/test.js +36 -27
- package/dist/fork/test.js.map +1 -1
- package/dist/harness/Harness.d.ts +124 -0
- package/dist/harness/Harness.d.ts.map +1 -0
- package/dist/harness/Harness.js +193 -0
- package/dist/harness/Harness.js.map +1 -0
- package/dist/harness/codeObject.d.ts +31 -0
- package/dist/harness/codeObject.d.ts.map +1 -0
- package/dist/harness/codeObject.js +271 -0
- package/dist/harness/codeObject.js.map +1 -0
- package/dist/harness/errors.d.ts +14 -0
- package/dist/harness/errors.d.ts.map +1 -0
- package/dist/harness/errors.js +22 -0
- package/dist/harness/errors.js.map +1 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +3 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/proxy.d.ts +7 -0
- package/dist/harness/proxy.d.ts.map +1 -0
- package/dist/harness/proxy.js +36 -0
- package/dist/harness/proxy.js.map +1 -0
- package/dist/harness/script.d.ts +21 -0
- package/dist/harness/script.d.ts.map +1 -0
- package/dist/harness/script.js +155 -0
- package/dist/harness/script.js.map +1 -0
- package/dist/harness/view.d.ts +22 -0
- package/dist/harness/view.d.ts.map +1 -0
- package/dist/harness/view.js +28 -0
- package/dist/harness/view.js.map +1 -0
- package/dist/helpers/__tests__/semver-utils.test.d.ts +2 -0
- package/dist/helpers/__tests__/semver-utils.test.d.ts.map +1 -0
- package/dist/helpers/__tests__/semver-utils.test.js +103 -0
- package/dist/helpers/__tests__/semver-utils.test.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -2
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +2 -2
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/move-tests.d.ts +3 -3
- package/dist/helpers/move-tests.d.ts.map +1 -1
- package/dist/helpers/move-tests.js +21 -20
- package/dist/helpers/move-tests.js.map +1 -1
- package/dist/helpers/npm-registry.d.ts.map +1 -1
- package/dist/helpers/npm-registry.js +1 -3
- package/dist/helpers/npm-registry.js.map +1 -1
- package/dist/helpers/semver-utils.d.ts.map +1 -1
- package/dist/helpers/semver-utils.js +4 -3
- package/dist/helpers/semver-utils.js.map +1 -1
- package/dist/helpers/setup.d.ts.map +1 -1
- package/dist/helpers/setup.js +6 -4
- package/dist/helpers/setup.js.map +1 -1
- package/dist/helpers/setupLocalTesting.d.ts +32 -27
- package/dist/helpers/setupLocalTesting.d.ts.map +1 -1
- package/dist/helpers/setupLocalTesting.js +179 -180
- package/dist/helpers/setupLocalTesting.js.map +1 -1
- package/dist/helpers/testFixtures.d.ts +19 -53
- package/dist/helpers/testFixtures.d.ts.map +1 -1
- package/dist/helpers/testFixtures.js +89 -107
- package/dist/helpers/testFixtures.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/node/LocalNodeManager.d.ts +9 -1
- package/dist/node/LocalNodeManager.d.ts.map +1 -1
- package/dist/node/LocalNodeManager.js +75 -58
- package/dist/node/LocalNodeManager.js.map +1 -1
- package/dist/node/__tests__/LocalNodeManager.test.d.ts +2 -0
- package/dist/node/__tests__/LocalNodeManager.test.d.ts.map +1 -0
- package/dist/node/__tests__/LocalNodeManager.test.js +349 -0
- package/dist/node/__tests__/LocalNodeManager.test.js.map +1 -0
- package/dist/runtime.d.ts +12 -15
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +28 -239
- package/dist/runtime.js.map +1 -1
- package/dist/templates/README.md +1 -1
- package/dist/templates/movehat.config.ts +10 -0
- package/dist/templates/package.json +2 -1
- package/dist/templates/scripts/deploy-counter.ts +46 -38
- package/dist/templates/tests/Counter.test.ts +39 -51
- package/dist/templates/types/movehat.d.ts +6 -9
- package/dist/types/config.d.ts +8 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/fork.d.ts +7 -1
- package/dist/types/fork.d.ts.map +1 -1
- package/dist/types/harness.d.ts +166 -0
- package/dist/types/harness.d.ts.map +1 -0
- package/dist/types/harness.js +2 -0
- package/dist/types/harness.js.map +1 -0
- package/dist/types/runtime.d.ts +7 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/ui/__tests__/colors.test.d.ts +2 -0
- package/dist/ui/__tests__/colors.test.d.ts.map +1 -0
- package/dist/ui/__tests__/colors.test.js +127 -0
- package/dist/ui/__tests__/colors.test.js.map +1 -0
- package/dist/ui/colors.d.ts.map +1 -1
- package/dist/ui/colors.js +6 -2
- package/dist/ui/colors.js.map +1 -1
- package/dist/ui/logger.d.ts +17 -0
- package/dist/ui/logger.d.ts.map +1 -1
- package/dist/ui/logger.js +22 -0
- package/dist/ui/logger.js.map +1 -1
- package/dist/ui/symbols.d.ts +1 -0
- package/dist/ui/symbols.d.ts.map +1 -1
- package/dist/ui/symbols.js +7 -1
- package/dist/ui/symbols.js.map +1 -1
- package/dist/utils/__tests__/address.test.d.ts +2 -0
- package/dist/utils/__tests__/address.test.d.ts.map +1 -0
- package/dist/utils/__tests__/address.test.js +70 -0
- package/dist/utils/__tests__/address.test.js.map +1 -0
- package/dist/utils/__tests__/childProcessAdapter.test.d.ts +2 -0
- package/dist/utils/__tests__/childProcessAdapter.test.d.ts.map +1 -0
- package/dist/utils/__tests__/childProcessAdapter.test.js +217 -0
- package/dist/utils/__tests__/childProcessAdapter.test.js.map +1 -0
- package/dist/utils/__tests__/runCli.test.d.ts +2 -0
- package/dist/utils/__tests__/runCli.test.d.ts.map +1 -0
- package/dist/utils/__tests__/runCli.test.js +187 -0
- package/dist/utils/__tests__/runCli.test.js.map +1 -0
- package/dist/utils/address.d.ts +33 -0
- package/dist/utils/address.d.ts.map +1 -0
- package/dist/utils/address.js +52 -0
- package/dist/utils/address.js.map +1 -0
- package/dist/utils/childProcessAdapter.d.ts +93 -0
- package/dist/utils/childProcessAdapter.d.ts.map +1 -0
- package/dist/utils/childProcessAdapter.js +109 -0
- package/dist/utils/childProcessAdapter.js.map +1 -0
- package/dist/utils/parseCliOutput.d.ts +20 -0
- package/dist/utils/parseCliOutput.d.ts.map +1 -0
- package/dist/utils/parseCliOutput.js +26 -0
- package/dist/utils/parseCliOutput.js.map +1 -0
- package/dist/utils/redact.d.ts +15 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/dist/utils/redact.js +24 -0
- package/dist/utils/redact.js.map +1 -0
- package/dist/utils/runCli.d.ts +24 -0
- package/dist/utils/runCli.d.ts.map +1 -0
- package/dist/utils/runCli.js +37 -0
- package/dist/utils/runCli.js.map +1 -0
- package/package.json +14 -4
- package/src/__tests__/deployContract.test.ts +429 -0
- package/src/__tests__/errors.test.ts +84 -0
- package/src/__tests__/fixtures/sigint-deploy-harness.ts +95 -0
- package/src/__tests__/fork/api.test.ts +143 -0
- package/src/__tests__/harness/Harness.createLive.test.ts +57 -0
- package/src/__tests__/harness/Harness.proxy.test.ts +115 -0
- package/src/__tests__/harness/_fixture.ts +131 -0
- package/src/__tests__/harness/codeObject.deploy.test.ts +319 -0
- package/src/__tests__/harness/codeObject.upgrade.test.ts +156 -0
- package/src/__tests__/harness/script.test.ts +245 -0
- package/src/__tests__/harness/view.test.ts +104 -0
- package/src/__tests__/runtime.test.ts +182 -0
- package/src/cli.ts +2 -1
- package/src/commands/__tests__/compile.test.ts +407 -0
- package/src/commands/__tests__/init.test.ts +125 -0
- package/src/commands/__tests__/run.test.ts +192 -0
- package/src/commands/__tests__/test-move.test.ts +81 -0
- package/src/commands/__tests__/test.test.ts +204 -0
- package/src/commands/__tests__/update.test.ts +223 -0
- package/src/commands/compile.ts +168 -32
- package/src/commands/fork/__tests__/create.test.ts +132 -0
- package/src/commands/fork/__tests__/fund.test.ts +104 -0
- package/src/commands/fork/__tests__/list.test.ts +139 -0
- package/src/commands/fork/__tests__/serve.test.ts +121 -0
- package/src/commands/fork/__tests__/view-resource.test.ts +101 -0
- package/src/commands/fork/create.ts +4 -3
- package/src/commands/fork/fund.ts +16 -9
- package/src/commands/fork/list.ts +3 -2
- package/src/commands/fork/serve.ts +6 -3
- package/src/commands/fork/view-resource.ts +11 -6
- package/src/commands/run.ts +54 -28
- package/src/commands/test-move.ts +4 -3
- package/src/commands/test.ts +56 -44
- package/src/commands/update.ts +19 -16
- package/src/core/AccountManager.ts +23 -10
- package/src/core/Publisher.ts +322 -0
- package/src/core/__tests__/AccountManager.test.ts +290 -0
- package/src/core/__tests__/config.test.ts +377 -0
- package/src/core/__tests__/deployments.test.ts +247 -0
- package/src/core/__tests__/shell.test.ts +138 -0
- package/src/core/config.ts +96 -12
- package/src/core/contract.ts +13 -4
- package/src/core/deployments.ts +13 -11
- package/src/core/movementProfile.ts +179 -0
- package/src/core/shell.ts +34 -14
- package/src/errors.ts +60 -0
- package/src/fork/__tests__/manager.test.ts +385 -0
- package/src/fork/__tests__/server.test.ts +65 -0
- package/src/fork/__tests__/storage.test.ts +281 -0
- package/src/fork/__tests__/test.test.ts +97 -0
- package/src/fork/api.ts +28 -14
- package/src/fork/manager.ts +88 -43
- package/src/fork/server.ts +53 -19
- package/src/fork/storage.ts +12 -15
- package/src/fork/test.ts +58 -32
- package/src/harness/Harness.ts +228 -0
- package/src/harness/codeObject.ts +388 -0
- package/src/harness/errors.ts +22 -0
- package/src/harness/index.ts +3 -0
- package/src/harness/proxy.ts +40 -0
- package/src/harness/script.ts +196 -0
- package/src/harness/view.ts +34 -0
- package/src/helpers/__tests__/semver-utils.test.ts +121 -0
- package/src/helpers/index.ts +2 -8
- package/src/helpers/move-tests.ts +27 -23
- package/src/helpers/npm-registry.ts +4 -3
- package/src/helpers/semver-utils.ts +4 -3
- package/src/helpers/setup.ts +6 -4
- package/src/helpers/setupLocalTesting.ts +219 -200
- package/src/helpers/testFixtures.ts +106 -118
- package/src/index.ts +9 -3
- package/src/node/LocalNodeManager.ts +87 -62
- package/src/node/__tests__/LocalNodeManager.test.ts +452 -0
- package/src/runtime.ts +30 -288
- package/src/templates/README.md +1 -1
- package/src/templates/movehat.config.ts +10 -0
- package/src/templates/package.json +2 -1
- package/src/templates/scripts/deploy-counter.ts +46 -38
- package/src/templates/tests/Counter.test.ts +39 -51
- package/src/templates/types/movehat.d.ts +6 -9
- package/src/types/config.ts +8 -0
- package/src/types/fork.ts +7 -1
- package/src/types/harness.ts +182 -0
- package/src/types/runtime.ts +11 -3
- package/src/ui/__tests__/colors.test.ts +156 -0
- package/src/ui/colors.ts +5 -2
- package/src/ui/logger.ts +22 -0
- package/src/ui/symbols.ts +7 -1
- package/src/utils/__tests__/address.test.ts +93 -0
- package/src/utils/__tests__/childProcessAdapter.test.ts +266 -0
- package/src/utils/__tests__/runCli.test.ts +240 -0
- package/src/utils/address.ts +56 -0
- package/src/utils/childProcessAdapter.ts +215 -0
- package/src/utils/parseCliOutput.ts +27 -0
- package/src/utils/redact.ts +24 -0
- package/src/utils/runCli.ts +64 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
+
import { vol, fs as memfsFs } from 'memfs';
|
|
3
|
+
|
|
4
|
+
// Mock fs module - handle both default and named exports
|
|
5
|
+
vi.mock('fs', () => {
|
|
6
|
+
return {
|
|
7
|
+
default: memfsFs,
|
|
8
|
+
...memfsFs,
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Mock runCli so the compileCommand orchestrator tests below never hit
|
|
13
|
+
// the real `movement` binary.
|
|
14
|
+
const runCliMock = vi.fn();
|
|
15
|
+
vi.mock('../../utils/runCli.js', () => ({
|
|
16
|
+
runCli: runCliMock,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
// Mock loadUserConfig so we don't need a real movehat.config.ts on disk
|
|
20
|
+
// (memfs replaces fs but not the dynamic-import path inside loadUserConfig).
|
|
21
|
+
const loadUserConfigMock = vi.fn();
|
|
22
|
+
vi.mock('../../core/config.js', () => ({
|
|
23
|
+
loadUserConfig: loadUserConfigMock,
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
// Import after mocks are set up
|
|
27
|
+
const compileModule = await import('../compile.js');
|
|
28
|
+
const { extractNamedAddresses, updateMoveToml } = compileModule;
|
|
29
|
+
const compileCommand = compileModule.default;
|
|
30
|
+
|
|
31
|
+
describe('extractNamedAddresses', () => {
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
vol.reset();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
vol.reset();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should extract single module address', () => {
|
|
41
|
+
vol.fromJSON({
|
|
42
|
+
'/move/sources/counter.move': `
|
|
43
|
+
module counter::my_counter {
|
|
44
|
+
public fun increment() {}
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const addresses = extractNamedAddresses('/move');
|
|
50
|
+
expect(addresses).toContain('counter');
|
|
51
|
+
expect(addresses.size).toBe(1);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should extract multiple module addresses', () => {
|
|
55
|
+
vol.fromJSON({
|
|
56
|
+
'/move/sources/counter.move': `
|
|
57
|
+
module counter::my_counter {
|
|
58
|
+
public fun increment() {}
|
|
59
|
+
}
|
|
60
|
+
`,
|
|
61
|
+
'/move/sources/token.move': `
|
|
62
|
+
module my_token::token {
|
|
63
|
+
public fun mint() {}
|
|
64
|
+
}
|
|
65
|
+
`,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const addresses = extractNamedAddresses('/move');
|
|
69
|
+
expect(addresses).toContain('counter');
|
|
70
|
+
expect(addresses).toContain('my_token');
|
|
71
|
+
expect(addresses.size).toBe(2);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should ignore standard addresses (std, aptos_framework, aptos_std)', () => {
|
|
75
|
+
vol.fromJSON({
|
|
76
|
+
'/move/sources/counter.move': `
|
|
77
|
+
module std::something {
|
|
78
|
+
public fun test() {}
|
|
79
|
+
}
|
|
80
|
+
module aptos_framework::coin {
|
|
81
|
+
public fun transfer() {}
|
|
82
|
+
}
|
|
83
|
+
module aptos_std::table {
|
|
84
|
+
public fun new() {}
|
|
85
|
+
}
|
|
86
|
+
module my_module::counter {
|
|
87
|
+
public fun increment() {}
|
|
88
|
+
}
|
|
89
|
+
`,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const addresses = extractNamedAddresses('/move');
|
|
93
|
+
expect(addresses).not.toContain('std');
|
|
94
|
+
expect(addresses).not.toContain('aptos_framework');
|
|
95
|
+
expect(addresses).not.toContain('aptos_std');
|
|
96
|
+
expect(addresses).toContain('my_module');
|
|
97
|
+
expect(addresses.size).toBe(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should ignore addresses in comments', () => {
|
|
101
|
+
vol.fromJSON({
|
|
102
|
+
'/move/sources/counter.move': `
|
|
103
|
+
// module commented_out::should_not_match {
|
|
104
|
+
/*
|
|
105
|
+
module block_comment::also_ignored {
|
|
106
|
+
*/
|
|
107
|
+
module real_module::counter {
|
|
108
|
+
public fun increment() {}
|
|
109
|
+
}
|
|
110
|
+
`,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const addresses = extractNamedAddresses('/move');
|
|
114
|
+
expect(addresses).not.toContain('commented_out');
|
|
115
|
+
expect(addresses).not.toContain('block_comment');
|
|
116
|
+
expect(addresses).toContain('real_module');
|
|
117
|
+
expect(addresses.size).toBe(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should handle nested directories', () => {
|
|
121
|
+
vol.fromJSON({
|
|
122
|
+
'/move/sources/core/counter.move': `
|
|
123
|
+
module core_module::counter {
|
|
124
|
+
public fun increment() {}
|
|
125
|
+
}
|
|
126
|
+
`,
|
|
127
|
+
'/move/sources/utils/helpers.move': `
|
|
128
|
+
module utils_module::helpers {
|
|
129
|
+
public fun helper() {}
|
|
130
|
+
}
|
|
131
|
+
`,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const addresses = extractNamedAddresses('/move');
|
|
135
|
+
expect(addresses).toContain('core_module');
|
|
136
|
+
expect(addresses).toContain('utils_module');
|
|
137
|
+
expect(addresses.size).toBe(2);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should return empty set for empty directory', () => {
|
|
141
|
+
vol.fromJSON({
|
|
142
|
+
'/move/sources/.gitkeep': '',
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const addresses = extractNamedAddresses('/move');
|
|
146
|
+
expect(addresses.size).toBe(0);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should handle module with underscore in name', () => {
|
|
150
|
+
vol.fromJSON({
|
|
151
|
+
'/move/sources/counter.move': `
|
|
152
|
+
module hello_blockchain::my_counter_v2 {
|
|
153
|
+
public fun increment() {}
|
|
154
|
+
}
|
|
155
|
+
`,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const addresses = extractNamedAddresses('/move');
|
|
159
|
+
expect(addresses).toContain('hello_blockchain');
|
|
160
|
+
expect(addresses.size).toBe(1);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe('updateMoveToml', () => {
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
vol.reset();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
afterEach(() => {
|
|
170
|
+
vol.reset();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should add missing addresses to Move.toml', () => {
|
|
174
|
+
vol.fromJSON({
|
|
175
|
+
'/move/Move.toml': `[package]
|
|
176
|
+
name = "test"
|
|
177
|
+
version = "1.0.0"
|
|
178
|
+
|
|
179
|
+
[addresses]
|
|
180
|
+
existing = "_"
|
|
181
|
+
|
|
182
|
+
[dev-addresses]
|
|
183
|
+
existing = "0xcafe"
|
|
184
|
+
|
|
185
|
+
[dependencies]
|
|
186
|
+
`,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const detected = new Set(['existing', 'new_address']);
|
|
190
|
+
const added = updateMoveToml('/move', detected);
|
|
191
|
+
|
|
192
|
+
expect(added).toContain('new_address');
|
|
193
|
+
expect(added).not.toContain('existing');
|
|
194
|
+
expect(added.length).toBe(1);
|
|
195
|
+
|
|
196
|
+
const content = vol.readFileSync('/move/Move.toml', 'utf-8') as string;
|
|
197
|
+
expect(content).toContain('new_address = "_"');
|
|
198
|
+
expect(content).toContain('new_address = "0xbeef"'); // Second dev address
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('should assign unique dev addresses', () => {
|
|
202
|
+
vol.fromJSON({
|
|
203
|
+
'/move/Move.toml': `[package]
|
|
204
|
+
name = "test"
|
|
205
|
+
|
|
206
|
+
[addresses]
|
|
207
|
+
|
|
208
|
+
[dev-addresses]
|
|
209
|
+
|
|
210
|
+
[dependencies]
|
|
211
|
+
`,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const detected = new Set(['addr1', 'addr2', 'addr3']);
|
|
215
|
+
const added = updateMoveToml('/move', detected);
|
|
216
|
+
|
|
217
|
+
expect(added.length).toBe(3);
|
|
218
|
+
|
|
219
|
+
const content = vol.readFileSync('/move/Move.toml', 'utf-8') as string;
|
|
220
|
+
expect(content).toContain('addr1 = "0xcafe"');
|
|
221
|
+
expect(content).toContain('addr2 = "0xbeef"');
|
|
222
|
+
expect(content).toContain('addr3 = "0xdead"');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should not duplicate existing addresses', () => {
|
|
226
|
+
vol.fromJSON({
|
|
227
|
+
'/move/Move.toml': `[package]
|
|
228
|
+
name = "test"
|
|
229
|
+
|
|
230
|
+
[addresses]
|
|
231
|
+
counter = "_"
|
|
232
|
+
|
|
233
|
+
[dev-addresses]
|
|
234
|
+
counter = "0xcafe"
|
|
235
|
+
|
|
236
|
+
[dependencies]
|
|
237
|
+
`,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const detected = new Set(['counter']);
|
|
241
|
+
const added = updateMoveToml('/move', detected);
|
|
242
|
+
|
|
243
|
+
expect(added.length).toBe(0);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should return empty array if Move.toml does not exist', () => {
|
|
247
|
+
vol.fromJSON({
|
|
248
|
+
'/move/sources/counter.move': 'module test::counter {}',
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const detected = new Set(['test']);
|
|
252
|
+
const added = updateMoveToml('/move', detected);
|
|
253
|
+
|
|
254
|
+
expect(added.length).toBe(0);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should avoid dev address conflicts', () => {
|
|
258
|
+
vol.fromJSON({
|
|
259
|
+
'/move/Move.toml': `[package]
|
|
260
|
+
name = "test"
|
|
261
|
+
|
|
262
|
+
[addresses]
|
|
263
|
+
existing = "_"
|
|
264
|
+
|
|
265
|
+
[dev-addresses]
|
|
266
|
+
existing = "0xcafe"
|
|
267
|
+
|
|
268
|
+
[dependencies]
|
|
269
|
+
`,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const detected = new Set(['existing', 'new_one']);
|
|
273
|
+
const added = updateMoveToml('/move', detected);
|
|
274
|
+
|
|
275
|
+
const content = vol.readFileSync('/move/Move.toml', 'utf-8') as string;
|
|
276
|
+
// new_one should get 0xbeef since 0xcafe is taken
|
|
277
|
+
expect(content).toContain('new_one = "0xbeef"');
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
describe('compileCommand — orchestrator', () => {
|
|
282
|
+
let exitSpy: ReturnType<typeof vi.spyOn>;
|
|
283
|
+
|
|
284
|
+
beforeEach(() => {
|
|
285
|
+
vol.reset();
|
|
286
|
+
runCliMock.mockReset();
|
|
287
|
+
loadUserConfigMock.mockReset();
|
|
288
|
+
exitSpy = vi
|
|
289
|
+
.spyOn(process, 'exit')
|
|
290
|
+
.mockImplementation(((code?: number) => {
|
|
291
|
+
throw new Error(`__test_exit_${code ?? 0}__`);
|
|
292
|
+
}) as never);
|
|
293
|
+
vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
294
|
+
vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
afterEach(() => {
|
|
298
|
+
vol.reset();
|
|
299
|
+
vi.restoreAllMocks();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('happy path: detects named addresses, invokes movement build, finishes', async () => {
|
|
303
|
+
loadUserConfigMock.mockResolvedValueOnce({
|
|
304
|
+
moveDir: '/proj/move',
|
|
305
|
+
namedAddresses: {},
|
|
306
|
+
});
|
|
307
|
+
vol.fromJSON({
|
|
308
|
+
'/proj/move/Move.toml': `[package]
|
|
309
|
+
name = "proj"
|
|
310
|
+
|
|
311
|
+
[addresses]
|
|
312
|
+
counter = "_"
|
|
313
|
+
|
|
314
|
+
[dev-addresses]
|
|
315
|
+
counter = "0xcafe"
|
|
316
|
+
|
|
317
|
+
[dependencies]
|
|
318
|
+
`,
|
|
319
|
+
'/proj/move/sources/counter.move': 'module counter::lib {}',
|
|
320
|
+
});
|
|
321
|
+
runCliMock.mockResolvedValueOnce({ exitCode: 0, stdout: 'ok', stderr: '' });
|
|
322
|
+
|
|
323
|
+
await compileCommand();
|
|
324
|
+
|
|
325
|
+
expect(runCliMock).toHaveBeenCalledTimes(1);
|
|
326
|
+
const call = runCliMock.mock.calls[0]!;
|
|
327
|
+
expect(call[0].command).toBe('movement');
|
|
328
|
+
expect(call[0].args.slice(0, 2)).toEqual(['move', 'build']);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('exits 1 with a clear error when moveDir is missing', async () => {
|
|
332
|
+
loadUserConfigMock.mockResolvedValueOnce({
|
|
333
|
+
moveDir: '/nonexistent',
|
|
334
|
+
namedAddresses: {},
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
await expect(compileCommand()).rejects.toThrow('__test_exit_1__');
|
|
338
|
+
expect(runCliMock).not.toHaveBeenCalled();
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('exits 1 when the build step returns non-zero', async () => {
|
|
342
|
+
loadUserConfigMock.mockResolvedValueOnce({
|
|
343
|
+
moveDir: '/proj/move',
|
|
344
|
+
namedAddresses: {},
|
|
345
|
+
});
|
|
346
|
+
vol.fromJSON({
|
|
347
|
+
'/proj/move/Move.toml': '[package]\nname="x"\n[addresses]\n',
|
|
348
|
+
'/proj/move/sources/x.move': 'module x::lib {}',
|
|
349
|
+
});
|
|
350
|
+
runCliMock.mockResolvedValueOnce({
|
|
351
|
+
exitCode: 1,
|
|
352
|
+
stdout: '',
|
|
353
|
+
stderr: 'compile error',
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
await expect(compileCommand()).rejects.toThrow('__test_exit_1__');
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('merges user-configured namedAddresses over auto-assigned dev addresses', async () => {
|
|
360
|
+
loadUserConfigMock.mockResolvedValueOnce({
|
|
361
|
+
moveDir: '/proj/move',
|
|
362
|
+
namedAddresses: { counter: '0xabc' },
|
|
363
|
+
});
|
|
364
|
+
vol.fromJSON({
|
|
365
|
+
'/proj/move/Move.toml':
|
|
366
|
+
'[package]\nname="x"\n[addresses]\ncounter = "_"\n[dev-addresses]\n',
|
|
367
|
+
'/proj/move/sources/counter.move': 'module counter::lib {}',
|
|
368
|
+
});
|
|
369
|
+
runCliMock.mockResolvedValueOnce({ exitCode: 0, stdout: '', stderr: '' });
|
|
370
|
+
|
|
371
|
+
await compileCommand();
|
|
372
|
+
|
|
373
|
+
const args = runCliMock.mock.calls[0]![0].args;
|
|
374
|
+
const namedIdx = args.indexOf('--named-addresses');
|
|
375
|
+
expect(namedIdx).toBeGreaterThanOrEqual(0);
|
|
376
|
+
// User-configured override (0xabc) wins over auto-assigned (0xcafe).
|
|
377
|
+
expect(args[namedIdx + 1]).toContain('counter=0xabc');
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('rejects an invalid named-address key', async () => {
|
|
381
|
+
loadUserConfigMock.mockResolvedValueOnce({
|
|
382
|
+
moveDir: '/proj/move',
|
|
383
|
+
namedAddresses: { 'bad-name-with-dash': '0x1' },
|
|
384
|
+
});
|
|
385
|
+
vol.fromJSON({
|
|
386
|
+
'/proj/move/Move.toml': '[package]\nname="x"\n[addresses]\n',
|
|
387
|
+
'/proj/move/sources/x.move': 'module x::lib {}',
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
await expect(compileCommand()).rejects.toThrow('__test_exit_1__');
|
|
391
|
+
expect(runCliMock).not.toHaveBeenCalled();
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('rejects an invalid address value (non-hex)', async () => {
|
|
395
|
+
loadUserConfigMock.mockResolvedValueOnce({
|
|
396
|
+
moveDir: '/proj/move',
|
|
397
|
+
namedAddresses: { counter: 'not-hex' },
|
|
398
|
+
});
|
|
399
|
+
vol.fromJSON({
|
|
400
|
+
'/proj/move/Move.toml': '[package]\nname="x"\n[addresses]\n',
|
|
401
|
+
'/proj/move/sources/x.move': 'module counter::lib {}',
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
await expect(compileCommand()).rejects.toThrow('__test_exit_1__');
|
|
405
|
+
expect(runCliMock).not.toHaveBeenCalled();
|
|
406
|
+
});
|
|
407
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
const promptsMock = vi.fn();
|
|
7
|
+
vi.mock("prompts", () => ({
|
|
8
|
+
default: promptsMock,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
// Silence the ASCII banner.
|
|
12
|
+
vi.mock("../../helpers/banner.js", () => ({
|
|
13
|
+
printMovehatBanner: () => undefined,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const { default: initCommand } = await import("../init.js");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Strategy: real tmpdir + real fs ops (matches §6.1's example-as-canonical
|
|
20
|
+
* scaffold philosophy — if `init` can't actually copy files end-to-end,
|
|
21
|
+
* users land on a broken state). We chdir into a fresh tmp parent for
|
|
22
|
+
* each test and verify the target project directory was created and
|
|
23
|
+
* contains the expected files.
|
|
24
|
+
*
|
|
25
|
+
* The Move templates ship at `src/templates/` in the source tree; when
|
|
26
|
+
* vitest runs the TS source, `__dirname` of `init.ts` resolves to
|
|
27
|
+
* `src/commands/` so `path.join(__dirname, "..", "templates")` resolves
|
|
28
|
+
* to `src/templates/` cleanly. No bundling step required.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
describe("initCommand", () => {
|
|
32
|
+
let tmpParent: string;
|
|
33
|
+
let origCwd: string;
|
|
34
|
+
let exitSpy: ReturnType<typeof vi.spyOn>;
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
promptsMock.mockReset();
|
|
38
|
+
origCwd = process.cwd();
|
|
39
|
+
tmpParent = mkdtempSync(join(tmpdir(), "movehat-init-test-"));
|
|
40
|
+
process.chdir(tmpParent);
|
|
41
|
+
// Throw a sentinel error so flow actually aborts (in real CLI usage
|
|
42
|
+
// process.exit terminates the process; for tests we need it to break
|
|
43
|
+
// out of the rest of init.ts via a thrown error).
|
|
44
|
+
exitSpy = vi
|
|
45
|
+
.spyOn(process, "exit")
|
|
46
|
+
.mockImplementation(((code?: number) => {
|
|
47
|
+
throw new Error(`__test_exit_${code ?? 0}__`);
|
|
48
|
+
}) as never);
|
|
49
|
+
vi.spyOn(console, "log").mockImplementation(() => undefined);
|
|
50
|
+
vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
process.chdir(origCwd);
|
|
55
|
+
if (existsSync(tmpParent)) {
|
|
56
|
+
rmSync(tmpParent, { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
vi.restoreAllMocks();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("happy path: scaffolds a project from the canonical template", async () => {
|
|
62
|
+
await initCommand("my-test-project");
|
|
63
|
+
|
|
64
|
+
const target = join(tmpParent, "my-test-project");
|
|
65
|
+
expect(existsSync(target)).toBe(true);
|
|
66
|
+
// Canonical files at the project root.
|
|
67
|
+
expect(existsSync(join(target, "package.json"))).toBe(true);
|
|
68
|
+
expect(existsSync(join(target, "tsconfig.json"))).toBe(true);
|
|
69
|
+
expect(existsSync(join(target, ".mocharc.json"))).toBe(true);
|
|
70
|
+
expect(existsSync(join(target, "movehat.config.ts"))).toBe(true);
|
|
71
|
+
expect(existsSync(join(target, ".env.example"))).toBe(true);
|
|
72
|
+
expect(existsSync(join(target, ".gitignore"))).toBe(true);
|
|
73
|
+
expect(existsSync(join(target, "README.md"))).toBe(true);
|
|
74
|
+
// Subdirectories with their own files.
|
|
75
|
+
expect(existsSync(join(target, "move"))).toBe(true);
|
|
76
|
+
expect(existsSync(join(target, "scripts"))).toBe(true);
|
|
77
|
+
expect(existsSync(join(target, "tests"))).toBe(true);
|
|
78
|
+
// Excluded template-development directory.
|
|
79
|
+
expect(existsSync(join(target, "types"))).toBe(false);
|
|
80
|
+
expect(existsSync(join(target, ".vscode"))).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("substitutes {{projectName}} placeholders inside template files", async () => {
|
|
84
|
+
await initCommand("substituted-project");
|
|
85
|
+
|
|
86
|
+
const pkg = readFileSync(
|
|
87
|
+
join(tmpParent, "substituted-project", "package.json"),
|
|
88
|
+
"utf-8"
|
|
89
|
+
);
|
|
90
|
+
expect(pkg).toContain("substituted-project");
|
|
91
|
+
expect(pkg).not.toContain("{{projectName}}");
|
|
92
|
+
|
|
93
|
+
const readme = readFileSync(
|
|
94
|
+
join(tmpParent, "substituted-project", "README.md"),
|
|
95
|
+
"utf-8"
|
|
96
|
+
);
|
|
97
|
+
expect(readme).toContain("substituted-project");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("prompts for project name when none is provided", async () => {
|
|
101
|
+
promptsMock.mockResolvedValueOnce({ projectName: "from-prompt" });
|
|
102
|
+
|
|
103
|
+
await initCommand();
|
|
104
|
+
|
|
105
|
+
expect(promptsMock).toHaveBeenCalledTimes(1);
|
|
106
|
+
expect(existsSync(join(tmpParent, "from-prompt"))).toBe(true);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("exits 0 when the user Ctrl+Cs the prompt (no project created)", async () => {
|
|
110
|
+
promptsMock.mockResolvedValueOnce({});
|
|
111
|
+
|
|
112
|
+
await expect(initCommand()).rejects.toThrow("__test_exit_0__");
|
|
113
|
+
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("exits 1 when the template copy step hits an unwriteable target", async () => {
|
|
117
|
+
// Plant a directory where the command will try to write package.json
|
|
118
|
+
// as a file — fs.writeFile rejects with EISDIR.
|
|
119
|
+
const targetName = "blocked-project";
|
|
120
|
+
mkdirSync(join(tmpParent, targetName, "package.json"), { recursive: true });
|
|
121
|
+
|
|
122
|
+
await expect(initCommand(targetName)).rejects.toThrow("__test_exit_1__");
|
|
123
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
124
|
+
});
|
|
125
|
+
});
|