@slicemachine/manager 0.24.15-alpha.xru-doc-link-menu.1 → 0.24.15-alpha.xru-e2e-tests-logged-in.2
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/dist/_node_modules/@amplitude/analytics-core/_node_modules/tslib/tslib.es6.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/_node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/debug.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/debug.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/_node_modules/tslib/tslib.es6.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/_node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/lib/esm/transports/http.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/lib/esm/transports/http.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-core/dist/experiment-core.esm.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-core/dist/experiment-core.esm.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment-service.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment-service.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/cookie.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/cookie.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/cache.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/cache.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/fetcher.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/fetcher.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/poller.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/poller.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/remote/client.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/remote/client.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/transport/http.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/transport/http.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/util/backoff.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/util/backoff.js.map +1 -1
- package/dist/_node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.cjs.map +1 -1
- package/dist/_node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.js.map +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_node_modules/cross-spawn/lib/enoent.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/enoent.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/parse.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/parse.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/escape.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/escape.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/readShebang.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/readShebang.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/resolveCommand.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/resolveCommand.js.map +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -1
- package/dist/_node_modules/execa/index.cjs +2 -2
- package/dist/_node_modules/execa/index.cjs.map +1 -1
- package/dist/_node_modules/execa/index.js +2 -2
- package/dist/_node_modules/execa/index.js.map +1 -1
- package/dist/_node_modules/execa/lib/command.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/command.js.map +1 -1
- package/dist/_node_modules/execa/lib/error.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/error.js.map +1 -1
- package/dist/_node_modules/execa/lib/kill.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/kill.js.map +1 -1
- package/dist/_node_modules/execa/lib/promise.cjs +2 -2
- package/dist/_node_modules/execa/lib/promise.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/promise.js +2 -2
- package/dist/_node_modules/execa/lib/promise.js.map +1 -1
- package/dist/_node_modules/execa/lib/stdio.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/stdio.js.map +1 -1
- package/dist/_node_modules/execa/lib/stream.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/stream.js.map +1 -1
- package/dist/_node_modules/execa/lib/verbose.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/verbose.js.map +1 -1
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -1
- package/dist/_node_modules/fetch-blob/file.js.map +1 -1
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -1
- package/dist/_node_modules/fetch-blob/index.js.map +1 -1
- package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -1
- package/dist/_node_modules/fetch-blob/streams.js.map +1 -1
- package/dist/_node_modules/file-type/core.cjs.map +1 -1
- package/dist/_node_modules/file-type/core.js.map +1 -1
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -1
- package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -1
- package/dist/_node_modules/get-port/index.cjs.map +1 -1
- package/dist/_node_modules/get-port/index.js.map +1 -1
- package/dist/_node_modules/get-stream/index.cjs.map +1 -1
- package/dist/_node_modules/get-stream/index.js.map +1 -1
- package/dist/_node_modules/human-signals/build/src/realtime.cjs.map +1 -1
- package/dist/_node_modules/human-signals/build/src/realtime.js.map +1 -1
- package/dist/_node_modules/isexe/index.cjs.map +1 -1
- package/dist/_node_modules/isexe/index.js.map +1 -1
- package/dist/_node_modules/mimic-fn/index.cjs.map +1 -1
- package/dist/_node_modules/mimic-fn/index.js.map +1 -1
- package/dist/_node_modules/node-domexception/index.cjs.map +1 -1
- package/dist/_node_modules/node-domexception/index.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/body.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/headers.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/index.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -1
- package/dist/_node_modules/npm-run-path/_node_modules/path-key/index.cjs.map +1 -0
- package/dist/_node_modules/npm-run-path/_node_modules/path-key/index.js.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/npm-run-path → npm-run-path}/index.cjs +1 -1
- package/dist/_node_modules/npm-run-path/index.cjs.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/npm-run-path → npm-run-path}/index.js +1 -1
- package/dist/_node_modules/npm-run-path/index.js.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/onetime → onetime}/index.cjs +1 -1
- package/dist/_node_modules/onetime/index.cjs.map +1 -0
- package/dist/_node_modules/{execa/_node_modules/onetime → onetime}/index.js +1 -1
- package/dist/_node_modules/onetime/index.js.map +1 -0
- package/dist/_node_modules/p-limit/index.cjs.map +1 -1
- package/dist/_node_modules/p-limit/index.js.map +1 -1
- package/dist/_node_modules/r19/dist/handleRPCRequest.cjs.map +1 -1
- package/dist/_node_modules/r19/dist/handleRPCRequest.js.map +1 -1
- package/dist/_node_modules/shebang-command/index.cjs.map +1 -1
- package/dist/_node_modules/shebang-command/index.js.map +1 -1
- package/dist/_node_modules/signal-exit/index.cjs.map +1 -1
- package/dist/_node_modules/signal-exit/index.js.map +1 -1
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -1
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -1
- package/dist/_node_modules/which/which.cjs.map +1 -1
- package/dist/_node_modules/which/which.js.map +1 -1
- package/dist/_node_modules/zod/lib/index.cjs.map +1 -1
- package/dist/_node_modules/zod/lib/index.js.map +1 -1
- package/dist/_virtual/_commonjsHelpers.cjs +1 -4
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -1
- package/dist/_virtual/_commonjsHelpers.js +1 -4
- package/dist/_virtual/_commonjsHelpers.js.map +1 -1
- package/dist/_virtual/index2.cjs +4 -3
- package/dist/_virtual/index2.cjs.map +1 -1
- package/dist/_virtual/index2.js +4 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.cjs +3 -4
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +2 -4
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/auth/PrismicAuthManager.cjs.map +1 -1
- package/dist/auth/PrismicAuthManager.js.map +1 -1
- package/dist/auth/createPrismicAuthManagerMiddleware.cjs.map +1 -1
- package/dist/auth/createPrismicAuthManagerMiddleware.js.map +1 -1
- package/dist/constants/API_ENDPOINTS.cjs.map +1 -1
- package/dist/constants/API_ENDPOINTS.js.map +1 -1
- package/dist/constants/API_TOKENS.cjs.map +1 -1
- package/dist/constants/API_TOKENS.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/getEnvironmentInfo.cjs.map +1 -1
- package/dist/getEnvironmentInfo.js.map +1 -1
- package/dist/lib/DecodeError.cjs.map +1 -1
- package/dist/lib/DecodeError.js.map +1 -1
- package/dist/lib/buildPrismicRepositoryAPIEndpoint.cjs.map +1 -1
- package/dist/lib/buildPrismicRepositoryAPIEndpoint.js.map +1 -1
- package/dist/lib/fetchGitHubReleaseBodyForRelease.cjs.map +1 -1
- package/dist/lib/fetchGitHubReleaseBodyForRelease.js.map +1 -1
- package/dist/lib/fetchNPMPackageVersions.cjs.map +1 -1
- package/dist/lib/fetchNPMPackageVersions.js.map +1 -1
- package/dist/lib/installDependencies.cjs.map +1 -1
- package/dist/lib/installDependencies.js.map +1 -1
- package/dist/lib/locateFileUpward.cjs.map +1 -1
- package/dist/lib/locateFileUpward.js.map +1 -1
- package/dist/lib/prismicrc.cjs.map +1 -1
- package/dist/lib/prismicrc.js.map +1 -1
- package/dist/managers/SliceMachineManager.cjs.map +1 -1
- package/dist/managers/SliceMachineManager.js.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.cjs +213 -4
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.d.ts +130 -11
- package/dist/managers/customTypes/CustomTypesManager.js +215 -6
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/dist/managers/git/GitManager.cjs.map +1 -1
- package/dist/managers/git/GitManager.js.map +1 -1
- package/dist/managers/git/buildGitRepoSpecifier.cjs.map +1 -1
- package/dist/managers/git/buildGitRepoSpecifier.js.map +1 -1
- package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs.map +1 -1
- package/dist/managers/prismicRepository/PrismicRepositoryManager.js.map +1 -1
- package/dist/managers/project/ProjectManager.cjs.map +1 -1
- package/dist/managers/project/ProjectManager.js.map +1 -1
- package/dist/managers/screenshots/ScreenshotsManager.cjs.map +1 -1
- package/dist/managers/screenshots/ScreenshotsManager.js.map +1 -1
- package/dist/managers/sliceTemplateLibrary/SliceTemplateLibraryManager.cjs.map +1 -1
- package/dist/managers/sliceTemplateLibrary/SliceTemplateLibraryManager.js.map +1 -1
- package/dist/managers/slices/SlicesManager.cjs.map +1 -1
- package/dist/managers/slices/SlicesManager.js.map +1 -1
- package/dist/managers/telemetry/TelemetryManager.cjs.map +1 -1
- package/dist/managers/telemetry/TelemetryManager.js.map +1 -1
- package/dist/managers/telemetry/types.cjs +6 -4
- package/dist/managers/telemetry/types.cjs.map +1 -1
- package/dist/managers/telemetry/types.d.ts +7 -6
- package/dist/managers/telemetry/types.js +6 -4
- package/dist/managers/telemetry/types.js.map +1 -1
- package/dist/managers/versions/VersionsManager.cjs.map +1 -1
- package/dist/managers/versions/VersionsManager.js.map +1 -1
- package/package.json +5 -5
- package/src/managers/customTypes/CustomTypesManager.ts +365 -6
- package/src/managers/telemetry/types.ts +17 -12
- package/dist/_node_modules/execa/_node_modules/npm-run-path/index.cjs.map +0 -1
- package/dist/_node_modules/execa/_node_modules/npm-run-path/index.js.map +0 -1
- package/dist/_node_modules/execa/_node_modules/onetime/index.cjs.map +0 -1
- package/dist/_node_modules/execa/_node_modules/onetime/index.js.map +0 -1
- package/dist/_node_modules/execa/_node_modules/path-key/index.cjs.map +0 -1
- package/dist/_node_modules/execa/_node_modules/path-key/index.js.map +0 -1
- /package/dist/_node_modules/{execa → npm-run-path}/_node_modules/path-key/index.cjs +0 -0
- /package/dist/_node_modules/{execa → npm-run-path}/_node_modules/path-key/index.js +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchGitHubReleaseBodyForRelease.js","sources":["../../../src/lib/fetchGitHubReleaseBodyForRelease.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\nimport pLimit from \"p-limit\";\n\nimport { decode } from \"./decode\";\n\nconst GITHUB_JSON_ACCEPT_HEADER = \"application/vnd.github+json\";\n\n/**\n * A minimally defined codec for GitHub release metadata.\n *\n * @see https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name\n */\nconst GitHubReleaseMetadata = t.type({\n\tname: t.string,\n\tbody: t.union([t.null, t.string]),\n});\nexport type GitHubReleaseMetadata = t.TypeOf<typeof GitHubReleaseMetadata>;\n\ntype FetchAllGitHubReleasesArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n};\n\nconst fetchAllGitHubReleases = async (\n\targs: FetchAllGitHubReleasesArgs,\n): Promise<GitHubReleaseMetadata[]> => {\n\tconst res = await fetch(\n\t\t`https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(t.array(GitHubReleaseMetadata), json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t} else {\n\t\tconst text = await res.text();\n\t\tthrow new Error(`Invalid GitHub Release response.`, {\n\t\t\tcause: text,\n\t\t});\n\t}\n};\n\ntype FetchGitHubReleaseByVersionArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n};\n\nconst fetchGitHubReleaseByVersion = async (\n\targs: FetchGitHubReleaseByVersionArgs,\n): Promise<GitHubReleaseMetadata | undefined> => {\n\tlet url: string;\n\n\tif (args.packageName) {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.packageName}@${args.version}`;\n\t} else {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.version}`;\n\t}\n\n\tconst res = await fetch(url, {\n\t\theaders: {\n\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(GitHubReleaseMetadata, json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t}\n};\n\ntype FetchGitHubReleaseBodyForReleaseArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n\tcache?: Record<string, GitHubReleaseMetadata | undefined>;\n};\n\nconst _fetchGitHubReleaseBodyForRelease = async (\n\targs: FetchGitHubReleaseBodyForReleaseArgs,\n): Promise<string | undefined> => {\n\tconst cache = args.cache || {};\n\n\tif (Object.keys(cache).length < 1) {\n\t\tconst releases = await fetchAllGitHubReleases({\n\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\trepositoryName: args.repositoryName,\n\t\t});\n\n\t\tfor (const release of releases) {\n\t\t\tcache[release.name] = release;\n\t\t}\n\t}\n\n\tif (args.version in cache) {\n\t\tconst release = cache[args.version];\n\n\t\treturn release?.body ?? undefined;\n\t} else {\n\t\ttry {\n\t\t\tconst version = await fetchGitHubReleaseByVersion({\n\t\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\t\trepositoryName: args.repositoryName,\n\t\t\t\tpackageName: args.packageName,\n\t\t\t\tversion: args.version,\n\t\t\t});\n\n\t\t\tcache[args.version] = version;\n\n\t\t\treturn version?.body ?? undefined;\n\t\t} catch {\n\t\t\tcache[args.version] = undefined;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n};\n\nconst limit = pLimit(1);\n\nexport const fetchGitHubReleaseBodyForRelease = async (\n\t...args: Parameters<typeof _fetchGitHubReleaseBodyForRelease>\n): ReturnType<typeof _fetchGitHubReleaseBodyForRelease> => {\n\treturn await limit(() => _fetchGitHubReleaseBodyForRelease(...args));\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,4BAA4B;AAOlC,MAAM,wBAAwB,EAAE,KAAK;AAAA,EACpC,MAAM,EAAE;AAAA,EACR,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;AAChC,CAAA;AAQD,MAAM,yBAAyB,OAC9B,SACqC;
|
1
|
+
{"version":3,"file":"fetchGitHubReleaseBodyForRelease.js","sources":["../../../src/lib/fetchGitHubReleaseBodyForRelease.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\nimport pLimit from \"p-limit\";\n\nimport { decode } from \"./decode\";\n\nconst GITHUB_JSON_ACCEPT_HEADER = \"application/vnd.github+json\";\n\n/**\n * A minimally defined codec for GitHub release metadata.\n *\n * @see https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name\n */\nconst GitHubReleaseMetadata = t.type({\n\tname: t.string,\n\tbody: t.union([t.null, t.string]),\n});\nexport type GitHubReleaseMetadata = t.TypeOf<typeof GitHubReleaseMetadata>;\n\ntype FetchAllGitHubReleasesArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n};\n\nconst fetchAllGitHubReleases = async (\n\targs: FetchAllGitHubReleasesArgs,\n): Promise<GitHubReleaseMetadata[]> => {\n\tconst res = await fetch(\n\t\t`https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(t.array(GitHubReleaseMetadata), json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t} else {\n\t\tconst text = await res.text();\n\t\tthrow new Error(`Invalid GitHub Release response.`, {\n\t\t\tcause: text,\n\t\t});\n\t}\n};\n\ntype FetchGitHubReleaseByVersionArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n};\n\nconst fetchGitHubReleaseByVersion = async (\n\targs: FetchGitHubReleaseByVersionArgs,\n): Promise<GitHubReleaseMetadata | undefined> => {\n\tlet url: string;\n\n\tif (args.packageName) {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.packageName}@${args.version}`;\n\t} else {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.version}`;\n\t}\n\n\tconst res = await fetch(url, {\n\t\theaders: {\n\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(GitHubReleaseMetadata, json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t}\n};\n\ntype FetchGitHubReleaseBodyForReleaseArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n\tcache?: Record<string, GitHubReleaseMetadata | undefined>;\n};\n\nconst _fetchGitHubReleaseBodyForRelease = async (\n\targs: FetchGitHubReleaseBodyForReleaseArgs,\n): Promise<string | undefined> => {\n\tconst cache = args.cache || {};\n\n\tif (Object.keys(cache).length < 1) {\n\t\tconst releases = await fetchAllGitHubReleases({\n\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\trepositoryName: args.repositoryName,\n\t\t});\n\n\t\tfor (const release of releases) {\n\t\t\tcache[release.name] = release;\n\t\t}\n\t}\n\n\tif (args.version in cache) {\n\t\tconst release = cache[args.version];\n\n\t\treturn release?.body ?? undefined;\n\t} else {\n\t\ttry {\n\t\t\tconst version = await fetchGitHubReleaseByVersion({\n\t\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\t\trepositoryName: args.repositoryName,\n\t\t\t\tpackageName: args.packageName,\n\t\t\t\tversion: args.version,\n\t\t\t});\n\n\t\t\tcache[args.version] = version;\n\n\t\t\treturn version?.body ?? undefined;\n\t\t} catch {\n\t\t\tcache[args.version] = undefined;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n};\n\nconst limit = pLimit(1);\n\nexport const fetchGitHubReleaseBodyForRelease = async (\n\t...args: Parameters<typeof _fetchGitHubReleaseBodyForRelease>\n): ReturnType<typeof _fetchGitHubReleaseBodyForRelease> => {\n\treturn await limit(() => _fetchGitHubReleaseBodyForRelease(...args));\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,4BAA4B;AAOlC,MAAM,wBAAwB,EAAE,KAAK;AAAA,EACpC,MAAM,EAAE;AAAA,EACR,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;AAChC,CAAA;AAQD,MAAM,yBAAyB,OAC9B,SACqC;AAC/B,QAAA,MAAM,MAAM,MACjB,gCAAgC,KAAK,eAAe,IAAI,KAAK,cAAc,aAC3E;AAAA,IACC,SAAS;AAAA,MACR,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAGF,MAAI,IAAI,IAAI;AACL,UAAA,OAAO,MAAM,IAAI;AAEjB,UAAA,EAAE,OAAO,MAAK,IAAK,OAAO,EAAE,MAAM,qBAAqB,GAAG,IAAI;AAEpE,QAAI,OAAO;A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AA,QACjD,iBAAiB,KAAK;AAAA,QACtB,gBAAgB,KAAK;AAAA,QACrB,aAAa,KAAK;AAAA,QAClB,SAAS,KAAK;AAAA,MAAA,CACd;AAEK,YAAA,KAAK,OAAO,IAAI;AAEtB,cAAO,mCAAS,SAAQ;AAAA,IAAA,QACjB;AACD,YAAA,KAAK,OAAO,IAAI;AAEf,aAAA;AAAA,IACR;AAAA,EACD;AACD;AAEA,MAAM,QAAQ,OAAO,CAAC;AAET,MAAA,mCAAmC,UAC5C,SACsD;AACzD,SAAO,MAAM,MAAM,MAAM,kCAAkC,GAAG,IAAI,CAAC;AACpE;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchNPMPackageVersions.cjs","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":["t","fetch","decode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkCA,aAAE,KAAK;AAAA,EAC9C,UAAUA,aAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAMC,cAAM,8BAA8B,KAAK,
|
1
|
+
{"version":3,"file":"fetchNPMPackageVersions.cjs","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":["t","fetch","decode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkCA,aAAE,KAAK;AAAA,EAC9C,UAAUA,aAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAMC,cAAM,8BAA8B,KAAK,WAAW,IAAI;AAAA,IACzE,SAAS;AAAA,MACR,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEK,QAAA,OAAO,MAAM,IAAI;AAEvB,QAAM,EAAE,OAAO,MAAA,IAAUC,OAAAA,OAAO,iCAAiC,IAAI;AAErE,MAAI,OAAO;AACV,UAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,OAAO;AAAA,EACnE;AAEO,SAAA,OAAO,KAAK,MAAM,QAAQ;AAClC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchNPMPackageVersions.js","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkC,EAAE,KAAK;AAAA,EAC9C,UAAU,EAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAM,MAAM,8BAA8B,KAAK,
|
1
|
+
{"version":3,"file":"fetchNPMPackageVersions.js","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkC,EAAE,KAAK;AAAA,EAC9C,UAAU,EAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAM,MAAM,8BAA8B,KAAK,WAAW,IAAI;AAAA,IACzE,SAAS;AAAA,MACR,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEK,QAAA,OAAO,MAAM,IAAI;AAEvB,QAAM,EAAE,OAAO,MAAA,IAAU,OAAO,iCAAiC,IAAI;AAErE,MAAI,OAAO;AACV,UAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,OAAO;AAAA,EACnE;AAEO,SAAA,OAAO,KAAK,MAAM,QAAQ;AAClC;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"installDependencies.cjs","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":["parseNi","execaCommand"],"mappings":";;;;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,
|
1
|
+
{"version":3,"file":"installDependencies.cjs","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":["parseNi","execaCommand"],"mappings":";;;;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE;AAGhC,MAAA,YAAY,UAAU,KAAK,KAAK;AACnC,gBAAY,QAAQ,IAAI;AAAA,EACzB;AAEA,cAAY,KAAK,GAAG,oBAAoB,KAAK,cAAc,CAAC;AAE5D,QAAM,UAAU,MAAMA,GAAQ,QAAA,KAAK,gBAAgB,WAAW;AAE9D,MAAI,CAAC,SAAS;AACP,UAAA,IAAI,MACT,qEACA;AAAA,MACC,OAAO;AAAA,QACN,gBAAgB,KAAK;AAAA,QACrB,cAAc,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EAEH;AAEM,QAAA,eAAeC,mBAAa,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV,GAAG,KAAK;AAAA,EAAA,CACR;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"installDependencies.js","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":[],"mappings":";;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,
|
1
|
+
{"version":3,"file":"installDependencies.js","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":[],"mappings":";;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE;AAGhC,MAAA,YAAY,UAAU,KAAK,KAAK;AACnC,gBAAY,QAAQ,IAAI;AAAA,EACzB;AAEA,cAAY,KAAK,GAAG,oBAAoB,KAAK,cAAc,CAAC;AAE5D,QAAM,UAAU,MAAM,QAAQ,KAAK,gBAAgB,WAAW;AAE9D,MAAI,CAAC,SAAS;AACP,UAAA,IAAI,MACT,qEACA;AAAA,MACC,OAAO;AAAA,QACN,gBAAgB,KAAK;AAAA,QACrB,cAAc,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EAEH;AAEM,QAAA,eAAe,aAAa,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV,GAAG,KAAK;AAAA,EAAA,CACR;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locateFileUpward.cjs","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":["path","castArray","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAUA,gBAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAYC,oBAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmBD,gBAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAAE,cAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,
|
1
|
+
{"version":3,"file":"locateFileUpward.cjs","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":["path","castArray","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAUA,gBAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAYC,oBAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmBD,gBAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAAE,cAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,QACA;AACP;AAAA,IACD;AAAA,EACD;AAEA,MAAI,aAAa,SAAS;AACnB,UAAA,qBAAqB,UACzB,IAAI,CAAC,aAAa,MAAM,WAAW,GAAG,EACtC,KAAK,MAAM;AAEP,UAAA,IAAI,MACT,oBAAoB,kBAAkB,cAAc,gBAAgB,YAAY,OAAO,KAAK;AAAA,EAE9F;AAEA,SAAO,iBAAiB,iBAAiB;AAAA,IACxC,UAAUF,gBAAK,QAAQ,UAAU,IAAI;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,EAAA,CACnB;AACF;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"locateFileUpward.js","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":[],"mappings":";;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAU,KAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAY,UAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmB,KAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAA,GAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,
|
1
|
+
{"version":3,"file":"locateFileUpward.js","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":[],"mappings":";;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAU,KAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAY,UAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmB,KAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAA,GAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,QACA;AACP;AAAA,IACD;AAAA,EACD;AAEA,MAAI,aAAa,SAAS;AACnB,UAAA,qBAAqB,UACzB,IAAI,CAAC,aAAa,MAAM,WAAW,GAAG,EACtC,KAAK,MAAM;AAEP,UAAA,IAAI,MACT,oBAAoB,kBAAkB,cAAc,gBAAgB,YAAY,OAAO,KAAK;AAAA,EAE9F;AAEA,SAAO,iBAAiB,iBAAiB;AAAA,IACxC,UAAU,KAAK,QAAQ,UAAU,IAAI;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,EAAA,CACnB;AACF;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prismicrc.cjs","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":["t","rc9","decode","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAYA,aAAE,QAAQ;AAAA,EAC3B,WAAWA,aAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClBC,eAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjCA,eAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAAC,cAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAMC,gBAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,
|
1
|
+
{"version":3,"file":"prismicrc.cjs","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":["t","rc9","decode","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAYA,aAAE,QAAQ;AAAA,EAC3B,WAAWA,aAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClBC,eAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjCA,eAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAAC,cAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAMC,gBAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,SAAS,EACpD,KAAK,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAEhC;AAEO,SAAA;AACR;AAEa,MAAA,gBAAgB,CAAC,QAA0B;AACvD,QAAM,gBAAgB;AAChB,QAAA,mBAAmB,iBAAiB,GAAG;AAEtC,SAAA;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEL;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prismicrc.js","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAY,EAAE,QAAQ;AAAA,EAC3B,WAAW,EAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClB,IAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjC,IAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAA,OAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAM,KAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,
|
1
|
+
{"version":3,"file":"prismicrc.js","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAY,EAAE,QAAQ;AAAA,EAC3B,WAAW,EAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClB,IAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjC,IAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAA,OAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAM,KAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,SAAS,EACpD,KAAK,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAEhC;AAEO,SAAA;AACR;AAEa,MAAA,gBAAgB,CAAC,QAA0B;AACvD,QAAM,gBAAgB;AAChB,QAAA,mBAAmB,iBAAiB,GAAG;AAEtC,SAAA;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEL;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SliceMachineManager.cjs","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t]);\n\n\t\t\t\t\t\t\t\tif (model) {\n\t\t\t\t\t\t\t\t\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["createPrismicAuthManager","UserManager","PrismicRepositoryManager","PluginsManager","ProjectManager","CustomTypesManager","SlicesManager","SnippetsManager","ScreenshotsManager","SimulatorManager","DocumentationManager","SliceTemplateLibraryManager","VersionsManager","TelemetryManager","GitManager","API_ENDPOINTS","sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices","prismicCustomTypesClient","buildPrismicRepositoryAPIEndpoint","createContentDigest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkGa,oBAAmB;AAAA,EAsB/B,YAAY,MAAyC;AArB7C;AAEA;AAER;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,SAAK,sBAAsBA,yBAAAA;AAEtB,SAAA,OAAO,IAAIC,YAAA,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAIC,yBAAA,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAIC,eAAA,eAAe,MAAM;AAAA,MACvC,eAAe,6BAAM;AAAA,IAAA,CACrB;AAEI,SAAA,UAAU,IAAIC,eA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AA,YACF;AAAA,UACA,CAAA,CAAC;AAGH,oBAAU,KAAK;AAAA,YACd,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA;AAAA,YACT;AAAA,YACA,MAAM;AAAA;AAAA,cAEL,cAAc;AAAA,cACd,cAAc;AAAA,cACd,UAAU;AAAA,YACV;AAAA,UAAA,CACD;AAAA,QACF;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAGA,WAAO,UAAU,KAAK,CAAC,UAAU,aAAY;;AAC5C,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AACzD,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AAElD,aAAA,KAAK,KAAK,gBAAgB,aAAa;AAAA,IAAA,CAC9C;AAAA,EACF;AAAA,EAEQ,MAAM,kBAAe;AAG5B,UAAM,cACL,CAAA;AAED,UAAM,EAAE,KAAK,kBACZ,MAAM,KAAK,YAAY;AAExB,QAAI,eAAe;AAClB,YAAM,QAAQ,IACb,cAAc,IAAI,OAAO,iBAAgB;AACxC,cAAM,EAAE,MAAK,IAAK,MAAM,KAAK,YAAY,eAAe;AAAA,UACvD,IAAI;AAAA,QAAA,CACJ;AAED,YAAI,OAAO;AACV,sBAAY,KAAK,KAAK;AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;;"}
|
1
|
+
{"version":3,"file":"SliceMachineManager.cjs","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t]);\n\n\t\t\t\t\t\t\t\tif (model) {\n\t\t\t\t\t\t\t\t\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["createPrismicAuthManager","UserManager","PrismicRepositoryManager","PluginsManager","ProjectManager","CustomTypesManager","SlicesManager","SnippetsManager","ScreenshotsManager","SimulatorManager","DocumentationManager","SliceTemplateLibraryManager","VersionsManager","TelemetryManager","GitManager","API_ENDPOINTS","sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices","prismicCustomTypesClient","buildPrismicRepositoryAPIEndpoint","createContentDigest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkGa,oBAAmB;AAAA,EAsB/B,YAAY,MAAyC;AArB7C;AAEA;AAER;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,SAAK,sBAAsBA,yBAAAA;AAEtB,SAAA,OAAO,IAAIC,YAAA,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAIC,yBAAA,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAIC,eAAA,eAAe,MAAM;AAAA,MACvC,eAAe,6BAAM;AAAA,IAAA,CACrB;AAEI,SAAA,UAAU,IAAIC,eAAA,eAAe,IAAI;AACjC,SAAA,cAAc,IAAIC,mBAAA,mBAAmB,IAAI;AACzC,SAAA,SAAS,IAAIC,cAAA,cAAc,IAAI;AAC/B,SAAA,WAAW,IAAIC,gBAAA,gBAAgB,IAAI;AACnC,SAAA,cAAc,IAAIC,mBAAA,mBAAmB,IAAI;A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,YACV;AAAA,UAAA,CACD;AAAA,QACF;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAGA,WAAO,UAAU,KAAK,CAAC,UAAU,aAAY;;AAC5C,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AACzD,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AAElD,aAAA,KAAK,KAAK,gBAAgB,aAAa;AAAA,IAAA,CAC9C;AAAA,EACF;AAAA,EAEQ,MAAM,kBAAe;AAG5B,UAAM,cACL,CAAA;AAED,UAAM,EAAE,KAAK,kBACZ,MAAM,KAAK,YAAY;AAExB,QAAI,eAAe;AAClB,YAAM,QAAQ,IACb,cAAc,IAAI,OAAO,iBAAgB;AACxC,cAAM,EAAE,MAAK,IAAK,MAAM,KAAK,YAAY,eAAe;AAAA,UACvD,IAAI;AAAA,QAAA,CACJ;AAED,YAAI,OAAO;AACV,sBAAY,KAAK,KAAK;AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SliceMachineManager.js","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t]);\n\n\t\t\t\t\t\t\t\tif (model) {\n\t\t\t\t\t\t\t\t\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MAkGa,oBAAmB;AAAA,EAsB/B,YAAY,MAAyC;AArB7C;AAEA;AAER;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,SAAK,sBAAsB;AAEtB,SAAA,OAAO,IAAI,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAI,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAI,eAAe,MAAM;AAAA,MACvC,eAAe,6BAAM;AAAA,IAAA,CACrB;AAEI,SAAA,UAAU,IAAI,eAAe,IAAI;AACjC,SAAA,cAAc,IAAI,mBAAmB,IAAI;AACzC,SAAA,SAAS,IAAI,cAAc,IAAI;AAC/B,SAAA,WAAW,IAAI,gBAAgB,IAAI;AACnC,SAAA,cAAc,IAAI,mBAAmB,IAAI;AACzC,SAAA,YAAY,IAAI,iBAAiB,IAAI;AACrC,SAAA,gBAAgB,IAAI,qBAAqB,IAAI;AAC7C,SAAA,uBAAuB,IAAI,4BAA4B,IAAI;AAE3D,SAAA,WAAW,IAAI,gBAAgB,IAAI;AAEnC,SAAA,YAAY,IAAI,iBAAiB,IAAI;AAErC,SAAA,MAAM,IAAI,WAAW,IAAI;AAE9B,SAAK,OAAM,6BAAM,QAAO,QAAQ,IAAG;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,8BAA2B;AAC1B,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,wBAAqB;AACpB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,kBAAe;AACP,WAAA;AAA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ACJ;AAED,YAAI,OAAO;AACV,sBAAY,KAAK,KAAK;AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;"}
|
1
|
+
{"version":3,"file":"SliceMachineManager.js","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t]);\n\n\t\t\t\t\t\t\t\tif (model) {\n\t\t\t\t\t\t\t\t\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MAkGa,oBAAmB;AAAA,EAsB/B,YAAY,MAAyC;AArB7C;AAEA;AAER;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,SAAK,sBAAsB;AAEtB,SAAA,OAAO,IAAI,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAI,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAI,eAAe,MAAM;AAAA,MACvC,eAAe,6BAAM;AAAA,IAAA,CACrB;AAEI,SAAA,UAAU,IAAI,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AS;AAAA;AAAA,YACT;AAAA,YACA,MAAM;AAAA;AAAA,cAEL,cAAc;AAAA,cACd,cAAc;AAAA,cACd,UAAU;AAAA,YACV;AAAA,UAAA,CACD;AAAA,QACF;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAGA,WAAO,UAAU,KAAK,CAAC,UAAU,aAAY;;AAC5C,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AACzD,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AAElD,aAAA,KAAK,KAAK,gBAAgB,aAAa;AAAA,IAAA,CAC9C;AAAA,EACF;AAAA,EAEQ,MAAM,kBAAe;AAG5B,UAAM,cACL,CAAA;AAED,UAAM,EAAE,KAAK,kBACZ,MAAM,KAAK,YAAY;AAExB,QAAI,eAAe;AAClB,YAAM,QAAQ,IACb,cAAc,IAAI,OAAO,iBAAgB;AACxC,cAAM,EAAE,MAAK,IAAK,MAAM,KAAK,YAAY,eAAe;AAAA,UACvD,IAAI;AAAA,QAAA,CACJ;AAED,YAAI,OAAO;AACV,sBAAY,KAAK,KAAK;AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;"}
|
@@ -80,12 +80,109 @@ class CustomTypesManager extends BaseManager.BaseManager {
|
|
80
80
|
errors: errors2
|
81
81
|
};
|
82
82
|
}
|
83
|
+
/**
|
84
|
+
* Update the Content Relationship API IDs for all existing custom types and
|
85
|
+
* slices. The change is determined by properties inside the `updateMeta`
|
86
|
+
* property.
|
87
|
+
*/
|
88
|
+
async updateContentRelationships(args) {
|
89
|
+
assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
|
90
|
+
const { model } = args;
|
91
|
+
let { newPath, previousPath } = args;
|
92
|
+
if (previousPath.join(".") !== newPath.join(".")) {
|
93
|
+
previousPath = [model.id, ...previousPath];
|
94
|
+
newPath = [model.id, ...newPath];
|
95
|
+
const crUpdates = [];
|
96
|
+
const customTypes = await this.readAllCustomTypes();
|
97
|
+
updateCustomTypeContentRelationships({
|
98
|
+
models: customTypes.models,
|
99
|
+
onUpdate: ({ previousModel, model: updatedModel }) => {
|
100
|
+
var _a;
|
101
|
+
assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
|
102
|
+
crUpdates.push({
|
103
|
+
updatePromise: (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", { model: updatedModel }),
|
104
|
+
rollback: () => {
|
105
|
+
var _a2;
|
106
|
+
(_a2 = this.sliceMachinePluginRunner) == null ? void 0 : _a2.callHook("custom-type:update", {
|
107
|
+
model: previousModel
|
108
|
+
});
|
109
|
+
}
|
110
|
+
});
|
111
|
+
},
|
112
|
+
previousPath,
|
113
|
+
newPath
|
114
|
+
});
|
115
|
+
const { libraries } = await this.slices.readAllSliceLibraries();
|
116
|
+
for (const library of libraries) {
|
117
|
+
const slices = await this.slices.readAllSlicesForLibrary({
|
118
|
+
libraryID: library.libraryID
|
119
|
+
});
|
120
|
+
updateSharedSliceContentRelationships({
|
121
|
+
models: slices.models,
|
122
|
+
onUpdate: ({ previousModel, model: updatedModel }) => {
|
123
|
+
var _a;
|
124
|
+
assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
|
125
|
+
crUpdates.push({
|
126
|
+
updatePromise: (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("slice:update", { libraryID: library.libraryID, model: updatedModel }),
|
127
|
+
rollback: () => {
|
128
|
+
var _a2;
|
129
|
+
(_a2 = this.sliceMachinePluginRunner) == null ? void 0 : _a2.callHook("slice:update", {
|
130
|
+
libraryID: library.libraryID,
|
131
|
+
model: previousModel
|
132
|
+
});
|
133
|
+
}
|
134
|
+
});
|
135
|
+
},
|
136
|
+
previousPath,
|
137
|
+
newPath
|
138
|
+
});
|
139
|
+
}
|
140
|
+
const crUpdatesResult = await Promise.all(crUpdates.map((update) => update.updatePromise));
|
141
|
+
if (crUpdatesResult.some((result) => result.errors.length > 0)) {
|
142
|
+
return {
|
143
|
+
errors: crUpdatesResult.flatMap((result) => result.errors),
|
144
|
+
rollback: async () => {
|
145
|
+
await Promise.all(crUpdates.map((update) => update.rollback()));
|
146
|
+
}
|
147
|
+
};
|
148
|
+
}
|
149
|
+
}
|
150
|
+
return { errors: [] };
|
151
|
+
}
|
83
152
|
async updateCustomType(args) {
|
153
|
+
var _a, _b;
|
84
154
|
assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
|
85
|
-
const
|
86
|
-
|
87
|
-
|
88
|
-
|
155
|
+
const { model } = args;
|
156
|
+
const { fieldIdChanged } = args.updateMeta ?? {};
|
157
|
+
let previousCustomType;
|
158
|
+
if (fieldIdChanged) {
|
159
|
+
const customTypeRead = await this.readCustomType({ id: model.id });
|
160
|
+
if (customTypeRead.errors.length > 0) {
|
161
|
+
return { errors: customTypeRead.errors };
|
162
|
+
}
|
163
|
+
if (!customTypeRead.model) {
|
164
|
+
throw new Error(`readCustomType succeeded reading custom type ${model.id} but model is undefined.`);
|
165
|
+
}
|
166
|
+
previousCustomType = customTypeRead.model;
|
167
|
+
}
|
168
|
+
const customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook("custom-type:update", { model });
|
169
|
+
if (customTypeUpdateResult.errors.length > 0) {
|
170
|
+
return { errors: customTypeUpdateResult.errors };
|
171
|
+
}
|
172
|
+
if (previousCustomType && fieldIdChanged) {
|
173
|
+
const crUpdateResult = await this.updateContentRelationships({
|
174
|
+
...fieldIdChanged,
|
175
|
+
model: previousCustomType
|
176
|
+
});
|
177
|
+
if (crUpdateResult.errors.length > 0) {
|
178
|
+
await ((_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", {
|
179
|
+
model: previousCustomType
|
180
|
+
}));
|
181
|
+
await ((_b = crUpdateResult.rollback) == null ? void 0 : _b.call(crUpdateResult));
|
182
|
+
return { errors: crUpdateResult.errors };
|
183
|
+
}
|
184
|
+
}
|
185
|
+
return { errors: [] };
|
89
186
|
}
|
90
187
|
async renameCustomType(args) {
|
91
188
|
assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
|
@@ -231,5 +328,117 @@ const InferSliceResponse = index.default.object({
|
|
231
328
|
}),
|
232
329
|
langSmithUrl: index.default.string().url().optional()
|
233
330
|
});
|
331
|
+
function updateCRCustomType(args) {
|
332
|
+
const [previousCustomTypeId, previousFieldId] = args.previousPath;
|
333
|
+
const [newCustomTypeId, newFieldId] = args.newPath;
|
334
|
+
if (!previousCustomTypeId || !newCustomTypeId) {
|
335
|
+
throw new Error("Could not find a customtype id in previousPath and/or newPath, which should not be possible.");
|
336
|
+
}
|
337
|
+
if (!previousFieldId || !newFieldId) {
|
338
|
+
throw new Error("Could not find a field id in previousPath and/or newPath, which should not be possible.");
|
339
|
+
}
|
340
|
+
const customType = shallowCloneIfObject(args.customType);
|
341
|
+
if (typeof customType === "string" || !customType.fields) {
|
342
|
+
return customType;
|
343
|
+
}
|
344
|
+
const matchedCustomTypeId = customType.id === previousCustomTypeId;
|
345
|
+
const newFields = customType.fields.map((fieldArg) => {
|
346
|
+
const customTypeField = shallowCloneIfObject(fieldArg);
|
347
|
+
if (typeof customTypeField === "string") {
|
348
|
+
if (matchedCustomTypeId && customTypeField === previousFieldId && customTypeField !== newFieldId) {
|
349
|
+
return newFieldId;
|
350
|
+
}
|
351
|
+
return customTypeField;
|
352
|
+
}
|
353
|
+
if (matchedCustomTypeId && customTypeField.id === previousFieldId && customTypeField.id !== newFieldId) {
|
354
|
+
customTypeField.id = newFieldId;
|
355
|
+
}
|
356
|
+
return {
|
357
|
+
...customTypeField,
|
358
|
+
customtypes: customTypeField.customtypes.map((customTypeArg) => {
|
359
|
+
const nestedCustomType = shallowCloneIfObject(customTypeArg);
|
360
|
+
if (typeof nestedCustomType === "string" || !nestedCustomType.fields || // Since we are on the last level, if we don't start matching right
|
361
|
+
// at the custom type id, we can return exit early because it's not
|
362
|
+
// a match.
|
363
|
+
nestedCustomType.id !== previousCustomTypeId) {
|
364
|
+
return nestedCustomType;
|
365
|
+
}
|
366
|
+
return {
|
367
|
+
...nestedCustomType,
|
368
|
+
fields: nestedCustomType.fields.map((fieldArg2) => {
|
369
|
+
const nestedCustomTypeField = shallowCloneIfObject(fieldArg2);
|
370
|
+
if (nestedCustomTypeField === previousFieldId && nestedCustomTypeField !== newFieldId) {
|
371
|
+
return newFieldId;
|
372
|
+
}
|
373
|
+
return nestedCustomTypeField;
|
374
|
+
})
|
375
|
+
};
|
376
|
+
})
|
377
|
+
};
|
378
|
+
});
|
379
|
+
return { ...customType, fields: newFields };
|
380
|
+
}
|
381
|
+
function updateFieldContentRelationships(args) {
|
382
|
+
var _a, _b;
|
383
|
+
const { field, ...updateMeta } = args;
|
384
|
+
if (field.type !== "Link" || ((_a = field.config) == null ? void 0 : _a.select) !== "document" || !((_b = field.config) == null ? void 0 : _b.customtypes)) {
|
385
|
+
return field;
|
386
|
+
}
|
387
|
+
const newCustomTypes = field.config.customtypes.map((customType) => {
|
388
|
+
return updateCRCustomType({ customType, ...updateMeta });
|
389
|
+
});
|
390
|
+
return {
|
391
|
+
...field,
|
392
|
+
config: { ...field.config, customtypes: newCustomTypes }
|
393
|
+
};
|
394
|
+
}
|
395
|
+
function updateCustomTypeContentRelationships(args) {
|
396
|
+
const { models, previousPath, newPath, onUpdate } = args;
|
397
|
+
for (const { model: customType } of models) {
|
398
|
+
const updatedCustomType = customtypes.traverseCustomType({
|
399
|
+
customType,
|
400
|
+
onField: ({ field }) => {
|
401
|
+
return updateFieldContentRelationships({
|
402
|
+
field,
|
403
|
+
previousPath,
|
404
|
+
newPath
|
405
|
+
});
|
406
|
+
}
|
407
|
+
});
|
408
|
+
if (!isEqualModel(customType, updatedCustomType)) {
|
409
|
+
onUpdate({ model: updatedCustomType, previousModel: customType });
|
410
|
+
}
|
411
|
+
}
|
412
|
+
}
|
413
|
+
function updateSharedSliceContentRelationships(args) {
|
414
|
+
const { models, previousPath, newPath, onUpdate } = args;
|
415
|
+
for (const { model: slice } of models) {
|
416
|
+
const updateSlice = customtypes.traverseSharedSlice({
|
417
|
+
path: ["."],
|
418
|
+
slice,
|
419
|
+
onField: ({ field }) => {
|
420
|
+
return updateFieldContentRelationships({
|
421
|
+
field,
|
422
|
+
previousPath,
|
423
|
+
newPath
|
424
|
+
});
|
425
|
+
}
|
426
|
+
});
|
427
|
+
if (!isEqualModel(slice, updateSlice)) {
|
428
|
+
onUpdate({ model: updateSlice, previousModel: slice });
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
function isEqualModel(modelA, modelB) {
|
433
|
+
return JSON.stringify(modelA) === JSON.stringify(modelB);
|
434
|
+
}
|
435
|
+
function shallowCloneIfObject(value) {
|
436
|
+
if (typeof value === "object") {
|
437
|
+
return { ...value };
|
438
|
+
}
|
439
|
+
return value;
|
440
|
+
}
|
234
441
|
exports.CustomTypesManager = CustomTypesManager;
|
442
|
+
exports.updateCustomTypeContentRelationships = updateCustomTypeContentRelationships;
|
443
|
+
exports.updateSharedSliceContentRelationships = updateSharedSliceContentRelationships;
|
235
444
|
//# sourceMappingURL=CustomTypesManager.cjs.map
|