@gadicc/loom 1.38.0 → 2.0.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/.loom-source-manifest.json +97 -0
- package/README.md +103 -31
- package/db/databaseTls.js +6 -3
- package/db/databaseUrl.js +3 -2
- package/db/drizzle-config.js +14 -16
- package/db/fixtures.d.ts +1 -3
- package/db/fixtures.js +4 -7
- package/esm/bin/loom.d.ts +2 -1
- package/esm/bin/loom.d.ts.map +1 -1
- package/esm/bin/loom.js +37 -10
- package/esm/bin/loom.js.map +1 -0
- package/esm/mod.d.ts +0 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/mod.js.map +1 -0
- package/esm/src/apiKeys/authorize.d.ts.map +1 -1
- package/esm/src/apiKeys/authorize.js +15 -14
- package/esm/src/apiKeys/authorize.js.map +1 -0
- package/esm/src/apiKeys/betterAuth.d.ts.map +1 -1
- package/esm/src/apiKeys/betterAuth.js +1 -0
- package/esm/src/apiKeys/betterAuth.js.map +1 -0
- package/esm/src/apiKeys/country.d.ts.map +1 -1
- package/esm/src/apiKeys/country.js +1 -0
- package/esm/src/apiKeys/country.js.map +1 -0
- package/esm/src/apiKeys/credentials.d.ts.map +1 -1
- package/esm/src/apiKeys/credentials.js +3 -1
- package/esm/src/apiKeys/credentials.js.map +1 -0
- package/esm/src/apiKeys/fingerprint.d.ts.map +1 -1
- package/esm/src/apiKeys/fingerprint.js +1 -0
- package/esm/src/apiKeys/fingerprint.js.map +1 -0
- package/esm/src/apiKeys/lifecycle.d.ts.map +1 -1
- package/esm/src/apiKeys/lifecycle.js +1 -0
- package/esm/src/apiKeys/lifecycle.js.map +1 -0
- package/esm/src/apiKeys/limits.d.ts.map +1 -1
- package/esm/src/apiKeys/limits.js +10 -10
- package/esm/src/apiKeys/limits.js.map +1 -0
- package/esm/src/apiKeys/mod.d.ts +0 -1
- package/esm/src/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/apiKeys/mod.js +1 -1
- package/esm/src/apiKeys/mod.js.map +1 -0
- package/esm/src/apiKeys/permissions.d.ts.map +1 -1
- package/esm/src/apiKeys/permissions.js +1 -0
- package/esm/src/apiKeys/permissions.js.map +1 -0
- package/esm/src/apiKeys/policy.d.ts.map +1 -1
- package/esm/src/apiKeys/policy.js +1 -0
- package/esm/src/apiKeys/policy.js.map +1 -0
- package/esm/src/apiKeys/retention.d.ts.map +1 -1
- package/esm/src/apiKeys/retention.js +1 -0
- package/esm/src/apiKeys/retention.js.map +1 -0
- package/esm/src/apiKeys/types.d.ts.map +1 -1
- package/esm/src/apiKeys/types.js +1 -0
- package/esm/src/apiKeys/types.js.map +1 -0
- package/esm/src/cli/atomicText.d.ts +3 -0
- package/esm/src/cli/atomicText.d.ts.map +1 -0
- package/esm/src/cli/atomicText.js +33 -0
- package/esm/src/cli/atomicText.js.map +1 -0
- package/esm/src/cli/bunLocalDev.d.ts +65 -0
- package/esm/src/cli/bunLocalDev.d.ts.map +1 -0
- package/esm/src/cli/bunLocalDev.js +459 -0
- package/esm/src/cli/bunLocalDev.js.map +1 -0
- package/esm/src/cli/bunProject.d.ts +30 -0
- package/esm/src/cli/bunProject.d.ts.map +1 -0
- package/esm/src/cli/bunProject.js +309 -0
- package/esm/src/cli/bunProject.js.map +1 -0
- package/esm/src/cli/cliBootstrap.d.ts +83 -0
- package/esm/src/cli/cliBootstrap.d.ts.map +1 -0
- package/esm/src/cli/cliBootstrap.js +186 -0
- package/esm/src/cli/cliBootstrap.js.map +1 -0
- package/esm/src/cli/externalSkills.d.ts.map +1 -1
- package/esm/src/cli/externalSkills.js +9 -5
- package/esm/src/cli/externalSkills.js.map +1 -0
- package/esm/src/cli/filesR2Policy.d.ts.map +1 -1
- package/esm/src/cli/filesR2Policy.js +18 -11
- package/esm/src/cli/filesR2Policy.js.map +1 -0
- package/esm/src/cli/generatedBuild.d.ts +42 -0
- package/esm/src/cli/generatedBuild.d.ts.map +1 -0
- package/esm/src/cli/generatedBuild.js +259 -0
- package/esm/src/cli/generatedBuild.js.map +1 -0
- package/esm/src/cli/generatedCleanup.d.ts +7 -0
- package/esm/src/cli/generatedCleanup.d.ts.map +1 -0
- package/esm/src/cli/generatedCleanup.js +67 -0
- package/esm/src/cli/generatedCleanup.js.map +1 -0
- package/esm/src/cli/generatedDevLease.d.ts +8 -0
- package/esm/src/cli/generatedDevLease.d.ts.map +1 -0
- package/esm/src/cli/generatedDevLease.js +39 -0
- package/esm/src/cli/generatedDevLease.js.map +1 -0
- package/esm/src/cli/generatedInstall.d.ts +64 -0
- package/esm/src/cli/generatedInstall.d.ts.map +1 -0
- package/esm/src/cli/generatedInstall.js +466 -0
- package/esm/src/cli/generatedInstall.js.map +1 -0
- package/esm/src/cli/generatedWorkflow.d.ts +34 -0
- package/esm/src/cli/generatedWorkflow.d.ts.map +1 -0
- package/esm/src/cli/generatedWorkflow.js +85 -0
- package/esm/src/cli/generatedWorkflow.js.map +1 -0
- package/esm/src/cli/legacyManagedOutputs.d.ts.map +1 -1
- package/esm/src/cli/legacyManagedOutputs.js +1 -0
- package/esm/src/cli/legacyManagedOutputs.js.map +1 -0
- package/esm/src/cli/localDb.d.ts.map +1 -1
- package/esm/src/cli/localDb.js +33 -28
- package/esm/src/cli/localDb.js.map +1 -0
- package/esm/src/cli/localDevLock.d.ts +9 -0
- package/esm/src/cli/localDevLock.d.ts.map +1 -1
- package/esm/src/cli/localDevLock.js +54 -13
- package/esm/src/cli/localDevLock.js.map +1 -0
- package/esm/src/cli/localDevPackage.d.ts +6 -11
- package/esm/src/cli/localDevPackage.d.ts.map +1 -1
- package/esm/src/cli/localDevPackage.js +51 -48
- package/esm/src/cli/localDevPackage.js.map +1 -0
- package/esm/src/cli/managedFiles.d.ts.map +1 -1
- package/esm/src/cli/managedFiles.js +34 -18
- package/esm/src/cli/managedFiles.js.map +1 -0
- package/esm/src/cli/migrationEnv.d.ts +16 -3
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +7 -4
- package/esm/src/cli/migrationEnv.js.map +1 -0
- package/esm/src/cli/mod.d.ts +19 -7
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +2000 -742
- package/esm/src/cli/mod.js.map +1 -0
- package/esm/src/cli/packageTreeSignature.d.ts +8 -0
- package/esm/src/cli/packageTreeSignature.d.ts.map +1 -0
- package/esm/src/cli/packageTreeSignature.js +60 -0
- package/esm/src/cli/packageTreeSignature.js.map +1 -0
- package/esm/src/cli/processIdentity.d.ts +7 -0
- package/esm/src/cli/processIdentity.d.ts.map +1 -0
- package/esm/src/cli/processIdentity.js +39 -0
- package/esm/src/cli/processIdentity.js.map +1 -0
- package/esm/src/cli/projectSkills.d.ts +1 -1
- package/esm/src/cli/projectSkills.d.ts.map +1 -1
- package/esm/src/cli/projectSkills.js +31 -23
- package/esm/src/cli/projectSkills.js.map +1 -0
- package/esm/src/cli/projectTooling.d.ts +6 -3
- package/esm/src/cli/projectTooling.d.ts.map +1 -1
- package/esm/src/cli/projectTooling.js +86 -41
- package/esm/src/cli/projectTooling.js.map +1 -0
- package/esm/src/cli/releaseConfig.d.ts.map +1 -1
- package/esm/src/cli/releaseConfig.js +5 -3
- package/esm/src/cli/releaseConfig.js.map +1 -0
- package/esm/src/cli/releaseCredentials.d.ts.map +1 -1
- package/esm/src/cli/releaseCredentials.js +19 -31
- package/esm/src/cli/releaseCredentials.js.map +1 -0
- package/esm/src/cli/releaseTrust.d.ts.map +1 -1
- package/esm/src/cli/releaseTrust.js +11 -4
- package/esm/src/cli/releaseTrust.js.map +1 -0
- package/esm/src/cli/releaseTrustCommand.d.ts.map +1 -1
- package/esm/src/cli/releaseTrustCommand.js +6 -4
- package/esm/src/cli/releaseTrustCommand.js.map +1 -0
- package/esm/src/cli/sourceConfig.d.ts +3 -0
- package/esm/src/cli/sourceConfig.d.ts.map +1 -0
- package/esm/src/cli/sourceConfig.js +91 -0
- package/esm/src/cli/sourceConfig.js.map +1 -0
- package/esm/src/cli/sourceDev.d.ts +77 -0
- package/esm/src/cli/sourceDev.d.ts.map +1 -0
- package/esm/src/cli/sourceDev.js +974 -0
- package/esm/src/cli/sourceDev.js.map +1 -0
- package/esm/src/cli/vercelBuildEnv.d.ts.map +1 -1
- package/esm/src/cli/vercelBuildEnv.js +21 -15
- package/esm/src/cli/vercelBuildEnv.js.map +1 -0
- package/esm/src/cli/vercelEnvMask.d.ts +2 -2
- package/esm/src/cli/vercelEnvMask.d.ts.map +1 -1
- package/esm/src/cli/vercelEnvMask.js +8 -4
- package/esm/src/cli/vercelEnvMask.js.map +1 -0
- package/esm/src/cli/vercelProjectRelease.d.ts.map +1 -1
- package/esm/src/cli/vercelProjectRelease.js +45 -22
- package/esm/src/cli/vercelProjectRelease.js.map +1 -0
- package/esm/src/cli/vercelPulledEnv.d.ts +1 -1
- package/esm/src/cli/vercelPulledEnv.d.ts.map +1 -1
- package/esm/src/cli/vercelPulledEnv.js +1 -0
- package/esm/src/cli/vercelPulledEnv.js.map +1 -0
- package/esm/src/clientData/identity.d.ts.map +1 -1
- package/esm/src/clientData/identity.js +1 -0
- package/esm/src/clientData/identity.js.map +1 -0
- package/esm/src/clientData/mod.d.ts +0 -1
- package/esm/src/clientData/mod.d.ts.map +1 -1
- package/esm/src/clientData/mod.js +1 -0
- package/esm/src/clientData/mod.js.map +1 -0
- package/esm/src/files/client.d.ts +1 -1
- package/esm/src/files/client.d.ts.map +1 -1
- package/esm/src/files/client.js +3 -4
- package/esm/src/files/client.js.map +1 -0
- package/esm/src/files/errors.d.ts.map +1 -1
- package/esm/src/files/errors.js +3 -12
- package/esm/src/files/errors.js.map +1 -0
- package/esm/src/files/hash.d.ts +1 -1
- package/esm/src/files/hash.d.ts.map +1 -1
- package/esm/src/files/hash.js +1 -0
- package/esm/src/files/hash.js.map +1 -0
- package/esm/src/files/memory.d.ts.map +1 -1
- package/esm/src/files/memory.js +2 -1
- package/esm/src/files/memory.js.map +1 -0
- package/esm/src/files/metadata.d.ts.map +1 -1
- package/esm/src/files/metadata.js +11 -18
- package/esm/src/files/metadata.js.map +1 -0
- package/esm/src/files/mod.d.ts +0 -1
- package/esm/src/files/mod.d.ts.map +1 -1
- package/esm/src/files/mod.js +1 -1
- package/esm/src/files/mod.js.map +1 -0
- package/esm/src/files/s3.d.ts.map +1 -1
- package/esm/src/files/s3.js +6 -4
- package/esm/src/files/s3.js.map +1 -0
- package/esm/src/files/service.d.ts.map +1 -1
- package/esm/src/files/service.js +3 -4
- package/esm/src/files/service.js.map +1 -0
- package/esm/src/files/types.d.ts.map +1 -1
- package/esm/src/files/types.js +1 -0
- package/esm/src/files/types.js.map +1 -0
- package/esm/src/jobs/catalog.d.ts.map +1 -1
- package/esm/src/jobs/catalog.js +5 -1
- package/esm/src/jobs/catalog.js.map +1 -0
- package/esm/src/jobs/controller.d.ts +1 -1
- package/esm/src/jobs/controller.d.ts.map +1 -1
- package/esm/src/jobs/controller.js +11 -55
- package/esm/src/jobs/controller.js.map +1 -0
- package/esm/src/jobs/direct.d.ts.map +1 -1
- package/esm/src/jobs/direct.js +3 -3
- package/esm/src/jobs/direct.js.map +1 -0
- package/esm/src/jobs/events.d.ts.map +1 -1
- package/esm/src/jobs/events.js +1 -0
- package/esm/src/jobs/events.js.map +1 -0
- package/esm/src/jobs/format.d.ts +5 -5
- package/esm/src/jobs/format.d.ts.map +1 -1
- package/esm/src/jobs/format.js +2 -1
- package/esm/src/jobs/format.js.map +1 -0
- package/esm/src/jobs/http.d.ts +3 -3
- package/esm/src/jobs/http.d.ts.map +1 -1
- package/esm/src/jobs/http.js +1 -0
- package/esm/src/jobs/http.js.map +1 -0
- package/esm/src/jobs/log.d.ts.map +1 -1
- package/esm/src/jobs/log.js +1 -0
- package/esm/src/jobs/log.js.map +1 -0
- package/esm/src/jobs/mod.d.ts.map +1 -1
- package/esm/src/jobs/mod.js +1 -0
- package/esm/src/jobs/mod.js.map +1 -0
- package/esm/src/jobs/run.d.ts.map +1 -1
- package/esm/src/jobs/run.js +1 -0
- package/esm/src/jobs/run.js.map +1 -0
- package/esm/src/jobs/sanitize.d.ts.map +1 -1
- package/esm/src/jobs/sanitize.js +1 -0
- package/esm/src/jobs/sanitize.js.map +1 -0
- package/esm/src/jobs/types.d.ts +1 -0
- package/esm/src/jobs/types.d.ts.map +1 -1
- package/esm/src/jobs/types.js +1 -0
- package/esm/src/jobs/types.js.map +1 -0
- package/esm/src/mail/errors.d.ts.map +1 -1
- package/esm/src/mail/errors.js +8 -42
- package/esm/src/mail/errors.js.map +1 -0
- package/esm/src/mail/memory.d.ts +1 -1
- package/esm/src/mail/memory.d.ts.map +1 -1
- package/esm/src/mail/memory.js +10 -14
- package/esm/src/mail/memory.js.map +1 -0
- package/esm/src/mail/mod.d.ts +0 -1
- package/esm/src/mail/mod.d.ts.map +1 -1
- package/esm/src/mail/mod.js +1 -1
- package/esm/src/mail/mod.js.map +1 -0
- package/esm/src/mail/postal.d.ts +1 -2
- package/esm/src/mail/postal.d.ts.map +1 -1
- package/esm/src/mail/postal.js +22 -18
- package/esm/src/mail/postal.js.map +1 -0
- package/esm/src/mail/retry.d.ts.map +1 -1
- package/esm/src/mail/retry.js +1 -0
- package/esm/src/mail/retry.js.map +1 -0
- package/esm/src/mail/sender.d.ts.map +1 -1
- package/esm/src/mail/sender.js +1 -0
- package/esm/src/mail/sender.js.map +1 -0
- package/esm/src/mail/service.d.ts.map +1 -1
- package/esm/src/mail/service.js +6 -7
- package/esm/src/mail/service.js.map +1 -0
- package/esm/src/mail/types.d.ts.map +1 -1
- package/esm/src/mail/types.js +1 -0
- package/esm/src/mail/types.js.map +1 -0
- package/esm/src/mui/apiKeys.d.ts +10 -11
- package/esm/src/mui/apiKeys.d.ts.map +1 -1
- package/esm/src/mui/apiKeys.js +83 -214
- package/esm/src/mui/apiKeys.js.map +1 -0
- package/esm/src/mui/apiKeysView.d.ts +1 -1
- package/esm/src/mui/apiKeysView.d.ts.map +1 -1
- package/esm/src/mui/apiKeysView.js +11 -9
- package/esm/src/mui/apiKeysView.js.map +1 -0
- package/esm/src/mui/confirm.d.ts +2 -2
- package/esm/src/mui/confirm.d.ts.map +1 -1
- package/esm/src/mui/confirm.js +3 -7
- package/esm/src/mui/confirm.js.map +1 -0
- package/esm/src/mui/mail.d.ts +4 -4
- package/esm/src/mui/mail.d.ts.map +1 -1
- package/esm/src/mui/mail.js +11 -71
- package/esm/src/mui/mail.js.map +1 -0
- package/esm/src/mui/mailView.d.ts +1 -1
- package/esm/src/mui/mailView.d.ts.map +1 -1
- package/esm/src/mui/mailView.js +1 -0
- package/esm/src/mui/mailView.js.map +1 -0
- package/esm/src/mui/mod.d.ts +0 -1
- package/esm/src/mui/mod.d.ts.map +1 -1
- package/esm/src/mui/mod.js +1 -0
- package/esm/src/mui/mod.js.map +1 -0
- package/esm/src/next/apiKeys/mod.d.ts +2 -3
- package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/next/apiKeys/mod.js +6 -5
- package/esm/src/next/apiKeys/mod.js.map +1 -0
- package/esm/src/next/auth/client.d.ts +0 -1
- package/esm/src/next/auth/client.d.ts.map +1 -1
- package/esm/src/next/auth/client.js +1 -0
- package/esm/src/next/auth/client.js.map +1 -0
- package/esm/src/next/auth/config.d.ts.map +1 -1
- package/esm/src/next/auth/config.js +11 -17
- package/esm/src/next/auth/config.js.map +1 -0
- package/esm/src/next/auth/localTestLogin.d.ts.map +1 -1
- package/esm/src/next/auth/localTestLogin.js +13 -9
- package/esm/src/next/auth/localTestLogin.js.map +1 -0
- package/esm/src/next/auth/mod.d.ts.map +1 -1
- package/esm/src/next/auth/mod.js +1 -0
- package/esm/src/next/auth/mod.js.map +1 -0
- package/esm/src/next/auth/server.d.ts +2 -2
- package/esm/src/next/auth/server.d.ts.map +1 -1
- package/esm/src/next/auth/server.js +1 -0
- package/esm/src/next/auth/server.js.map +1 -0
- package/esm/src/next/files/mod.d.ts +0 -1
- package/esm/src/next/files/mod.d.ts.map +1 -1
- package/esm/src/next/files/mod.js +1 -1
- package/esm/src/next/files/mod.js.map +1 -0
- package/esm/src/next/files/route.d.ts +1 -1
- package/esm/src/next/files/route.d.ts.map +1 -1
- package/esm/src/next/files/route.js +11 -11
- package/esm/src/next/files/route.js.map +1 -0
- package/esm/src/next/jobs/list.d.ts +5 -5
- package/esm/src/next/jobs/list.d.ts.map +1 -1
- package/esm/src/next/jobs/list.js +15 -19
- package/esm/src/next/jobs/list.js.map +1 -0
- package/esm/src/next/jobs/mod.d.ts.map +1 -1
- package/esm/src/next/jobs/mod.js +1 -0
- package/esm/src/next/jobs/mod.js.map +1 -0
- package/esm/src/next/jobs/paths.d.ts +2 -2
- package/esm/src/next/jobs/paths.d.ts.map +1 -1
- package/esm/src/next/jobs/paths.js +1 -0
- package/esm/src/next/jobs/paths.js.map +1 -0
- package/esm/src/next/jobs/route.d.ts +2 -2
- package/esm/src/next/jobs/route.d.ts.map +1 -1
- package/esm/src/next/jobs/route.js +4 -4
- package/esm/src/next/jobs/route.js.map +1 -0
- package/esm/src/next/jobs/run.d.ts +2 -2
- package/esm/src/next/jobs/run.d.ts.map +1 -1
- package/esm/src/next/jobs/run.js +68 -132
- package/esm/src/next/jobs/run.js.map +1 -0
- package/esm/src/next/jobs/runRequest.d.ts +1 -1
- package/esm/src/next/jobs/runRequest.d.ts.map +1 -1
- package/esm/src/next/jobs/runRequest.js +3 -4
- package/esm/src/next/jobs/runRequest.js.map +1 -0
- package/esm/src/next/jobs/stream.d.ts.map +1 -1
- package/esm/src/next/jobs/stream.js +1 -0
- package/esm/src/next/jobs/stream.js.map +1 -0
- package/esm/src/next/mail/mod.d.ts +0 -1
- package/esm/src/next/mail/mod.d.ts.map +1 -1
- package/esm/src/next/mail/mod.js +1 -1
- package/esm/src/next/mail/mod.js.map +1 -0
- package/esm/src/next/mail/route.d.ts +2 -2
- package/esm/src/next/mail/route.d.ts.map +1 -1
- package/esm/src/next/mail/route.js +1 -0
- package/esm/src/next/mail/route.js.map +1 -0
- package/esm/src/next/pwa/mod.d.ts +0 -4
- package/esm/src/next/pwa/mod.d.ts.map +1 -1
- package/esm/src/next/pwa/mod.js +32 -16
- package/esm/src/next/pwa/mod.js.map +1 -0
- package/esm/src/next/pwa/worker.d.ts +0 -1
- package/esm/src/next/pwa/worker.d.ts.map +1 -1
- package/esm/src/next/pwa/worker.js +1 -0
- package/esm/src/next/pwa/worker.js.map +1 -0
- package/esm/src/next/secrets/constants.d.ts +3 -0
- package/esm/src/next/secrets/constants.d.ts.map +1 -0
- package/esm/src/next/secrets/constants.js +3 -0
- package/esm/src/next/secrets/constants.js.map +1 -0
- package/esm/src/next/secrets/mod.d.ts +1 -3
- package/esm/src/next/secrets/mod.d.ts.map +1 -1
- package/esm/src/next/secrets/mod.js +6 -7
- package/esm/src/next/secrets/mod.js.map +1 -0
- package/esm/src/next/sourceDev.d.ts +6 -0
- package/esm/src/next/sourceDev.d.ts.map +1 -0
- package/esm/src/next/sourceDev.js +41 -0
- package/esm/src/next/sourceDev.js.map +1 -0
- package/esm/src/secrets/encoding.d.ts.map +1 -1
- package/esm/src/secrets/encoding.js +1 -0
- package/esm/src/secrets/encoding.js.map +1 -0
- package/esm/src/secrets/errors.d.ts.map +1 -1
- package/esm/src/secrets/errors.js +3 -7
- package/esm/src/secrets/errors.js.map +1 -0
- package/esm/src/secrets/fingerprint.d.ts.map +1 -1
- package/esm/src/secrets/fingerprint.js +1 -0
- package/esm/src/secrets/fingerprint.js.map +1 -0
- package/esm/src/secrets/frame.d.ts.map +1 -1
- package/esm/src/secrets/frame.js +4 -3
- package/esm/src/secrets/frame.js.map +1 -0
- package/esm/src/secrets/keyring.d.ts.map +1 -1
- package/esm/src/secrets/keyring.js +6 -6
- package/esm/src/secrets/keyring.js.map +1 -0
- package/esm/src/secrets/legacy.d.ts +0 -1
- package/esm/src/secrets/legacy.d.ts.map +1 -1
- package/esm/src/secrets/legacy.js +13 -10
- package/esm/src/secrets/legacy.js.map +1 -0
- package/esm/src/secrets/maintenance.d.ts +0 -1
- package/esm/src/secrets/maintenance.d.ts.map +1 -1
- package/esm/src/secrets/maintenance.js +9 -24
- package/esm/src/secrets/maintenance.js.map +1 -0
- package/esm/src/secrets/mod.d.ts +0 -1
- package/esm/src/secrets/mod.d.ts.map +1 -1
- package/esm/src/secrets/mod.js +1 -1
- package/esm/src/secrets/mod.js.map +1 -0
- package/esm/src/secrets/secrets.d.ts.map +1 -1
- package/esm/src/secrets/secrets.js +38 -30
- package/esm/src/secrets/secrets.js.map +1 -0
- package/package.json +111 -135
- package/skills/loom/SKILL.md +40 -5
- package/skills/loom/references/esm-package.md +35 -0
- package/skills/loom/references/local-development.md +261 -29
- package/skills/loom-mail/SKILL.md +1 -0
- package/skills/upgrade-deps/SKILL.md +4 -2
- package/source/bin/loom.ts +50 -0
- package/source/mod.ts +10 -0
- package/source/src/apiKeys/authorize.ts +294 -0
- package/source/src/apiKeys/betterAuth.ts +253 -0
- package/source/src/apiKeys/country.ts +7 -0
- package/source/src/apiKeys/credentials.ts +171 -0
- package/source/src/apiKeys/fingerprint.ts +10 -0
- package/{script/src/apiKeys/lifecycle.d.ts → source/src/apiKeys/lifecycle.ts} +21 -23
- package/source/src/apiKeys/limits.ts +372 -0
- package/source/src/apiKeys/mod.ts +11 -0
- package/source/src/apiKeys/permissions.ts +153 -0
- package/source/src/apiKeys/policy.ts +189 -0
- package/source/src/apiKeys/retention.ts +136 -0
- package/source/src/apiKeys/types.ts +288 -0
- package/source/src/cli/atomicText.ts +38 -0
- package/source/src/cli/bunLocalDev.ts +646 -0
- package/source/src/cli/bunProject.ts +433 -0
- package/source/src/cli/cliBootstrap.ts +313 -0
- package/source/src/cli/externalSkills.ts +315 -0
- package/source/src/cli/filesR2Policy.ts +212 -0
- package/source/src/cli/generatedBuild.ts +380 -0
- package/source/src/cli/generatedCleanup.ts +87 -0
- package/source/src/cli/generatedDevLease.ts +52 -0
- package/source/src/cli/generatedInstall.ts +630 -0
- package/source/src/cli/generatedWorkflow.ts +135 -0
- package/{script/src/cli/legacyManagedOutputs.js → source/src/cli/legacyManagedOutputs.ts} +36 -30
- package/source/src/cli/localDb.ts +548 -0
- package/source/src/cli/localDevLock.ts +462 -0
- package/source/src/cli/localDevPackage.ts +754 -0
- package/source/src/cli/managedFiles.ts +688 -0
- package/source/src/cli/migrationEnv.ts +267 -0
- package/source/src/cli/mod.ts +26788 -0
- package/source/src/cli/packageTreeSignature.ts +65 -0
- package/source/src/cli/processIdentity.ts +38 -0
- package/source/src/cli/projectSkills.ts +1102 -0
- package/source/src/cli/projectTooling.ts +1140 -0
- package/source/src/cli/releaseConfig.ts +36 -0
- package/source/src/cli/releaseCredentials.ts +642 -0
- package/source/src/cli/releaseTrust.ts +194 -0
- package/source/src/cli/releaseTrustCommand.ts +210 -0
- package/source/src/cli/sourceConfig.ts +106 -0
- package/source/src/cli/sourceDev.ts +1279 -0
- package/source/src/cli/vercelBuildEnv.ts +714 -0
- package/source/src/cli/vercelEnvMask.ts +182 -0
- package/source/src/cli/vercelProjectRelease.ts +807 -0
- package/source/src/cli/vercelPulledEnv.ts +174 -0
- package/source/src/clientData/identity.ts +229 -0
- package/source/src/clientData/mod.ts +1 -0
- package/source/src/files/client.ts +75 -0
- package/source/src/files/errors.ts +69 -0
- package/source/src/files/hash.ts +109 -0
- package/source/src/files/memory.ts +158 -0
- package/source/src/files/metadata.ts +251 -0
- package/source/src/files/mod.ts +8 -0
- package/source/src/files/s3.ts +182 -0
- package/source/src/files/service.ts +210 -0
- package/source/src/files/types.ts +171 -0
- package/source/src/jobs/catalog.ts +303 -0
- package/source/src/jobs/controller.ts +156 -0
- package/source/src/jobs/direct.ts +177 -0
- package/source/src/jobs/events.ts +74 -0
- package/source/src/jobs/format.ts +233 -0
- package/source/src/jobs/http.ts +83 -0
- package/source/src/jobs/log.ts +10 -0
- package/source/src/jobs/mod.ts +10 -0
- package/source/src/jobs/run.ts +141 -0
- package/source/src/jobs/sanitize.ts +142 -0
- package/source/src/jobs/types.ts +43 -0
- package/source/src/mail/errors.ts +77 -0
- package/source/src/mail/memory.ts +451 -0
- package/source/src/mail/mod.ts +5 -0
- package/source/src/mail/postal.ts +363 -0
- package/source/src/mail/retry.ts +30 -0
- package/source/src/mail/sender.ts +57 -0
- package/source/src/mail/service.ts +252 -0
- package/source/src/mail/types.ts +229 -0
- package/source/src/mui/apiKeys.tsx +1044 -0
- package/source/src/mui/apiKeysView.ts +535 -0
- package/source/src/mui/confirm.tsx +138 -0
- package/source/src/mui/mail.tsx +279 -0
- package/source/src/mui/mailView.ts +50 -0
- package/source/src/mui/mod.ts +3 -0
- package/source/src/next/apiKeys/mod.ts +393 -0
- package/{script/src/next/auth/client.d.ts → source/src/next/auth/client.ts} +19 -5
- package/source/src/next/auth/config.ts +207 -0
- package/source/src/next/auth/localTestLogin.ts +412 -0
- package/source/src/next/auth/mod.ts +3 -0
- package/source/src/next/auth/server.ts +94 -0
- package/source/src/next/files/mod.ts +1 -0
- package/source/src/next/files/route.ts +621 -0
- package/source/src/next/jobs/list.tsx +90 -0
- package/source/src/next/jobs/mod.ts +5 -0
- package/source/src/next/jobs/paths.ts +70 -0
- package/source/src/next/jobs/route.ts +207 -0
- package/source/src/next/jobs/run.tsx +888 -0
- package/source/src/next/jobs/runRequest.ts +92 -0
- package/source/src/next/jobs/stream.ts +33 -0
- package/source/src/next/mail/mod.ts +1 -0
- package/source/src/next/mail/route.ts +75 -0
- package/source/src/next/pwa/mod.tsx +453 -0
- package/source/src/next/pwa/worker.ts +59 -0
- package/source/src/next/secrets/constants.ts +2 -0
- package/source/src/next/secrets/mod.ts +319 -0
- package/source/src/next/sourceDev.ts +50 -0
- package/source/src/secrets/encoding.ts +102 -0
- package/source/src/secrets/errors.ts +58 -0
- package/source/src/secrets/fingerprint.ts +132 -0
- package/source/src/secrets/frame.ts +119 -0
- package/source/src/secrets/keyring.ts +225 -0
- package/source/src/secrets/legacy.ts +244 -0
- package/source/src/secrets/maintenance.ts +517 -0
- package/source/src/secrets/mod.ts +38 -0
- package/source/src/secrets/secrets.ts +926 -0
- package/db/databaseTls.test.ts +0 -171
- package/db/databaseUrl.test.ts +0 -72
- package/db/neonEndpoint.test.ts +0 -51
- package/db/testing.test.ts +0 -28
- package/deno.json +0 -3
- package/esm/_dnt.polyfills.d.ts +0 -166
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -177
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/package.json +0 -3
- package/script/_dnt.polyfills.d.ts +0 -166
- package/script/_dnt.polyfills.d.ts.map +0 -1
- package/script/_dnt.polyfills.js +0 -180
- package/script/_dnt.shims.d.ts +0 -2
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -60
- package/script/bin/loom.d.ts +0 -2
- package/script/bin/loom.d.ts.map +0 -1
- package/script/bin/loom.js +0 -17
- package/script/mod.d.ts +0 -12
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -27
- package/script/package.json +0 -3
- package/script/src/apiKeys/authorize.d.ts +0 -4
- package/script/src/apiKeys/authorize.d.ts.map +0 -1
- package/script/src/apiKeys/authorize.js +0 -258
- package/script/src/apiKeys/betterAuth.d.ts +0 -123
- package/script/src/apiKeys/betterAuth.d.ts.map +0 -1
- package/script/src/apiKeys/betterAuth.js +0 -169
- package/script/src/apiKeys/country.d.ts +0 -3
- package/script/src/apiKeys/country.d.ts.map +0 -1
- package/script/src/apiKeys/country.js +0 -10
- package/script/src/apiKeys/credentials.d.ts +0 -39
- package/script/src/apiKeys/credentials.d.ts.map +0 -1
- package/script/src/apiKeys/credentials.js +0 -121
- package/script/src/apiKeys/fingerprint.d.ts +0 -3
- package/script/src/apiKeys/fingerprint.d.ts.map +0 -1
- package/script/src/apiKeys/fingerprint.js +0 -8
- package/script/src/apiKeys/lifecycle.d.ts.map +0 -1
- package/script/src/apiKeys/lifecycle.js +0 -7
- package/script/src/apiKeys/limits.d.ts +0 -132
- package/script/src/apiKeys/limits.d.ts.map +0 -1
- package/script/src/apiKeys/limits.js +0 -254
- package/script/src/apiKeys/mod.d.ts +0 -13
- package/script/src/apiKeys/mod.d.ts.map +0 -1
- package/script/src/apiKeys/mod.js +0 -28
- package/script/src/apiKeys/permissions.d.ts +0 -56
- package/script/src/apiKeys/permissions.d.ts.map +0 -1
- package/script/src/apiKeys/permissions.js +0 -136
- package/script/src/apiKeys/policy.d.ts +0 -61
- package/script/src/apiKeys/policy.d.ts.map +0 -1
- package/script/src/apiKeys/policy.js +0 -94
- package/script/src/apiKeys/retention.d.ts +0 -55
- package/script/src/apiKeys/retention.d.ts.map +0 -1
- package/script/src/apiKeys/retention.js +0 -70
- package/script/src/apiKeys/types.d.ts +0 -242
- package/script/src/apiKeys/types.d.ts.map +0 -1
- package/script/src/apiKeys/types.js +0 -2
- package/script/src/cli/externalSkills.d.ts +0 -39
- package/script/src/cli/externalSkills.d.ts.map +0 -1
- package/script/src/cli/externalSkills.js +0 -204
- package/script/src/cli/filesR2Policy.d.ts +0 -33
- package/script/src/cli/filesR2Policy.d.ts.map +0 -1
- package/script/src/cli/filesR2Policy.js +0 -135
- package/script/src/cli/legacyManagedOutputs.d.ts +0 -33
- package/script/src/cli/legacyManagedOutputs.d.ts.map +0 -1
- package/script/src/cli/localDb.d.ts +0 -28
- package/script/src/cli/localDb.d.ts.map +0 -1
- package/script/src/cli/localDb.js +0 -370
- package/script/src/cli/localDevLock.d.ts +0 -97
- package/script/src/cli/localDevLock.d.ts.map +0 -1
- package/script/src/cli/localDevLock.js +0 -320
- package/script/src/cli/localDevPackage.d.ts +0 -172
- package/script/src/cli/localDevPackage.d.ts.map +0 -1
- package/script/src/cli/localDevPackage.js +0 -635
- package/script/src/cli/managedFiles.d.ts +0 -131
- package/script/src/cli/managedFiles.d.ts.map +0 -1
- package/script/src/cli/managedFiles.js +0 -536
- package/script/src/cli/migrationEnv.d.ts +0 -63
- package/script/src/cli/migrationEnv.d.ts.map +0 -1
- package/script/src/cli/migrationEnv.js +0 -217
- package/script/src/cli/mod.d.ts +0 -582
- package/script/src/cli/mod.d.ts.map +0 -1
- package/script/src/cli/mod.js +0 -17010
- package/script/src/cli/projectSkills.d.ts +0 -109
- package/script/src/cli/projectSkills.d.ts.map +0 -1
- package/script/src/cli/projectSkills.js +0 -749
- package/script/src/cli/projectTooling.d.ts +0 -164
- package/script/src/cli/projectTooling.d.ts.map +0 -1
- package/script/src/cli/projectTooling.js +0 -847
- package/script/src/cli/releaseConfig.d.ts +0 -10
- package/script/src/cli/releaseConfig.d.ts.map +0 -1
- package/script/src/cli/releaseConfig.js +0 -26
- package/script/src/cli/releaseCredentials.d.ts +0 -32
- package/script/src/cli/releaseCredentials.d.ts.map +0 -1
- package/script/src/cli/releaseCredentials.js +0 -392
- package/script/src/cli/releaseTrust.d.ts +0 -39
- package/script/src/cli/releaseTrust.d.ts.map +0 -1
- package/script/src/cli/releaseTrust.js +0 -130
- package/script/src/cli/releaseTrustCommand.d.ts +0 -18
- package/script/src/cli/releaseTrustCommand.d.ts.map +0 -1
- package/script/src/cli/releaseTrustCommand.js +0 -145
- package/script/src/cli/vercelBuildEnv.d.ts +0 -62
- package/script/src/cli/vercelBuildEnv.d.ts.map +0 -1
- package/script/src/cli/vercelBuildEnv.js +0 -418
- package/script/src/cli/vercelEnvMask.d.ts +0 -38
- package/script/src/cli/vercelEnvMask.d.ts.map +0 -1
- package/script/src/cli/vercelEnvMask.js +0 -142
- package/script/src/cli/vercelProjectRelease.d.ts +0 -38
- package/script/src/cli/vercelProjectRelease.d.ts.map +0 -1
- package/script/src/cli/vercelProjectRelease.js +0 -607
- package/script/src/cli/vercelPulledEnv.d.ts +0 -65
- package/script/src/cli/vercelPulledEnv.d.ts.map +0 -1
- package/script/src/cli/vercelPulledEnv.js +0 -138
- package/script/src/clientData/identity.d.ts +0 -89
- package/script/src/clientData/identity.d.ts.map +0 -1
- package/script/src/clientData/identity.js +0 -134
- package/script/src/clientData/mod.d.ts +0 -3
- package/script/src/clientData/mod.d.ts.map +0 -1
- package/script/src/clientData/mod.js +0 -18
- package/script/src/files/client.d.ts +0 -29
- package/script/src/files/client.d.ts.map +0 -1
- package/script/src/files/client.js +0 -45
- package/script/src/files/errors.d.ts +0 -37
- package/script/src/files/errors.d.ts.map +0 -1
- package/script/src/files/errors.js +0 -76
- package/script/src/files/hash.d.ts +0 -15
- package/script/src/files/hash.d.ts.map +0 -1
- package/script/src/files/hash.js +0 -89
- package/script/src/files/memory.d.ts +0 -29
- package/script/src/files/memory.d.ts.map +0 -1
- package/script/src/files/memory.js +0 -113
- package/script/src/files/metadata.d.ts +0 -10
- package/script/src/files/metadata.d.ts.map +0 -1
- package/script/src/files/metadata.js +0 -189
- package/script/src/files/mod.d.ts +0 -10
- package/script/src/files/mod.d.ts.map +0 -1
- package/script/src/files/mod.js +0 -25
- package/script/src/files/s3.d.ts +0 -29
- package/script/src/files/s3.d.ts.map +0 -1
- package/script/src/files/s3.js +0 -110
- package/script/src/files/service.d.ts +0 -27
- package/script/src/files/service.d.ts.map +0 -1
- package/script/src/files/service.js +0 -139
- package/script/src/files/types.d.ts +0 -134
- package/script/src/files/types.d.ts.map +0 -1
- package/script/src/files/types.js +0 -2
- package/script/src/jobs/catalog.d.ts +0 -32
- package/script/src/jobs/catalog.d.ts.map +0 -1
- package/script/src/jobs/catalog.js +0 -223
- package/script/src/jobs/controller.d.ts +0 -41
- package/script/src/jobs/controller.d.ts.map +0 -1
- package/script/src/jobs/controller.js +0 -151
- package/script/src/jobs/direct.d.ts +0 -36
- package/script/src/jobs/direct.d.ts.map +0 -1
- package/script/src/jobs/direct.js +0 -128
- package/script/src/jobs/events.d.ts +0 -23
- package/script/src/jobs/events.d.ts.map +0 -1
- package/script/src/jobs/events.js +0 -50
- package/script/src/jobs/format.d.ts +0 -16
- package/script/src/jobs/format.d.ts.map +0 -1
- package/script/src/jobs/format.js +0 -193
- package/script/src/jobs/http.d.ts +0 -22
- package/script/src/jobs/http.d.ts.map +0 -1
- package/script/src/jobs/http.js +0 -50
- package/script/src/jobs/log.d.ts +0 -2
- package/script/src/jobs/log.d.ts.map +0 -1
- package/script/src/jobs/log.js +0 -13
- package/script/src/jobs/mod.d.ts +0 -11
- package/script/src/jobs/mod.d.ts.map +0 -1
- package/script/src/jobs/mod.js +0 -26
- package/script/src/jobs/run.d.ts +0 -39
- package/script/src/jobs/run.d.ts.map +0 -1
- package/script/src/jobs/run.js +0 -86
- package/script/src/jobs/sanitize.d.ts +0 -30
- package/script/src/jobs/sanitize.d.ts.map +0 -1
- package/script/src/jobs/sanitize.js +0 -97
- package/script/src/jobs/types.d.ts +0 -31
- package/script/src/jobs/types.d.ts.map +0 -1
- package/script/src/jobs/types.js +0 -2
- package/script/src/mail/errors.d.ts +0 -33
- package/script/src/mail/errors.d.ts.map +0 -1
- package/script/src/mail/errors.js +0 -97
- package/script/src/mail/memory.d.ts +0 -30
- package/script/src/mail/memory.d.ts.map +0 -1
- package/script/src/mail/memory.js +0 -345
- package/script/src/mail/mod.d.ts +0 -7
- package/script/src/mail/mod.d.ts.map +0 -1
- package/script/src/mail/mod.js +0 -22
- package/script/src/mail/postal.d.ts +0 -57
- package/script/src/mail/postal.d.ts.map +0 -1
- package/script/src/mail/postal.js +0 -251
- package/script/src/mail/retry.d.ts +0 -9
- package/script/src/mail/retry.d.ts.map +0 -1
- package/script/src/mail/retry.js +0 -22
- package/script/src/mail/sender.d.ts +0 -5
- package/script/src/mail/sender.d.ts.map +0 -1
- package/script/src/mail/sender.js +0 -52
- package/script/src/mail/service.d.ts +0 -23
- package/script/src/mail/service.d.ts.map +0 -1
- package/script/src/mail/service.js +0 -191
- package/script/src/mail/types.d.ts +0 -176
- package/script/src/mail/types.d.ts.map +0 -1
- package/script/src/mail/types.js +0 -2
- package/script/src/mui/apiKeys.d.ts +0 -171
- package/script/src/mui/apiKeys.d.ts.map +0 -1
- package/script/src/mui/apiKeys.js +0 -470
- package/script/src/mui/apiKeysView.d.ts +0 -193
- package/script/src/mui/apiKeysView.d.ts.map +0 -1
- package/script/src/mui/apiKeysView.js +0 -331
- package/script/src/mui/confirm.d.ts +0 -12
- package/script/src/mui/confirm.d.ts.map +0 -1
- package/script/src/mui/confirm.js +0 -85
- package/script/src/mui/mail.d.ts +0 -29
- package/script/src/mui/mail.d.ts.map +0 -1
- package/script/src/mui/mail.js +0 -159
- package/script/src/mui/mailView.d.ts +0 -20
- package/script/src/mui/mailView.d.ts.map +0 -1
- package/script/src/mui/mailView.js +0 -32
- package/script/src/mui/mod.d.ts +0 -5
- package/script/src/mui/mod.d.ts.map +0 -1
- package/script/src/mui/mod.js +0 -20
- package/script/src/next/apiKeys/mod.d.ts +0 -71
- package/script/src/next/apiKeys/mod.d.ts.map +0 -1
- package/script/src/next/apiKeys/mod.js +0 -227
- package/script/src/next/auth/client.d.ts.map +0 -1
- package/script/src/next/auth/client.js +0 -39
- package/script/src/next/auth/config.d.ts +0 -62
- package/script/src/next/auth/config.d.ts.map +0 -1
- package/script/src/next/auth/config.js +0 -178
- package/script/src/next/auth/localTestLogin.d.ts +0 -75
- package/script/src/next/auth/localTestLogin.d.ts.map +0 -1
- package/script/src/next/auth/localTestLogin.js +0 -291
- package/script/src/next/auth/mod.d.ts +0 -4
- package/script/src/next/auth/mod.d.ts.map +0 -1
- package/script/src/next/auth/mod.js +0 -19
- package/script/src/next/auth/server.d.ts +0 -44
- package/script/src/next/auth/server.d.ts.map +0 -1
- package/script/src/next/auth/server.js +0 -39
- package/script/src/next/files/mod.d.ts +0 -3
- package/script/src/next/files/mod.d.ts.map +0 -1
- package/script/src/next/files/mod.js +0 -18
- package/script/src/next/files/route.d.ts +0 -99
- package/script/src/next/files/route.d.ts.map +0 -1
- package/script/src/next/files/route.js +0 -353
- package/script/src/next/jobs/list.d.ts +0 -25
- package/script/src/next/jobs/list.d.ts.map +0 -1
- package/script/src/next/jobs/list.js +0 -48
- package/script/src/next/jobs/mod.d.ts +0 -6
- package/script/src/next/jobs/mod.d.ts.map +0 -1
- package/script/src/next/jobs/mod.js +0 -21
- package/script/src/next/jobs/paths.d.ts +0 -14
- package/script/src/next/jobs/paths.d.ts.map +0 -1
- package/script/src/next/jobs/paths.js +0 -47
- package/script/src/next/jobs/route.d.ts +0 -48
- package/script/src/next/jobs/route.d.ts.map +0 -1
- package/script/src/next/jobs/route.js +0 -105
- package/script/src/next/jobs/run.d.ts +0 -58
- package/script/src/next/jobs/run.d.ts.map +0 -1
- package/script/src/next/jobs/run.js +0 -592
- package/script/src/next/jobs/runRequest.d.ts +0 -19
- package/script/src/next/jobs/runRequest.d.ts.map +0 -1
- package/script/src/next/jobs/runRequest.js +0 -81
- package/script/src/next/jobs/stream.d.ts +0 -3
- package/script/src/next/jobs/stream.d.ts.map +0 -1
- package/script/src/next/jobs/stream.js +0 -28
- package/script/src/next/mail/mod.d.ts +0 -3
- package/script/src/next/mail/mod.d.ts.map +0 -1
- package/script/src/next/mail/mod.js +0 -18
- package/script/src/next/mail/route.d.ts +0 -12
- package/script/src/next/mail/route.d.ts.map +0 -1
- package/script/src/next/mail/route.js +0 -46
- package/script/src/next/pwa/mod.d.ts +0 -112
- package/script/src/next/pwa/mod.d.ts.map +0 -1
- package/script/src/next/pwa/mod.js +0 -303
- package/script/src/next/pwa/worker.d.ts +0 -27
- package/script/src/next/pwa/worker.d.ts.map +0 -1
- package/script/src/next/pwa/worker.js +0 -33
- package/script/src/next/secrets/mod.d.ts +0 -108
- package/script/src/next/secrets/mod.d.ts.map +0 -1
- package/script/src/next/secrets/mod.js +0 -218
- package/script/src/secrets/encoding.d.ts +0 -32
- package/script/src/secrets/encoding.d.ts.map +0 -1
- package/script/src/secrets/encoding.js +0 -95
- package/script/src/secrets/errors.d.ts +0 -45
- package/script/src/secrets/errors.d.ts.map +0 -1
- package/script/src/secrets/errors.js +0 -45
- package/script/src/secrets/fingerprint.d.ts +0 -43
- package/script/src/secrets/fingerprint.d.ts.map +0 -1
- package/script/src/secrets/fingerprint.js +0 -92
- package/script/src/secrets/frame.d.ts +0 -34
- package/script/src/secrets/frame.d.ts.map +0 -1
- package/script/src/secrets/frame.js +0 -91
- package/script/src/secrets/keyring.d.ts +0 -62
- package/script/src/secrets/keyring.d.ts.map +0 -1
- package/script/src/secrets/keyring.js +0 -202
- package/script/src/secrets/legacy.d.ts +0 -60
- package/script/src/secrets/legacy.d.ts.map +0 -1
- package/script/src/secrets/legacy.js +0 -186
- package/script/src/secrets/maintenance.d.ts +0 -173
- package/script/src/secrets/maintenance.d.ts.map +0 -1
- package/script/src/secrets/maintenance.js +0 -323
- package/script/src/secrets/mod.d.ts +0 -6
- package/script/src/secrets/mod.d.ts.map +0 -1
- package/script/src/secrets/mod.js +0 -24
- package/script/src/secrets/secrets.d.ts +0 -192
- package/script/src/secrets/secrets.d.ts.map +0 -1
- package/script/src/secrets/secrets.js +0 -532
|
@@ -0,0 +1,1140 @@
|
|
|
1
|
+
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { replaceTextAtomically } from "./atomicText.ts";
|
|
4
|
+
|
|
5
|
+
import * as jsoncParserNamespace from "jsonc-parser";
|
|
6
|
+
import type { FormattingOptions, ParseError } from "jsonc-parser";
|
|
7
|
+
|
|
8
|
+
type JsoncParser = typeof jsoncParserNamespace;
|
|
9
|
+
// A static import, not a lazy createRequire(), so jsonc-parser is part of
|
|
10
|
+
// every module graph that reaches these exported helpers. It is UMD without
|
|
11
|
+
// an `exports` map: Node's ESM loader exposes its named exports only when
|
|
12
|
+
// cjs-module-lexer recognises them, so fall back to the CommonJS object that
|
|
13
|
+
// it always provides as `default`.
|
|
14
|
+
const jsoncParser: JsoncParser =
|
|
15
|
+
typeof jsoncParserNamespace.modify === "function"
|
|
16
|
+
? jsoncParserNamespace
|
|
17
|
+
: (jsoncParserNamespace as unknown as { default: JsoncParser }).default;
|
|
18
|
+
|
|
19
|
+
export type PackageManager = "bun" | "deno" | "npm" | "pnpm" | "yarn";
|
|
20
|
+
export type TaskRunner = PackageManager;
|
|
21
|
+
export type TaskConfigPath = "deno.json" | "deno.jsonc" | "package.json";
|
|
22
|
+
export type DependencyConfigPath = TaskConfigPath;
|
|
23
|
+
|
|
24
|
+
/** The persisted project-level owners for tasks and dependencies. */
|
|
25
|
+
export type ProjectTooling = {
|
|
26
|
+
dependencies: {
|
|
27
|
+
config: DependencyConfigPath;
|
|
28
|
+
manager: PackageManager;
|
|
29
|
+
};
|
|
30
|
+
tasks: {
|
|
31
|
+
config: TaskConfigPath;
|
|
32
|
+
runner: TaskRunner;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type DenoTaskDefinition =
|
|
37
|
+
| string
|
|
38
|
+
| ({
|
|
39
|
+
command?: string;
|
|
40
|
+
dependencies?: string[];
|
|
41
|
+
description?: string;
|
|
42
|
+
env?: string[];
|
|
43
|
+
files?: string[];
|
|
44
|
+
output?: string[];
|
|
45
|
+
} & Record<string, unknown>);
|
|
46
|
+
|
|
47
|
+
export type TaskDefinition = DenoTaskDefinition;
|
|
48
|
+
|
|
49
|
+
export type ProjectPackageJson = {
|
|
50
|
+
dependencies?: Record<string, string>;
|
|
51
|
+
devDependencies?: Record<string, string>;
|
|
52
|
+
name?: string;
|
|
53
|
+
packageManager?: string;
|
|
54
|
+
pnpm?: Record<string, unknown>;
|
|
55
|
+
resolutions?: Record<string, unknown>;
|
|
56
|
+
scripts?: Record<string, string>;
|
|
57
|
+
version?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type DenoJson = {
|
|
61
|
+
imports?: Record<string, string>;
|
|
62
|
+
links?: string[];
|
|
63
|
+
name?: string;
|
|
64
|
+
nodeModulesDir?: "auto" | "manual" | "none";
|
|
65
|
+
preferPackageJson?: boolean;
|
|
66
|
+
tasks?: Record<string, DenoTaskDefinition>;
|
|
67
|
+
version?: string;
|
|
68
|
+
} & Record<string, unknown>;
|
|
69
|
+
|
|
70
|
+
export type TaskStore = {
|
|
71
|
+
config: TaskConfigPath;
|
|
72
|
+
definitions: Record<string, TaskDefinition>;
|
|
73
|
+
rootKey: "scripts" | "tasks";
|
|
74
|
+
runner: TaskRunner;
|
|
75
|
+
text: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type TaskConflict = {
|
|
79
|
+
authoritative: TaskDefinition;
|
|
80
|
+
authoritativeConfig: TaskConfigPath;
|
|
81
|
+
name: string;
|
|
82
|
+
secondary: TaskDefinition;
|
|
83
|
+
secondaryConfig: TaskConfigPath;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type DependencyMutation = {
|
|
87
|
+
dependencies?: Record<string, string>;
|
|
88
|
+
devDependencies?: Record<string, string>;
|
|
89
|
+
remove?: readonly string[];
|
|
90
|
+
replace?: boolean;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
async function readTextIfExists(path: string) {
|
|
94
|
+
try {
|
|
95
|
+
return await readFile(path, "utf8");
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return null;
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Parses Deno JSON/JSONC while reporting every syntax error. */
|
|
103
|
+
export function parseJsonc<T>(text: string, filename: string): T {
|
|
104
|
+
const { parse, printParseErrorCode } = jsoncParser;
|
|
105
|
+
const errors: ParseError[] = [];
|
|
106
|
+
const value = parse(text, errors, {
|
|
107
|
+
allowEmptyContent: false,
|
|
108
|
+
allowTrailingComma: true,
|
|
109
|
+
disallowComments: false,
|
|
110
|
+
}) as T;
|
|
111
|
+
if (errors.length) {
|
|
112
|
+
const detail = errors
|
|
113
|
+
.map(
|
|
114
|
+
(error) =>
|
|
115
|
+
`${printParseErrorCode(error.error)} at offset ${error.offset}`,
|
|
116
|
+
)
|
|
117
|
+
.join(", ");
|
|
118
|
+
throw new Error(`Failed to parse ${filename}: ${detail}`);
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function parseStrictJson<T>(text: string, filename: string): T {
|
|
124
|
+
try {
|
|
125
|
+
return JSON.parse(text) as T;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
throw new Error(`Failed to parse ${filename}: ${(error as Error).message}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function formattingOptions(text: string): FormattingOptions {
|
|
132
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
133
|
+
const indentation = text.match(/(?:^|\r?\n)([\t ]+)\S/m)?.[1] ?? " ";
|
|
134
|
+
const insertSpaces = !indentation.includes("\t");
|
|
135
|
+
return {
|
|
136
|
+
eol,
|
|
137
|
+
insertFinalNewline: text.endsWith("\n"),
|
|
138
|
+
insertSpaces,
|
|
139
|
+
keepLines: true,
|
|
140
|
+
tabSize: insertSpaces ? Math.max(1, indentation.length) : 1,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function updateJsonPath(
|
|
145
|
+
text: string,
|
|
146
|
+
path: Array<string | number>,
|
|
147
|
+
value: unknown,
|
|
148
|
+
) {
|
|
149
|
+
const { applyEdits, modify } = jsoncParser;
|
|
150
|
+
return applyEdits(
|
|
151
|
+
text,
|
|
152
|
+
modify(text, path, value, { formattingOptions: formattingOptions(text) }),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function isPlainJsonObject(value: unknown): value is Record<string, unknown> {
|
|
157
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function sortedJson(value: unknown): unknown {
|
|
161
|
+
if (Array.isArray(value)) return value.map(sortedJson);
|
|
162
|
+
if (!isPlainJsonObject(value)) return value;
|
|
163
|
+
return Object.fromEntries(
|
|
164
|
+
Object.keys(value)
|
|
165
|
+
.filter((key) => value[key] !== undefined)
|
|
166
|
+
.sort()
|
|
167
|
+
.map((key) => [key, sortedJson(value[key])]),
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Compares JSON data, ignoring object key order and `undefined` members. */
|
|
172
|
+
export function jsonValuesEqual(left: unknown, right: unknown) {
|
|
173
|
+
return JSON.stringify(sortedJson(left)) === JSON.stringify(sortedJson(right));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function collectJsonEdits(
|
|
177
|
+
current: unknown,
|
|
178
|
+
next: unknown,
|
|
179
|
+
path: Array<string | number>,
|
|
180
|
+
edits: Array<[Array<string | number>, unknown]>,
|
|
181
|
+
) {
|
|
182
|
+
if (jsonValuesEqual(current, next)) return;
|
|
183
|
+
if (isPlainJsonObject(current) && isPlainJsonObject(next)) {
|
|
184
|
+
for (const key of Object.keys(current)) {
|
|
185
|
+
if (next[key] === undefined) edits.push([[...path, key], undefined]);
|
|
186
|
+
}
|
|
187
|
+
for (const [key, value] of Object.entries(next)) {
|
|
188
|
+
if (value === undefined) continue;
|
|
189
|
+
if (hasOwn(current, key)) {
|
|
190
|
+
collectJsonEdits(current[key], value, [...path, key], edits);
|
|
191
|
+
} else {
|
|
192
|
+
edits.push([[...path, key], value]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
edits.push([path, next]);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Rewrites JSON or JSONC text to hold `next` by editing only the members
|
|
202
|
+
* whose values changed, so the file keeps its own key order, indentation,
|
|
203
|
+
* line layout and comments. New members are appended to their object.
|
|
204
|
+
*/
|
|
205
|
+
export function patchJsonText(text: string, next: unknown) {
|
|
206
|
+
const edits: Array<[Array<string | number>, unknown]> = [];
|
|
207
|
+
collectJsonEdits(parseJsonc(text, "JSON"), next, [], edits);
|
|
208
|
+
return edits.reduce(
|
|
209
|
+
(result, [path, value]) => updateJsonPath(result, path, value),
|
|
210
|
+
text,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function hasOwn(value: object, key: PropertyKey) {
|
|
215
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function definitionsEqual(left: TaskDefinition, right: TaskDefinition) {
|
|
219
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function definitionsConflict(left: TaskDefinition, right: TaskDefinition) {
|
|
223
|
+
if (definitionsEqual(left, right)) return false;
|
|
224
|
+
const leftCommand = getTaskCommand(left);
|
|
225
|
+
const rightCommand = getTaskCommand(right);
|
|
226
|
+
if (leftCommand !== rightCommand) return true;
|
|
227
|
+
const leftDependencies = getTaskDependencies(left);
|
|
228
|
+
const rightDependencies = getTaskDependencies(right);
|
|
229
|
+
if (JSON.stringify(leftDependencies) !== JSON.stringify(rightDependencies)) {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
const executionKeys = ["env", "files", "output"] as const;
|
|
233
|
+
return executionKeys.some(
|
|
234
|
+
(key) =>
|
|
235
|
+
JSON.stringify(typeof left === "object" ? left[key] : undefined) !==
|
|
236
|
+
JSON.stringify(typeof right === "object" ? right[key] : undefined),
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function fileExists(path: string) {
|
|
241
|
+
try {
|
|
242
|
+
return (await stat(path)).isFile();
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return false;
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function packageManagerFromField(value: string | undefined) {
|
|
250
|
+
for (const manager of ["bun", "pnpm", "yarn", "npm", "deno"] as const) {
|
|
251
|
+
if (value?.startsWith(`${manager}@`)) return manager;
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async function detectDependencyManager(
|
|
257
|
+
cwd: string,
|
|
258
|
+
packageJson: ProjectPackageJson | null,
|
|
259
|
+
denoConfig: DenoJson | null,
|
|
260
|
+
): Promise<PackageManager> {
|
|
261
|
+
const declared = packageManagerFromField(packageJson?.packageManager);
|
|
262
|
+
if (declared) return declared;
|
|
263
|
+
// The historical binary lock is only an ownership signal; never decode it.
|
|
264
|
+
if (
|
|
265
|
+
packageJson &&
|
|
266
|
+
((await fileExists(join(cwd, "bun.lock"))) ||
|
|
267
|
+
(await fileExists(join(cwd, "bun.lockb"))))
|
|
268
|
+
)
|
|
269
|
+
return "bun";
|
|
270
|
+
if (await readTextIfExists(join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
271
|
+
if (await readTextIfExists(join(cwd, "yarn.lock"))) return "yarn";
|
|
272
|
+
if (await readTextIfExists(join(cwd, "package-lock.json"))) return "npm";
|
|
273
|
+
if (denoConfig || (await readTextIfExists(join(cwd, "deno.lock")))) {
|
|
274
|
+
return "deno";
|
|
275
|
+
}
|
|
276
|
+
return "npm";
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function validateRecordedTooling(
|
|
280
|
+
tooling: ProjectTooling,
|
|
281
|
+
available: Set<TaskConfigPath>,
|
|
282
|
+
) {
|
|
283
|
+
const configs = new Set<TaskConfigPath>([
|
|
284
|
+
"deno.json",
|
|
285
|
+
"deno.jsonc",
|
|
286
|
+
"package.json",
|
|
287
|
+
]);
|
|
288
|
+
const managers = new Set<PackageManager>([
|
|
289
|
+
"bun",
|
|
290
|
+
"deno",
|
|
291
|
+
"npm",
|
|
292
|
+
"pnpm",
|
|
293
|
+
"yarn",
|
|
294
|
+
]);
|
|
295
|
+
if (
|
|
296
|
+
!tooling ||
|
|
297
|
+
typeof tooling !== "object" ||
|
|
298
|
+
!tooling.tasks ||
|
|
299
|
+
typeof tooling.tasks !== "object" ||
|
|
300
|
+
!tooling.dependencies ||
|
|
301
|
+
typeof tooling.dependencies !== "object" ||
|
|
302
|
+
!configs.has(tooling.tasks.config) ||
|
|
303
|
+
!configs.has(tooling.dependencies.config) ||
|
|
304
|
+
!managers.has(tooling.tasks.runner) ||
|
|
305
|
+
!managers.has(tooling.dependencies.manager)
|
|
306
|
+
) {
|
|
307
|
+
throw new Error("loom.json records invalid project tooling.");
|
|
308
|
+
}
|
|
309
|
+
if (!available.has(tooling.tasks.config)) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`loom.json records missing task config: ${tooling.tasks.config}`,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
if (!available.has(tooling.dependencies.config)) {
|
|
315
|
+
throw new Error(
|
|
316
|
+
`loom.json records missing dependency config: ${tooling.dependencies.config}`,
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
if (
|
|
320
|
+
tooling.tasks.config !== "package.json" &&
|
|
321
|
+
tooling.tasks.runner !== "deno"
|
|
322
|
+
) {
|
|
323
|
+
throw new Error(
|
|
324
|
+
`${tooling.tasks.config} tasks must use the deno task runner.`,
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
if (
|
|
328
|
+
tooling.dependencies.config !== "package.json" &&
|
|
329
|
+
tooling.dependencies.manager !== "deno"
|
|
330
|
+
) {
|
|
331
|
+
throw new Error(
|
|
332
|
+
`${tooling.dependencies.config} dependencies must use the deno manager.`,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Detects project tooling once during adoption. A recorded Loom choice is
|
|
339
|
+
* authoritative on later runs and is validated instead of inferred again.
|
|
340
|
+
*/
|
|
341
|
+
export async function detectProjectTooling(
|
|
342
|
+
cwd: string,
|
|
343
|
+
recorded?: ProjectTooling,
|
|
344
|
+
): Promise<ProjectTooling> {
|
|
345
|
+
const packageText = await readTextIfExists(join(cwd, "package.json"));
|
|
346
|
+
const denoText = await readTextIfExists(join(cwd, "deno.json"));
|
|
347
|
+
const denoJsoncText = await readTextIfExists(join(cwd, "deno.jsonc"));
|
|
348
|
+
if (denoText !== null && denoJsoncText !== null) {
|
|
349
|
+
throw new Error(
|
|
350
|
+
"Both deno.json and deno.jsonc exist. Keep one Deno config or record a single unambiguous project config before running Loom.",
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
if (packageText === null && denoText === null && denoJsoncText === null) {
|
|
354
|
+
throw new Error(
|
|
355
|
+
`No package.json, deno.json, or deno.jsonc found in ${cwd}`,
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const denoConfigPath: "deno.json" | "deno.jsonc" | null =
|
|
360
|
+
denoText !== null
|
|
361
|
+
? "deno.json"
|
|
362
|
+
: denoJsoncText !== null
|
|
363
|
+
? "deno.jsonc"
|
|
364
|
+
: null;
|
|
365
|
+
const denoConfigText = denoText ?? denoJsoncText;
|
|
366
|
+
const packageJson =
|
|
367
|
+
packageText === null
|
|
368
|
+
? null
|
|
369
|
+
: parseStrictJson<ProjectPackageJson>(packageText, "package.json");
|
|
370
|
+
const denoConfig =
|
|
371
|
+
denoConfigText === null || !denoConfigPath
|
|
372
|
+
? null
|
|
373
|
+
: parseJsonc<DenoJson>(denoConfigText, denoConfigPath);
|
|
374
|
+
const available = new Set<TaskConfigPath>();
|
|
375
|
+
if (packageText !== null) available.add("package.json");
|
|
376
|
+
if (denoConfigPath) available.add(denoConfigPath);
|
|
377
|
+
if (recorded) {
|
|
378
|
+
validateRecordedTooling(recorded, available);
|
|
379
|
+
return recorded;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const dependencyManager = await detectDependencyManager(
|
|
383
|
+
cwd,
|
|
384
|
+
packageJson,
|
|
385
|
+
denoConfig,
|
|
386
|
+
);
|
|
387
|
+
const dependencyConfig: DependencyConfigPath = packageJson
|
|
388
|
+
? "package.json"
|
|
389
|
+
: denoConfigPath!;
|
|
390
|
+
const denoOwnsTasks = Boolean(denoConfig && hasOwn(denoConfig, "tasks"));
|
|
391
|
+
const taskConfig: TaskConfigPath =
|
|
392
|
+
denoOwnsTasks || !packageJson ? denoConfigPath! : "package.json";
|
|
393
|
+
const taskRunner: TaskRunner =
|
|
394
|
+
taskConfig === "package.json" ? dependencyManager : "deno";
|
|
395
|
+
|
|
396
|
+
return {
|
|
397
|
+
dependencies: {
|
|
398
|
+
config: dependencyConfig,
|
|
399
|
+
manager: dependencyManager,
|
|
400
|
+
},
|
|
401
|
+
tasks: {
|
|
402
|
+
config: taskConfig,
|
|
403
|
+
runner: taskRunner,
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Reads the task definitions from the recorded authoritative config. */
|
|
409
|
+
export async function readTaskStore(
|
|
410
|
+
cwd: string,
|
|
411
|
+
tooling: ProjectTooling["tasks"],
|
|
412
|
+
): Promise<TaskStore> {
|
|
413
|
+
const text = await readTextIfExists(join(cwd, tooling.config));
|
|
414
|
+
if (text === null) {
|
|
415
|
+
throw new Error(`Missing authoritative task config: ${tooling.config}`);
|
|
416
|
+
}
|
|
417
|
+
if (tooling.config === "package.json") {
|
|
418
|
+
const packageJson = parseStrictJson<ProjectPackageJson>(
|
|
419
|
+
text,
|
|
420
|
+
tooling.config,
|
|
421
|
+
);
|
|
422
|
+
const definitions = packageJson.scripts ?? {};
|
|
423
|
+
validateTaskDefinitions(definitions, tooling.config, false);
|
|
424
|
+
return {
|
|
425
|
+
config: tooling.config,
|
|
426
|
+
definitions,
|
|
427
|
+
rootKey: "scripts",
|
|
428
|
+
runner: tooling.runner,
|
|
429
|
+
text,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
const denoConfig = parseJsonc<DenoJson>(text, tooling.config);
|
|
433
|
+
const definitions = denoConfig.tasks ?? {};
|
|
434
|
+
validateTaskDefinitions(definitions, tooling.config, true);
|
|
435
|
+
return {
|
|
436
|
+
config: tooling.config,
|
|
437
|
+
definitions,
|
|
438
|
+
rootKey: "tasks",
|
|
439
|
+
runner: tooling.runner,
|
|
440
|
+
text,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function validateTaskDefinitions(
|
|
445
|
+
definitions: unknown,
|
|
446
|
+
config: TaskConfigPath,
|
|
447
|
+
allowStructured: boolean,
|
|
448
|
+
): asserts definitions is Record<string, TaskDefinition> {
|
|
449
|
+
if (
|
|
450
|
+
!definitions ||
|
|
451
|
+
typeof definitions !== "object" ||
|
|
452
|
+
Array.isArray(definitions)
|
|
453
|
+
) {
|
|
454
|
+
throw new Error(`${config} tasks/scripts must be an object.`);
|
|
455
|
+
}
|
|
456
|
+
for (const [name, definition] of Object.entries(definitions)) {
|
|
457
|
+
if (typeof definition === "string") continue;
|
|
458
|
+
if (
|
|
459
|
+
!allowStructured ||
|
|
460
|
+
!definition ||
|
|
461
|
+
typeof definition !== "object" ||
|
|
462
|
+
Array.isArray(definition)
|
|
463
|
+
) {
|
|
464
|
+
throw new Error(`${config} task '${name}' has an invalid definition.`);
|
|
465
|
+
}
|
|
466
|
+
const task = definition as Record<string, unknown>;
|
|
467
|
+
if (task.command !== undefined && typeof task.command !== "string") {
|
|
468
|
+
throw new Error(`${config} task '${name}' has a non-string command.`);
|
|
469
|
+
}
|
|
470
|
+
if (
|
|
471
|
+
task.dependencies !== undefined &&
|
|
472
|
+
(!Array.isArray(task.dependencies) ||
|
|
473
|
+
task.dependencies.some((dependency) => typeof dependency !== "string"))
|
|
474
|
+
) {
|
|
475
|
+
throw new Error(`${config} task '${name}' has invalid dependencies.`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function parseNpmImport(value: unknown) {
|
|
481
|
+
if (typeof value !== "string") return undefined;
|
|
482
|
+
const match = value.match(
|
|
483
|
+
/^npm:((?:@[^/]+\/)?[^@/]+)(?:@([^/]+))?(?:\/.*)?$/,
|
|
484
|
+
);
|
|
485
|
+
return match ? { name: match[1], version: match[2] ?? "*" } : undefined;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** Projects a Deno import map and task table into Loom's dependency signals. */
|
|
489
|
+
export function denoConfigAsPackageJson(config: DenoJson): ProjectPackageJson {
|
|
490
|
+
const dependencies: Record<string, string> = {};
|
|
491
|
+
for (const value of Object.values(config.imports ?? {})) {
|
|
492
|
+
const dependency = parseNpmImport(value);
|
|
493
|
+
if (dependency) dependencies[dependency.name] = dependency.version;
|
|
494
|
+
}
|
|
495
|
+
const scripts = Object.fromEntries(
|
|
496
|
+
Object.entries(config.tasks ?? {}).flatMap(([name, definition]) => {
|
|
497
|
+
const command = getTaskCommand(definition);
|
|
498
|
+
return command ? [[name, command]] : [];
|
|
499
|
+
}),
|
|
500
|
+
);
|
|
501
|
+
return {
|
|
502
|
+
dependencies,
|
|
503
|
+
name: config.name,
|
|
504
|
+
packageManager: "deno",
|
|
505
|
+
scripts,
|
|
506
|
+
version: config.version,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** Reads package metadata, falling back to Deno imports/tasks for Deno-only projects. */
|
|
511
|
+
export async function readProjectPackageMetadata(cwd: string): Promise<{
|
|
512
|
+
config: DependencyConfigPath;
|
|
513
|
+
packageJson: ProjectPackageJson;
|
|
514
|
+
path: string;
|
|
515
|
+
}> {
|
|
516
|
+
const packageText = await readTextIfExists(join(cwd, "package.json"));
|
|
517
|
+
if (packageText !== null) {
|
|
518
|
+
return {
|
|
519
|
+
config: "package.json" as const,
|
|
520
|
+
packageJson: parseStrictJson<ProjectPackageJson>(
|
|
521
|
+
packageText,
|
|
522
|
+
"package.json",
|
|
523
|
+
),
|
|
524
|
+
path: join(cwd, "package.json"),
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
const denoJsonText = await readTextIfExists(join(cwd, "deno.json"));
|
|
528
|
+
const denoJsoncText = await readTextIfExists(join(cwd, "deno.jsonc"));
|
|
529
|
+
if (denoJsonText !== null && denoJsoncText !== null) {
|
|
530
|
+
throw new Error("Both deno.json and deno.jsonc exist.");
|
|
531
|
+
}
|
|
532
|
+
const config = denoJsonText !== null ? "deno.json" : "deno.jsonc";
|
|
533
|
+
const text = denoJsonText ?? denoJsoncText;
|
|
534
|
+
if (text === null) {
|
|
535
|
+
throw new Error(
|
|
536
|
+
`No package.json, deno.json, or deno.jsonc found in ${cwd}`,
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
config: config as "deno.json" | "deno.jsonc",
|
|
541
|
+
packageJson: denoConfigAsPackageJson(parseJsonc<DenoJson>(text, config)),
|
|
542
|
+
path: join(cwd, config),
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function npmImport(name: string, version: string) {
|
|
547
|
+
return `npm:${name}@${version}`;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Applies dependency changes to the recorded dependency owner. Deno projects
|
|
552
|
+
* use imports and share one dependency class; package projects retain the
|
|
553
|
+
* dependencies/devDependencies distinction.
|
|
554
|
+
*/
|
|
555
|
+
export async function mutateProjectDependencies(
|
|
556
|
+
cwd: string,
|
|
557
|
+
tooling: ProjectTooling["dependencies"],
|
|
558
|
+
mutation: DependencyMutation,
|
|
559
|
+
) {
|
|
560
|
+
const path = join(cwd, tooling.config);
|
|
561
|
+
const original = await readTextIfExists(path);
|
|
562
|
+
if (original === null) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
`Missing authoritative dependency config: ${tooling.config}`,
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
let text = original;
|
|
568
|
+
const changedKeys: string[] = [];
|
|
569
|
+
const removedKeys: string[] = [];
|
|
570
|
+
if (tooling.config === "package.json") {
|
|
571
|
+
let config = parseStrictJson<ProjectPackageJson>(text, tooling.config);
|
|
572
|
+
for (const [field, additions] of [
|
|
573
|
+
["dependencies", mutation.dependencies],
|
|
574
|
+
["devDependencies", mutation.devDependencies],
|
|
575
|
+
] as const) {
|
|
576
|
+
for (const [name, version] of Object.entries(additions ?? {})) {
|
|
577
|
+
if (!mutation.replace && config[field]?.[name]) continue;
|
|
578
|
+
if (config[field]?.[name] === version) continue;
|
|
579
|
+
text = updateJsonPath(text, [field, name], version);
|
|
580
|
+
config = parseStrictJson<ProjectPackageJson>(text, tooling.config);
|
|
581
|
+
changedKeys.push(name);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
for (const name of mutation.remove ?? []) {
|
|
585
|
+
for (const field of ["dependencies", "devDependencies"] as const) {
|
|
586
|
+
if (!config[field]?.[name]) continue;
|
|
587
|
+
text = updateJsonPath(text, [field, name], undefined);
|
|
588
|
+
config = parseStrictJson<ProjectPackageJson>(text, tooling.config);
|
|
589
|
+
removedKeys.push(name);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
let config = parseJsonc<DenoJson>(text, tooling.config);
|
|
594
|
+
const additions = {
|
|
595
|
+
...mutation.devDependencies,
|
|
596
|
+
...mutation.dependencies,
|
|
597
|
+
};
|
|
598
|
+
for (const [name, version] of Object.entries(additions)) {
|
|
599
|
+
const desired = npmImport(name, version);
|
|
600
|
+
if (!mutation.replace && config.imports?.[name]) continue;
|
|
601
|
+
if (config.imports?.[name] === desired) continue;
|
|
602
|
+
text = updateJsonPath(text, ["imports", name], desired);
|
|
603
|
+
config = parseJsonc<DenoJson>(text, tooling.config);
|
|
604
|
+
changedKeys.push(name);
|
|
605
|
+
}
|
|
606
|
+
for (const name of mutation.remove ?? []) {
|
|
607
|
+
if (!config.imports?.[name]) continue;
|
|
608
|
+
text = updateJsonPath(text, ["imports", name], undefined);
|
|
609
|
+
config = parseJsonc<DenoJson>(text, tooling.config);
|
|
610
|
+
removedKeys.push(name);
|
|
611
|
+
}
|
|
612
|
+
if (config.nodeModulesDir === undefined) {
|
|
613
|
+
text = updateJsonPath(text, ["nodeModulesDir"], "auto");
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (text !== original) await writeFile(path, text, "utf8");
|
|
617
|
+
return {
|
|
618
|
+
changed: text !== original,
|
|
619
|
+
changedKeys: [...new Set(changedKeys)],
|
|
620
|
+
config: tooling.config,
|
|
621
|
+
removedKeys: [...new Set(removedKeys)],
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** A package.json override map; callers select the owning manager's active map. */
|
|
626
|
+
export type PackageJsonOverrideField =
|
|
627
|
+
| "overrides"
|
|
628
|
+
| "pnpm.overrides"
|
|
629
|
+
| "resolutions";
|
|
630
|
+
|
|
631
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
632
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function getJsonPath(value: unknown, path: readonly string[]) {
|
|
636
|
+
let current = value;
|
|
637
|
+
for (const key of path) {
|
|
638
|
+
current = isPlainObject(current) ? current[key] : undefined;
|
|
639
|
+
}
|
|
640
|
+
return current;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Sets, replaces, or (with an undefined value) removes one entry of a
|
|
645
|
+
* package.json override map with a minimal text edit that keeps the file's
|
|
646
|
+
* formatting. A missing map is created. Removing a map's last entry leaves
|
|
647
|
+
* the map in place unless `removeEmptyMap` says the caller created it.
|
|
648
|
+
*/
|
|
649
|
+
export async function mutatePackageJsonOverride(
|
|
650
|
+
cwd: string,
|
|
651
|
+
field: PackageJsonOverrideField,
|
|
652
|
+
name: string,
|
|
653
|
+
value: string | undefined,
|
|
654
|
+
options: {
|
|
655
|
+
/** Remove the map too when removing its last entry. */
|
|
656
|
+
removeEmptyMap?: boolean;
|
|
657
|
+
/** Use process-crash-safe replacement for generated local-dev selectors. */
|
|
658
|
+
atomic?: boolean;
|
|
659
|
+
/** Remove an emptied `pnpm` object too (with `pnpm.overrides`). */
|
|
660
|
+
removeEmptyPnpm?: boolean;
|
|
661
|
+
} = {},
|
|
662
|
+
) {
|
|
663
|
+
const path = join(cwd, "package.json");
|
|
664
|
+
const original = await readTextIfExists(path);
|
|
665
|
+
if (original === null) throw new Error("Missing package.json");
|
|
666
|
+
const config = parseStrictJson<Record<string, unknown>>(
|
|
667
|
+
original,
|
|
668
|
+
"package.json",
|
|
669
|
+
);
|
|
670
|
+
const mapPath = field !== "pnpm.overrides" ? [field] : ["pnpm", "overrides"];
|
|
671
|
+
if (getJsonPath(config, [...mapPath, name]) === value) {
|
|
672
|
+
return { changed: false };
|
|
673
|
+
}
|
|
674
|
+
let editPath = [...mapPath, name];
|
|
675
|
+
let editValue: unknown = value;
|
|
676
|
+
const map = getJsonPath(config, mapPath);
|
|
677
|
+
if (value === undefined) {
|
|
678
|
+
if (
|
|
679
|
+
options.removeEmptyMap &&
|
|
680
|
+
isPlainObject(map) &&
|
|
681
|
+
Object.keys(map).length === 1
|
|
682
|
+
) {
|
|
683
|
+
editPath = mapPath;
|
|
684
|
+
if (
|
|
685
|
+
options.removeEmptyPnpm &&
|
|
686
|
+
field === "pnpm.overrides" &&
|
|
687
|
+
isPlainObject(config.pnpm) &&
|
|
688
|
+
Object.keys(config.pnpm).length === 1
|
|
689
|
+
) {
|
|
690
|
+
editPath = ["pnpm"];
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
} else if (map === undefined) {
|
|
694
|
+
if (field === "pnpm.overrides" && config.pnpm === undefined) {
|
|
695
|
+
editPath = ["pnpm"];
|
|
696
|
+
editValue = { overrides: { [name]: value } };
|
|
697
|
+
} else {
|
|
698
|
+
editPath = mapPath;
|
|
699
|
+
editValue = { [name]: value };
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
const text =
|
|
703
|
+
editSingleLineObjectEntry(
|
|
704
|
+
original,
|
|
705
|
+
editPath.slice(0, -1),
|
|
706
|
+
editPath[editPath.length - 1],
|
|
707
|
+
editValue,
|
|
708
|
+
) ?? updateJsonPath(original, editPath, editValue);
|
|
709
|
+
if (text !== original) {
|
|
710
|
+
if (options.atomic) await replaceTextAtomically(path, text, original);
|
|
711
|
+
else await writeFile(path, text, "utf8");
|
|
712
|
+
}
|
|
713
|
+
return { changed: text !== original };
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Appends or removes one entry of an object written on a single line without
|
|
718
|
+
* reformatting it, so a compact map such as `{ "a": "1" }` round-trips byte
|
|
719
|
+
* for byte (jsonc `modify` would expand it). Returns null when the object is
|
|
720
|
+
* missing, spans lines, or the edit is not a plain append or removal.
|
|
721
|
+
*/
|
|
722
|
+
function editSingleLineObjectEntry(
|
|
723
|
+
text: string,
|
|
724
|
+
objectPath: string[],
|
|
725
|
+
name: string,
|
|
726
|
+
value: unknown,
|
|
727
|
+
) {
|
|
728
|
+
const { findNodeAtLocation, parseTree } = jsoncParser;
|
|
729
|
+
const tree = parseTree(text);
|
|
730
|
+
const object = tree
|
|
731
|
+
? objectPath.length
|
|
732
|
+
? findNodeAtLocation(tree, objectPath)
|
|
733
|
+
: tree
|
|
734
|
+
: undefined;
|
|
735
|
+
const properties = object?.type === "object" ? (object.children ?? []) : [];
|
|
736
|
+
const objectText = object
|
|
737
|
+
? text.slice(object.offset, object.offset + object.length)
|
|
738
|
+
: "";
|
|
739
|
+
if (!object || object.type !== "object" || objectText.includes("\n")) {
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
const end = (node: { length: number; offset: number }) =>
|
|
743
|
+
node.offset + node.length;
|
|
744
|
+
const index = properties.findIndex(
|
|
745
|
+
(property) => property.children?.[0]?.value === name,
|
|
746
|
+
);
|
|
747
|
+
let edited: string;
|
|
748
|
+
if (value === undefined) {
|
|
749
|
+
if (index === -1) return null;
|
|
750
|
+
const property = properties[index];
|
|
751
|
+
// Removing the only entry of `{"a":1}` gives back `{}`.
|
|
752
|
+
const start =
|
|
753
|
+
properties.length === 1
|
|
754
|
+
? property.offset
|
|
755
|
+
: index > 0
|
|
756
|
+
? end(properties[index - 1])
|
|
757
|
+
: property.offset;
|
|
758
|
+
const stop =
|
|
759
|
+
properties.length === 1 || index > 0
|
|
760
|
+
? end(property)
|
|
761
|
+
: properties[index + 1].offset;
|
|
762
|
+
edited = text.slice(0, start) + text.slice(stop);
|
|
763
|
+
} else if (properties.length === 0) {
|
|
764
|
+
if (objectText !== "{}") return null;
|
|
765
|
+
edited = `${text.slice(0, object.offset + 1)}${JSON.stringify(name)}:${JSON.stringify(
|
|
766
|
+
value,
|
|
767
|
+
)}${text.slice(object.offset + 1)}`;
|
|
768
|
+
} else {
|
|
769
|
+
if (index !== -1) return null;
|
|
770
|
+
const last = properties[properties.length - 1];
|
|
771
|
+
const [lastKey, lastValue] = last.children ?? [];
|
|
772
|
+
if (!lastKey || !lastValue) return null;
|
|
773
|
+
const colon = text.slice(end(lastKey), lastValue.offset);
|
|
774
|
+
const separator =
|
|
775
|
+
properties.length > 1
|
|
776
|
+
? text.slice(end(properties[properties.length - 2]), last.offset)
|
|
777
|
+
: /^\{\s/.test(text.slice(object.offset))
|
|
778
|
+
? ", "
|
|
779
|
+
: ",";
|
|
780
|
+
edited = `${text.slice(0, end(last))}${separator}${JSON.stringify(
|
|
781
|
+
name,
|
|
782
|
+
)}${colon}${JSON.stringify(value)}${text.slice(end(last))}`;
|
|
783
|
+
}
|
|
784
|
+
// Keep the textual edit only when it parses to exactly the intended value.
|
|
785
|
+
let parsed: unknown;
|
|
786
|
+
try {
|
|
787
|
+
parsed = JSON.parse(edited);
|
|
788
|
+
} catch {
|
|
789
|
+
return null;
|
|
790
|
+
}
|
|
791
|
+
return JSON.stringify(getJsonPath(parsed, [...objectPath, name])) ===
|
|
792
|
+
JSON.stringify(value)
|
|
793
|
+
? edited
|
|
794
|
+
: null;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** Adds or removes local dependency links in a Deno config. */
|
|
798
|
+
export async function mutateDenoLinks(
|
|
799
|
+
cwd: string,
|
|
800
|
+
config: "deno.json" | "deno.jsonc",
|
|
801
|
+
mutation: {
|
|
802
|
+
add?: string;
|
|
803
|
+
remove?: string | readonly string[];
|
|
804
|
+
atomic?: boolean;
|
|
805
|
+
},
|
|
806
|
+
) {
|
|
807
|
+
const path = join(cwd, config);
|
|
808
|
+
const original = await readTextIfExists(path);
|
|
809
|
+
if (original === null) throw new Error(`Missing Deno config: ${config}`);
|
|
810
|
+
const denoConfig = parseJsonc<DenoJson>(original, config);
|
|
811
|
+
let links = [...(denoConfig.links ?? [])];
|
|
812
|
+
const remove =
|
|
813
|
+
typeof mutation.remove === "string"
|
|
814
|
+
? [mutation.remove]
|
|
815
|
+
: (mutation.remove ?? []);
|
|
816
|
+
links = links.filter((link) => !remove.includes(link));
|
|
817
|
+
if (mutation.add && !links.includes(mutation.add)) links.push(mutation.add);
|
|
818
|
+
const text =
|
|
819
|
+
JSON.stringify(links) === JSON.stringify(denoConfig.links ?? [])
|
|
820
|
+
? original
|
|
821
|
+
: updateJsonPath(original, ["links"], links.length ? links : undefined);
|
|
822
|
+
if (text !== original) {
|
|
823
|
+
if (mutation.atomic) await replaceTextAtomically(path, text, original);
|
|
824
|
+
else await writeFile(path, text, "utf8");
|
|
825
|
+
}
|
|
826
|
+
return { changed: text !== original, links };
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/** Returns the configured local links without resolving their paths. */
|
|
830
|
+
export async function readDenoLinks(
|
|
831
|
+
cwd: string,
|
|
832
|
+
config: "deno.json" | "deno.jsonc",
|
|
833
|
+
) {
|
|
834
|
+
const text = await readTextIfExists(join(cwd, config));
|
|
835
|
+
if (text === null) throw new Error(`Missing Deno config: ${config}`);
|
|
836
|
+
return parseJsonc<DenoJson>(text, config).links ?? [];
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** Returns the executable command portion of either task representation. */
|
|
840
|
+
export function getTaskCommand(definition: TaskDefinition | undefined) {
|
|
841
|
+
if (typeof definition === "string") return definition;
|
|
842
|
+
return typeof definition?.command === "string"
|
|
843
|
+
? definition.command
|
|
844
|
+
: undefined;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
export function getTaskDependencies(definition: TaskDefinition | undefined) {
|
|
848
|
+
return typeof definition === "object" &&
|
|
849
|
+
Array.isArray(definition.dependencies)
|
|
850
|
+
? definition.dependencies.filter(
|
|
851
|
+
(value): value is string => typeof value === "string",
|
|
852
|
+
)
|
|
853
|
+
: [];
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/** Formats a task invocation for the selected project runner. */
|
|
857
|
+
export function formatTaskInvocation(
|
|
858
|
+
tasks: ProjectTooling["tasks"],
|
|
859
|
+
name: string,
|
|
860
|
+
) {
|
|
861
|
+
switch (tasks.runner) {
|
|
862
|
+
case "bun":
|
|
863
|
+
return `bun run ${name}`;
|
|
864
|
+
case "deno":
|
|
865
|
+
return `deno task ${name}`;
|
|
866
|
+
case "npm":
|
|
867
|
+
return `npm run ${name}`;
|
|
868
|
+
case "pnpm":
|
|
869
|
+
return `pnpm ${name}`;
|
|
870
|
+
case "yarn":
|
|
871
|
+
return `yarn ${name}`;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function taskInvocationPatterns(name: string) {
|
|
876
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
877
|
+
const tail = `(?:[\\s;&|)]|$)`;
|
|
878
|
+
return [
|
|
879
|
+
new RegExp(`(?:^|[\\s;&|($])bun\\s+run\\s+${escaped}${tail}`),
|
|
880
|
+
new RegExp(`(?:^|[\\s;&|($])deno\\s+task\\s+${escaped}${tail}`),
|
|
881
|
+
new RegExp(`(?:^|[\\s;&|($])npm\\s+run\\s+${escaped}${tail}`),
|
|
882
|
+
new RegExp(`(?:^|[\\s;&|($])pnpm\\s+(?:run\\s+)?${escaped}${tail}`),
|
|
883
|
+
new RegExp(`(?:^|[\\s;&|($])yarn\\s+(?:run\\s+)?${escaped}${tail}`),
|
|
884
|
+
];
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function commandInvokesTask(command: string | undefined, name: string) {
|
|
888
|
+
return Boolean(
|
|
889
|
+
command &&
|
|
890
|
+
taskInvocationPatterns(name).some((pattern) => pattern.test(command)),
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/** Checks direct and transitive task references without executing shell code. */
|
|
895
|
+
export function taskInvokes(
|
|
896
|
+
store: Pick<TaskStore, "definitions">,
|
|
897
|
+
source: string,
|
|
898
|
+
target: string,
|
|
899
|
+
) {
|
|
900
|
+
const visiting = new Set<string>();
|
|
901
|
+
const visit = (name: string): boolean => {
|
|
902
|
+
if (name === target) return true;
|
|
903
|
+
if (visiting.has(name)) return false;
|
|
904
|
+
visiting.add(name);
|
|
905
|
+
const definition = store.definitions[name];
|
|
906
|
+
const command = getTaskCommand(definition);
|
|
907
|
+
if (commandInvokesTask(command, target)) return true;
|
|
908
|
+
if (getTaskDependencies(definition).some(visit)) return true;
|
|
909
|
+
return Object.keys(store.definitions).some(
|
|
910
|
+
(candidate) =>
|
|
911
|
+
candidate !== name &&
|
|
912
|
+
commandInvokesTask(command, candidate) &&
|
|
913
|
+
visit(candidate),
|
|
914
|
+
);
|
|
915
|
+
};
|
|
916
|
+
return source !== target && visit(source);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/** Checks whether a task, or a task it invokes, contains a command fragment. */
|
|
920
|
+
export function taskInvokesCommand(
|
|
921
|
+
store: Pick<TaskStore, "definitions">,
|
|
922
|
+
source: string,
|
|
923
|
+
expectedCommand: string,
|
|
924
|
+
) {
|
|
925
|
+
const normalizedExpected = expectedCommand.trim().replace(/\s+/g, " ");
|
|
926
|
+
const visiting = new Set<string>();
|
|
927
|
+
const visit = (name: string): boolean => {
|
|
928
|
+
if (visiting.has(name)) return false;
|
|
929
|
+
visiting.add(name);
|
|
930
|
+
const definition = store.definitions[name];
|
|
931
|
+
const command = getTaskCommand(definition)?.replace(/\s+/g, " ");
|
|
932
|
+
if (command?.includes(normalizedExpected)) return true;
|
|
933
|
+
if (getTaskDependencies(definition).some(visit)) return true;
|
|
934
|
+
return Object.keys(store.definitions).some(
|
|
935
|
+
(candidate) =>
|
|
936
|
+
candidate !== name &&
|
|
937
|
+
commandInvokesTask(command, candidate) &&
|
|
938
|
+
visit(candidate),
|
|
939
|
+
);
|
|
940
|
+
};
|
|
941
|
+
return normalizedExpected.length > 0 && visit(source);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/** Verifies that a task invocation is ordered before a command fragment. */
|
|
945
|
+
export function taskRunsBeforeCommand(
|
|
946
|
+
store: Pick<TaskStore, "definitions">,
|
|
947
|
+
source: string,
|
|
948
|
+
prerequisite: string,
|
|
949
|
+
beforeCommand: string,
|
|
950
|
+
) {
|
|
951
|
+
const definition = store.definitions[source];
|
|
952
|
+
const command = getTaskCommand(definition);
|
|
953
|
+
if (!command || !command.includes(beforeCommand)) return false;
|
|
954
|
+
if (
|
|
955
|
+
getTaskDependencies(definition).some(
|
|
956
|
+
(dependency) =>
|
|
957
|
+
dependency === prerequisite ||
|
|
958
|
+
taskInvokes(store, dependency, prerequisite),
|
|
959
|
+
)
|
|
960
|
+
) {
|
|
961
|
+
return true;
|
|
962
|
+
}
|
|
963
|
+
const commandIndex = command.indexOf(beforeCommand);
|
|
964
|
+
return taskInvocationPatterns(prerequisite).some((pattern) => {
|
|
965
|
+
const match = pattern.exec(command);
|
|
966
|
+
return match !== null && match.index < commandIndex;
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
export type EnsureTaskOptions = {
|
|
971
|
+
definition: TaskDefinition;
|
|
972
|
+
name: string;
|
|
973
|
+
onConflict?: "preserve" | "replace";
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
/** Ensures one task through a localized JSON/JSONC edit. */
|
|
977
|
+
export async function ensureTask(
|
|
978
|
+
cwd: string,
|
|
979
|
+
tooling: ProjectTooling["tasks"],
|
|
980
|
+
options: EnsureTaskOptions,
|
|
981
|
+
) {
|
|
982
|
+
const store = await readTaskStore(cwd, tooling);
|
|
983
|
+
validateTaskDefinitions(
|
|
984
|
+
{ [options.name]: options.definition },
|
|
985
|
+
store.config,
|
|
986
|
+
store.config !== "package.json",
|
|
987
|
+
);
|
|
988
|
+
const previous = store.definitions[options.name];
|
|
989
|
+
if (
|
|
990
|
+
previous !== undefined &&
|
|
991
|
+
definitionsEqual(previous, options.definition)
|
|
992
|
+
) {
|
|
993
|
+
return { changed: false, config: store.config, previous, preserved: false };
|
|
994
|
+
}
|
|
995
|
+
if (previous !== undefined && options.onConflict === "preserve") {
|
|
996
|
+
return { changed: false, config: store.config, previous, preserved: true };
|
|
997
|
+
}
|
|
998
|
+
const text = updateJsonPath(
|
|
999
|
+
store.text,
|
|
1000
|
+
[store.rootKey, options.name],
|
|
1001
|
+
options.definition,
|
|
1002
|
+
);
|
|
1003
|
+
if (text !== store.text) {
|
|
1004
|
+
await writeFile(join(cwd, store.config), text, "utf8");
|
|
1005
|
+
}
|
|
1006
|
+
return {
|
|
1007
|
+
changed: text !== store.text,
|
|
1008
|
+
config: store.config,
|
|
1009
|
+
previous,
|
|
1010
|
+
preserved: false,
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Ensures a prerequisite runs before a named task. Deno tasks use their native
|
|
1016
|
+
* dependency graph; package scripts receive the runner-specific invocation.
|
|
1017
|
+
*/
|
|
1018
|
+
export async function ensureTaskPrerequisite(
|
|
1019
|
+
cwd: string,
|
|
1020
|
+
tooling: ProjectTooling["tasks"],
|
|
1021
|
+
taskName: string,
|
|
1022
|
+
prerequisite: string,
|
|
1023
|
+
) {
|
|
1024
|
+
const store = await readTaskStore(cwd, tooling);
|
|
1025
|
+
const current = store.definitions[taskName];
|
|
1026
|
+
if (current === undefined) {
|
|
1027
|
+
throw new Error(`Cannot compose missing task: ${taskName}`);
|
|
1028
|
+
}
|
|
1029
|
+
if (taskInvokes(store, taskName, prerequisite)) {
|
|
1030
|
+
return { changed: false, config: store.config };
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
let definition: TaskDefinition;
|
|
1034
|
+
if (store.config !== "package.json") {
|
|
1035
|
+
if (typeof current === "string") {
|
|
1036
|
+
definition = { command: current, dependencies: [prerequisite] };
|
|
1037
|
+
} else {
|
|
1038
|
+
definition = {
|
|
1039
|
+
...current,
|
|
1040
|
+
dependencies: [...getTaskDependencies(current), prerequisite],
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
} else {
|
|
1044
|
+
const command = getTaskCommand(current);
|
|
1045
|
+
if (!command) throw new Error(`Task has no command: ${taskName}`);
|
|
1046
|
+
definition = `${formatTaskInvocation(
|
|
1047
|
+
tooling,
|
|
1048
|
+
prerequisite,
|
|
1049
|
+
)} && (${command})`;
|
|
1050
|
+
}
|
|
1051
|
+
const result = await ensureTask(cwd, tooling, {
|
|
1052
|
+
definition,
|
|
1053
|
+
name: taskName,
|
|
1054
|
+
});
|
|
1055
|
+
return { changed: result.changed, config: result.config };
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/** Ensures a named task runs after another task's existing command succeeds. */
|
|
1059
|
+
export async function ensureTaskFollowup(
|
|
1060
|
+
cwd: string,
|
|
1061
|
+
tooling: ProjectTooling["tasks"],
|
|
1062
|
+
taskName: string,
|
|
1063
|
+
followup: string,
|
|
1064
|
+
) {
|
|
1065
|
+
const store = await readTaskStore(cwd, tooling);
|
|
1066
|
+
const current = store.definitions[taskName];
|
|
1067
|
+
if (current === undefined) {
|
|
1068
|
+
throw new Error(`Cannot compose missing task: ${taskName}`);
|
|
1069
|
+
}
|
|
1070
|
+
if (taskInvokes(store, taskName, followup)) {
|
|
1071
|
+
return { changed: false, config: store.config };
|
|
1072
|
+
}
|
|
1073
|
+
const command = getTaskCommand(current);
|
|
1074
|
+
if (!command) throw new Error(`Task has no command: ${taskName}`);
|
|
1075
|
+
const composed = `(${command}) && ${formatTaskInvocation(tooling, followup)}`;
|
|
1076
|
+
const definition =
|
|
1077
|
+
typeof current === "string" ? composed : { ...current, command: composed };
|
|
1078
|
+
const result = await ensureTask(cwd, tooling, {
|
|
1079
|
+
definition,
|
|
1080
|
+
name: taskName,
|
|
1081
|
+
});
|
|
1082
|
+
return { changed: result.changed, config: result.config };
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
function delegatesToAuthoritativeDenoTask(
|
|
1086
|
+
primaryConfig: TaskConfigPath,
|
|
1087
|
+
secondaryConfig: TaskConfigPath,
|
|
1088
|
+
name: string,
|
|
1089
|
+
definition: TaskDefinition,
|
|
1090
|
+
) {
|
|
1091
|
+
return (
|
|
1092
|
+
primaryConfig !== "package.json" &&
|
|
1093
|
+
secondaryConfig === "package.json" &&
|
|
1094
|
+
getTaskCommand(definition)?.trim() === `deno task ${name}`
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/** Finds duplicate task names that differ and do not delegate to Deno. */
|
|
1099
|
+
export async function findTaskConflicts(
|
|
1100
|
+
cwd: string,
|
|
1101
|
+
authoritative: ProjectTooling["tasks"],
|
|
1102
|
+
): Promise<TaskConflict[]> {
|
|
1103
|
+
const primary = await readTaskStore(cwd, authoritative);
|
|
1104
|
+
const secondaryConfigs: TaskConfigPath[] =
|
|
1105
|
+
primary.config === "package.json"
|
|
1106
|
+
? ["deno.json", "deno.jsonc"]
|
|
1107
|
+
: ["package.json"];
|
|
1108
|
+
const conflicts: TaskConflict[] = [];
|
|
1109
|
+
for (const secondaryConfig of secondaryConfigs) {
|
|
1110
|
+
const text = await readTextIfExists(join(cwd, secondaryConfig));
|
|
1111
|
+
if (text === null) continue;
|
|
1112
|
+
const secondary = await readTaskStore(cwd, {
|
|
1113
|
+
config: secondaryConfig,
|
|
1114
|
+
runner: secondaryConfig === "package.json" ? "npm" : "deno",
|
|
1115
|
+
});
|
|
1116
|
+
for (const [name, definition] of Object.entries(primary.definitions)) {
|
|
1117
|
+
const other = secondary.definitions[name];
|
|
1118
|
+
if (
|
|
1119
|
+
other === undefined ||
|
|
1120
|
+
!definitionsConflict(definition, other) ||
|
|
1121
|
+
delegatesToAuthoritativeDenoTask(
|
|
1122
|
+
primary.config,
|
|
1123
|
+
secondaryConfig,
|
|
1124
|
+
name,
|
|
1125
|
+
other,
|
|
1126
|
+
)
|
|
1127
|
+
) {
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
conflicts.push({
|
|
1131
|
+
authoritative: definition,
|
|
1132
|
+
authoritativeConfig: primary.config,
|
|
1133
|
+
name,
|
|
1134
|
+
secondary: other,
|
|
1135
|
+
secondaryConfig,
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
return conflicts;
|
|
1140
|
+
}
|