@upstart.gg/sdk 0.0.106 → 0.0.107
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/shared/ajv.d.ts.map +1 -1
- package/dist/shared/ajv.js +1 -1
- package/dist/shared/attributes.d.ts.map +1 -1
- package/dist/shared/attributes.js +1 -1
- package/dist/shared/brick-manifest.js +1 -1
- package/dist/shared/bricks/manifests/accordion.manifest.d.ts +6 -6
- package/dist/shared/bricks/manifests/accordion.manifest.js +1 -1
- package/dist/shared/bricks/manifests/all-manifests.js +1 -1
- package/dist/shared/bricks/manifests/button.manifest.js +1 -1
- package/dist/shared/bricks/manifests/card.manifest.js +1 -1
- package/dist/shared/bricks/manifests/carousel.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/carousel.manifest.js +1 -1
- package/dist/shared/bricks/manifests/container.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/container.manifest.js +1 -1
- package/dist/shared/bricks/manifests/divider.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/divider.manifest.js +1 -1
- package/dist/shared/bricks/manifests/footer.manifest.js +1 -1
- package/dist/shared/bricks/manifests/form.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/form.manifest.js +1 -1
- package/dist/shared/bricks/manifests/hero.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/hero.manifest.js +1 -1
- package/dist/shared/bricks/manifests/icon.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/icon.manifest.js +1 -1
- package/dist/shared/bricks/manifests/image.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/image.manifest.js +1 -1
- package/dist/shared/bricks/manifests/images-gallery.manifest.js +1 -1
- package/dist/shared/bricks/manifests/map.manifest.d.ts +16 -3
- package/dist/shared/bricks/manifests/map.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/map.manifest.js +1 -1
- package/dist/shared/bricks/manifests/navbar.manifest.d.ts +6 -6
- package/dist/shared/bricks/manifests/navbar.manifest.js +1 -1
- package/dist/shared/bricks/manifests/sidebar.manifest.d.ts +6 -6
- package/dist/shared/bricks/manifests/sidebar.manifest.js +1 -1
- package/dist/shared/bricks/manifests/social-links.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/social-links.manifest.js +1 -1
- package/dist/shared/bricks/manifests/testimonials.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/testimonials.manifest.js +1 -1
- package/dist/shared/bricks/manifests/text.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/text.manifest.js +1 -1
- package/dist/shared/bricks/manifests/timeline.manifest.d.ts +6 -6
- package/dist/shared/bricks/manifests/timeline.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/timeline.manifest.js +1 -1
- package/dist/shared/bricks/manifests/video.manifest.d.ts +3 -3
- package/dist/shared/bricks/manifests/video.manifest.js +1 -1
- package/dist/shared/bricks/props/align.js +1 -1
- package/dist/shared/bricks/props/background.js +1 -1
- package/dist/shared/bricks/props/boolean.js +1 -1
- package/dist/shared/bricks/props/border.d.ts +6 -6
- package/dist/shared/bricks/props/border.js +1 -1
- package/dist/shared/bricks/props/color.js +1 -1
- package/dist/shared/bricks/props/container.js +1 -1
- package/dist/shared/bricks/props/css-length.js +1 -1
- package/dist/shared/bricks/props/datasource.js +1 -1
- package/dist/shared/bricks/props/date.js +1 -1
- package/dist/shared/bricks/props/effects.js +1 -1
- package/dist/shared/bricks/props/enum.js +1 -1
- package/dist/shared/bricks/props/file.js +1 -1
- package/dist/shared/bricks/props/geolocation.d.ts +7 -11
- package/dist/shared/bricks/props/geolocation.d.ts.map +1 -1
- package/dist/shared/bricks/props/geolocation.js +1 -1
- package/dist/shared/bricks/props/helpers.d.ts +3 -1
- package/dist/shared/bricks/props/helpers.d.ts.map +1 -1
- package/dist/shared/bricks/props/helpers.js +1 -1
- package/dist/shared/bricks/props/image.js +1 -1
- package/dist/shared/bricks/props/number.d.ts +1 -1
- package/dist/shared/bricks/props/number.d.ts.map +1 -1
- package/dist/shared/bricks/props/number.js +1 -1
- package/dist/shared/bricks/props/padding.js +1 -1
- package/dist/shared/bricks/props/position.js +1 -1
- package/dist/shared/bricks/props/string.d.ts +1 -1
- package/dist/shared/bricks/props/string.d.ts.map +1 -1
- package/dist/shared/bricks/props/string.js +1 -1
- package/dist/shared/bricks/props/text.js +1 -1
- package/dist/shared/bricks.d.ts +33 -33
- package/dist/shared/bricks.js +1 -1
- package/dist/shared/chunk-3G4PLX4N.js +4 -0
- package/dist/shared/{chunk-LOFXGDAK.js → chunk-4RMUHWWU.js} +1 -1
- package/dist/shared/{chunk-I3HSLGFA.js → chunk-5NDKGZ7L.js} +1 -1
- package/dist/shared/chunk-62VKGHN6.js +3 -0
- package/dist/shared/{chunk-ATDJCXC2.js → chunk-64RLYCR2.js} +1 -1
- package/dist/shared/{chunk-HIBTEX2T.js → chunk-6IOXG7MM.js} +1 -1
- package/dist/shared/{chunk-VTFWVTPI.js → chunk-6P7HLUMQ.js} +1 -1
- package/dist/shared/{chunk-CTRS76PX.js → chunk-6PWZKDRF.js} +1 -1
- package/dist/shared/chunk-6WZXFY7L.js +3 -0
- package/dist/shared/chunk-7LKXIVLH.js +3 -0
- package/dist/shared/chunk-7QJQRAH7.js +3 -0
- package/dist/shared/{chunk-BJSO43AS.js → chunk-DHF2VJH7.js} +1 -1
- package/dist/shared/{chunk-ZWYLKIBI.js → chunk-E3EPUQU4.js} +1 -1
- package/dist/shared/chunk-E3NQZZ2P.js +3 -0
- package/dist/shared/chunk-ENWFMNZY.js +3 -0
- package/dist/shared/{chunk-7E67XSKP.js → chunk-FDS5YHGZ.js} +1 -1
- package/dist/shared/{chunk-YZ5Y4WE6.js → chunk-FGRCD7GG.js} +1 -1
- package/dist/shared/chunk-GN5DXY6H.js +3 -0
- package/dist/shared/chunk-GYNIOIBM.js +3 -0
- package/dist/shared/{chunk-IXJX7EQ3.js → chunk-HAI73HEN.js} +1 -1
- package/dist/shared/chunk-IEXUC6I2.js +7 -0
- package/dist/shared/{chunk-L3TKLJKK.js → chunk-JOMVOZI5.js} +1 -1
- package/dist/shared/chunk-K5ORABHX.js +3 -0
- package/dist/shared/{chunk-XDCGA4WT.js → chunk-M7SU4L3J.js} +1 -1
- package/dist/shared/{chunk-33FU4KGU.js → chunk-MELCM74Q.js} +1 -1
- package/dist/shared/{chunk-6OKXZL6R.js → chunk-MRBC7NBM.js} +1 -1
- package/dist/shared/{chunk-U5XOIYSS.js → chunk-NL2OJKXK.js} +1 -1
- package/dist/shared/{chunk-H7OYUKBW.js → chunk-OGNNI674.js} +1 -1
- package/dist/shared/{chunk-2DI5SIVV.js → chunk-PNNMX7Z7.js} +1 -1
- package/dist/shared/chunk-PZOGR3ER.js +3 -0
- package/dist/shared/{chunk-PX7QSNLO.js → chunk-QQZ5HDFA.js} +1 -1
- package/dist/shared/chunk-QUFRMM2S.js +3 -0
- package/dist/shared/{chunk-OUI2VDNM.js → chunk-RAS2UZS6.js} +1 -1
- package/dist/shared/chunk-RKGXHPJX.js +3 -0
- package/dist/shared/{chunk-O3FJP65T.js → chunk-RRCFAX4L.js} +1 -1
- package/dist/shared/chunk-SONDO36R.js +3 -0
- package/dist/shared/{chunk-HYVQXAK5.js → chunk-TWSHGLIC.js} +1 -1
- package/dist/shared/{chunk-UYZP24VV.js → chunk-UA72HEYF.js} +1 -1
- package/dist/shared/{chunk-VBWC36L2.js → chunk-VM34BXEG.js} +1 -1
- package/dist/shared/{chunk-E4UAVLKC.js → chunk-WSJYO3DM.js} +1 -1
- package/dist/shared/{chunk-CAVNF3BU.js → chunk-WUYA4JIP.js} +1 -1
- package/dist/shared/{chunk-HBM4DPIW.js → chunk-WWYFOOW3.js} +1 -1
- package/dist/shared/chunk-XBRRT4ZE.js +3 -0
- package/dist/shared/{chunk-P5DZK4TS.js → chunk-XNAM26NU.js} +1 -1
- package/dist/shared/{chunk-JH3NRO6M.js → chunk-YR6RZXVH.js} +1 -1
- package/dist/shared/{chunk-G7LX3UKQ.js → chunk-YRO666MC.js} +1 -1
- package/dist/shared/{chunk-ALFOZHAH.js → chunk-ZW2ZLFRI.js} +1 -1
- package/dist/shared/datasources/external/http-json/options.d.ts +1 -1
- package/dist/shared/datasources/types.d.ts +3 -3
- package/dist/shared/images.js +1 -1
- package/dist/shared/page.d.ts +6 -6
- package/dist/shared/page.js +1 -1
- package/dist/shared/responsive.d.ts +1 -1
- package/dist/shared/responsive.js +1 -1
- package/dist/shared/site.d.ts +38 -38
- package/dist/shared/site.d.ts.map +1 -1
- package/dist/shared/site.js +1 -1
- package/dist/shared/sitemap.d.ts +4 -4
- package/dist/shared/sitemap.js +1 -1
- package/dist/shared/theme.js +1 -1
- package/dist/shared/utils/schema.d.ts +4 -1
- package/dist/shared/utils/schema.d.ts.map +1 -1
- package/dist/shared/utils/schema.js +1 -1
- package/package.json +2 -2
- package/dist/node/cli/api.d.ts +0 -34
- package/dist/node/cli/api.d.ts.map +0 -1
- package/dist/node/cli/api.js +0 -5
- package/dist/node/cli/api.js.map +0 -1
- package/dist/node/cli/commands/cmd-build.d.ts +0 -3
- package/dist/node/cli/commands/cmd-build.d.ts.map +0 -1
- package/dist/node/cli/commands/cmd-build.js +0 -7
- package/dist/node/cli/commands/cmd-build.js.map +0 -1
- package/dist/node/cli/commands/login/cmd-login.d.ts +0 -14
- package/dist/node/cli/commands/login/cmd-login.d.ts.map +0 -1
- package/dist/node/cli/commands/login/cmd-login.js +0 -12
- package/dist/node/cli/commands/login/cmd-login.js.map +0 -1
- package/dist/node/cli/commands/logout/cmd-logout.d.ts +0 -3
- package/dist/node/cli/commands/logout/cmd-logout.d.ts.map +0 -1
- package/dist/node/cli/commands/logout/cmd-logout.js +0 -5
- package/dist/node/cli/commands/logout/cmd-logout.js.map +0 -1
- package/dist/node/cli/commands/publish/cmd-publish.d.ts +0 -3
- package/dist/node/cli/commands/publish/cmd-publish.d.ts.map +0 -1
- package/dist/node/cli/commands/publish/cmd-publish.js +0 -35
- package/dist/node/cli/commands/publish/cmd-publish.js.map +0 -1
- package/dist/node/cli/commands/publish/parse-gitignore.d.ts +0 -56
- package/dist/node/cli/commands/publish/parse-gitignore.d.ts.map +0 -1
- package/dist/node/cli/commands/publish/parse-gitignore.js +0 -16
- package/dist/node/cli/commands/publish/parse-gitignore.js.map +0 -1
- package/dist/node/cli/commands/publish/uploader.d.ts +0 -20
- package/dist/node/cli/commands/publish/uploader.d.ts.map +0 -1
- package/dist/node/cli/commands/publish/uploader.js +0 -19
- package/dist/node/cli/commands/publish/uploader.js.map +0 -1
- package/dist/node/cli/constants.d.ts +0 -11
- package/dist/node/cli/constants.d.ts.map +0 -1
- package/dist/node/cli/constants.js +0 -4
- package/dist/node/cli/constants.js.map +0 -1
- package/dist/node/cli/is-logged-in.d.ts +0 -2
- package/dist/node/cli/is-logged-in.d.ts.map +0 -1
- package/dist/node/cli/is-logged-in.js +0 -5
- package/dist/node/cli/is-logged-in.js.map +0 -1
- package/dist/node/cli/program.d.ts +0 -3
- package/dist/node/cli/program.d.ts.map +0 -1
- package/dist/node/cli/program.js +0 -49
- package/dist/node/cli/program.js.map +0 -1
- package/dist/node/cli/store.d.ts +0 -9
- package/dist/node/cli/store.d.ts.map +0 -1
- package/dist/node/cli/store.js +0 -4
- package/dist/node/cli/store.js.map +0 -1
- package/dist/node/cli/tests/api.test.d.ts +0 -2
- package/dist/node/cli/tests/api.test.d.ts.map +0 -1
- package/dist/node/cli/types.d.ts +0 -30
- package/dist/node/cli/types.d.ts.map +0 -1
- package/dist/node/cli/types.js +0 -3
- package/dist/node/cli/types.js.map +0 -1
- package/dist/node/cli/utils.d.ts +0 -6
- package/dist/node/cli/utils.d.ts.map +0 -1
- package/dist/node/cli/utils.js +0 -4
- package/dist/node/cli/utils.js.map +0 -1
- package/dist/node/shared/config.d.ts +0 -6
- package/dist/node/shared/config.d.ts.map +0 -1
- package/dist/node/shared/config.js +0 -11
- package/dist/node/shared/config.js.map +0 -1
- package/dist/node/shared/logger.d.ts +0 -30
- package/dist/node/shared/logger.d.ts.map +0 -1
- package/dist/node/shared/logger.js +0 -5
- package/dist/node/shared/logger.js.map +0 -1
- package/dist/shared/chunk-3ZGRY444.js +0 -3
- package/dist/shared/chunk-AMGHA7QH.js +0 -3
- package/dist/shared/chunk-DC5DWF7B.js +0 -3
- package/dist/shared/chunk-DY2YCYZ6.js +0 -3
- package/dist/shared/chunk-EHH677K5.js +0 -4
- package/dist/shared/chunk-FD3KX2U7.js +0 -3
- package/dist/shared/chunk-G3JO5DM5.js +0 -3
- package/dist/shared/chunk-JAAPJQNK.js +0 -3
- package/dist/shared/chunk-JDBVMPSI.js +0 -3
- package/dist/shared/chunk-U76JDFWJ.js +0 -7
- package/dist/shared/chunk-UL7L3HYV.js +0 -3
- package/dist/shared/chunk-X42WBJTN.js +0 -3
- package/dist/shared/chunk-XB3X4P3I.js +0 -3
- package/dist/shared/chunk-YGHBFXR6.js +0 -3
- package/dist/shared/chunk-YJTGZQEV.js +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/node/cli/commands/publish/uploader.ts","../../../../../src/node/cli/constants.ts","../../../../../src/node/shared/logger.ts","../../../../../src/node/cli/commands/publish/parse-gitignore.ts","../../../../../src/node/cli/store.ts","../../../../../src/node/cli/api.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport crypto from \"node:crypto\";\nimport fg from \"fast-glob\";\nimport { API_BASE_URL, DEFAULT_UPLOAD_MAX_CONCURRENCY } from \"../../constants\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport { pipeline } from \"node:stream\";\nimport type { GenericApiError } from \"../../types\";\nimport { logger } from \"~/node/shared/logger\";\nimport chalk from \"chalk\";\nimport FormData from \"form-data\";\nimport parseGitIgnore from \"./parse-gitignore\";\nimport PQueue from \"p-queue\";\nimport ora from \"ora\";\nimport { customAlphabet } from \"nanoid\";\nimport { post } from \"../../api\";\n\ninterface UploadStats {\n fileName: string;\n fileSize: number;\n uploadDuration: number;\n statusCode: number;\n serverResponse: string;\n}\n\nclass UploadError extends Error implements GenericApiError {\n constructor(\n public error: string,\n public error_description: string,\n public filename: string,\n ) {\n super(`${error}: ${error_description}`);\n this.name = \"UploadError\";\n }\n}\n\ninterface UploadConfig {\n maxDataSize: number;\n retryAttempts: number;\n retryDelay: number;\n}\n\nconst defaultConfig: UploadConfig = {\n maxDataSize: 12 * 1024 * 1024, // 12MB\n retryAttempts: 2,\n retryDelay: 1000,\n};\n\nconst agent = new http.Agent({\n keepAlive: true,\n maxSockets: 10,\n keepAliveMsecs: 3000, // Keep connections open for 3 seconds\n});\n\nasync function discoverFiles(templateDir: string): Promise<string[]> {\n const gitignore = path.join(templateDir, \".gitignore\");\n const gitignoreExists = fs.existsSync(gitignore);\n const gitignored = gitignoreExists ? parseGitIgnore(fs.readFileSync(gitignore, \"utf-8\")).patterns : [];\n\n return fg(\"**/*\", {\n cwd: templateDir,\n onlyFiles: true,\n dot: true,\n absolute: true,\n ignore: [\n \"node_modules/**\",\n \".cache/**\",\n \"**/.DS_Store\",\n \".gitignore\",\n \".env\",\n \".env.*\",\n \".git/**\",\n \"dist/**\",\n ...gitignored,\n ],\n });\n}\n\nasync function uploadFile(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n const uploadWithRetry = async (attempt: number): Promise<UploadStats> => {\n try {\n return await performUpload(filePath, relativePath, uploadUrl, templateId, spinner, token, config);\n } catch (error) {\n if (attempt < config.retryAttempts) {\n logger.warn(`Retrying upload for ${relativePath} (attempt ${attempt + 1})`);\n await new Promise((resolve) => setTimeout(resolve, config.retryDelay));\n return uploadWithRetry(attempt + 1);\n }\n throw error;\n }\n };\n\n return uploadWithRetry(0);\n}\n\nasync function performUpload(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n return new Promise<UploadStats>((resolve, reject) => {\n const stats = fs.statSync(filePath);\n const fileName = path.basename(filePath);\n const startTime = Date.now();\n\n const form = new FormData({\n maxDataSize: config.maxDataSize,\n });\n const fileStream = fs.createReadStream(filePath);\n let totalUploaded = 0;\n\n const updateProgress = (chunk: Buffer | string) => {\n totalUploaded += chunk.length;\n };\n\n fileStream.on(\"data\", updateProgress);\n form.append(\"file\", fileStream, {\n filename: fileName,\n knownLength: stats.size,\n });\n\n const options: https.RequestOptions = {\n agent,\n method: \"POST\",\n headers: {\n authorization: `Bearer ${token}`,\n \"x-upstart-template-file-path\": relativePath,\n \"x-upstart-template-id\": templateId,\n ...form.getHeaders(),\n },\n };\n\n const protocol = uploadUrl.startsWith(\"https\") ? https : http;\n const req = protocol.request(uploadUrl, options, (res) => {\n let responseBody = \"\";\n res.on(\"data\", (chunk) => {\n responseBody += chunk;\n });\n\n res.on(\"end\", () => {\n const endTime = Date.now();\n const uploadStats: UploadStats = {\n fileName,\n fileSize: stats.size,\n uploadDuration: endTime - startTime,\n statusCode: res.statusCode ?? 0,\n serverResponse: responseBody,\n };\n\n if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {\n spinner.text = `Uploaded ${relativePath}`;\n resolve(uploadStats);\n } else {\n let errorObject: UploadError;\n if (res.headers[\"content-type\"]?.startsWith(\"application/json\")) {\n const parsedError = JSON.parse(responseBody);\n errorObject = new UploadError(\n parsedError.error || \"unknown_error\",\n parsedError.error_description || \"Unknown error occurred\",\n relativePath,\n );\n } else {\n errorObject = new UploadError(\n \"unknown_error\",\n responseBody || \"Unknown error occurred\",\n relativePath,\n );\n }\n\n spinner.fail(\n `Failed to upload ${relativePath} [${errorObject.error}] ${errorObject.error_description}`,\n );\n\n reject(errorObject);\n }\n });\n });\n\n req.on(\"error\", (error) => {\n reject(new UploadError(\"request_error\", error.message, relativePath));\n });\n\n pipeline(form, req, (err) => {\n if (err) {\n reject(\n new UploadError(\"pipeline_error\", `Pipeline failed for ${fileName}: ${err.message}`, relativePath),\n );\n }\n });\n });\n}\n\nfunction reportUploadStatistics(\n templateId: string,\n uploadedFiles: UploadStats[],\n failedFiles: PromiseRejectedResult[],\n) {\n if (failedFiles.length > 0) {\n logger.error(chalk.red(`Failed to upload ${failedFiles.length} files:`));\n failedFiles.forEach((failure) => {\n const error = failure.reason as UploadError;\n logger.error(`- ${error.filename}: ${error.error_description} (${error.error})`);\n });\n } else {\n logger.info(\n chalk.green(`Uploaded ${uploadedFiles.length} files successfully for template ${templateId}.\\n`),\n );\n }\n}\n\nexport async function uploadTemplate(\n templateId: string,\n templateDir: string,\n token: string,\n dryRun = false,\n config: Partial<UploadConfig> = {},\n) {\n const fullConfig = { ...defaultConfig, ...config };\n const queue = new PQueue({ concurrency: DEFAULT_UPLOAD_MAX_CONCURRENCY });\n const files = await discoverFiles(templateDir);\n const filesCount = files.length;\n const signatures: Record<string, string> = {};\n // generate a upload id\n const uploadId = generateUploadId();\n let completedUploads = 0;\n\n // compute signatures\n for (const file of files) {\n const relativePath = path.relative(templateDir, file);\n const md5 = await sha1sum(file);\n signatures[relativePath] = md5;\n }\n\n if (dryRun) {\n logger.info(\"Dry run mode enabled. Skipping upload.\\n\");\n logger.info(\"The following files would have been uploaded:\");\n files.forEach((file) => logger.info(`- ${file}`));\n process.exit(0);\n }\n\n const spinner = ora(`Uploading ${filesCount} files...`).start();\n\n // upload files\n const uploadPromises = files.map((file) => {\n const fullPath = path.resolve(templateDir, file);\n const relativePath = path.relative(templateDir, file);\n const url = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}`;\n return queue.add(async () => {\n const result = await uploadFile(fullPath, relativePath, url, templateId, spinner, token, fullConfig);\n completedUploads++;\n return result;\n });\n });\n\n const results = await Promise.allSettled(uploadPromises);\n spinner.stop();\n\n const uploadedFiles = results.filter(\n (result): result is PromiseFulfilledResult<UploadStats> => result.status === \"fulfilled\",\n );\n\n const failedFiles = results.filter(\n (result): result is PromiseRejectedResult => result.status === \"rejected\",\n );\n\n reportUploadStatistics(\n templateId,\n uploadedFiles.map((r) => r.value),\n failedFiles,\n );\n\n // finalize upload\n if (!failedFiles.length && uploadedFiles.length) {\n const finalizeUrl = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}/finalize`;\n const finalizePayload = {\n signatures,\n };\n\n const finalizeResponse = await post(finalizeUrl, finalizePayload);\n\n if (finalizeResponse.isError) {\n logger.error(\n `Failed to finalize upload: ${finalizeResponse.data.error_description} (${finalizeResponse.data.error})`,\n );\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles: [],\n success: false,\n };\n }\n }\n\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles,\n success: failedFiles.length === 0,\n };\n}\n\nasync function sha1sum(filePath: string): Promise<string> {\n const hash = await crypto.subtle.digest(\"SHA-1\", fs.readFileSync(filePath));\n // convert arrayBuffer to hex\n return Array.from(new Uint8Array(hash))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\nfunction generateUploadId(): string {\n const randomId = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 5);\n const now = new Date();\n const year = now.getUTCFullYear();\n const month = (now.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = now.getUTCDate().toString().padStart(2, \"0\");\n const hours = now.getUTCHours().toString().padStart(2, \"0\");\n const minutes = now.getUTCMinutes().toString().padStart(2, \"0\");\n const seconds = now.getUTCSeconds().toString().padStart(2, \"0\");\n return `${year}${month}${day}${hours}${minutes}${seconds}_${randomId()}`;\n}\n","export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\n// import { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\nconst VERSION = 0.1;\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${VERSION}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","/*!\n * parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>\n * Copyright (c) 2015-present, Jon Schlinkert.\n * Released under the MIT License.\n *\n * Converted to typescript by Matthias E. <matthias@upstart.gg>\n */\n\nimport * as fs from \"node:fs\";\n\n// eslint-disable-next-line no-control-regex\nconst INVALID_PATH_CHARS_REGEX = /[<>\"|?*\\n\\r\\t\\f\\x00-\\x1F]/;\nconst GLOBSTAR_REGEX = /(?:^|\\/)[*]{2}($|\\/)/;\nconst MAX_PATH_LENGTH = 260 - 12;\n\ninterface ParseOptions {\n path?: string;\n dedupe?: boolean;\n unique?: boolean;\n ignore?: string[];\n unignore?: string[];\n format?: boolean;\n formatSection?: (section: Section) => string;\n}\n\ninterface Section {\n name: string;\n comment?: string;\n patterns: string[];\n}\n\ninterface ParsedGitignore {\n sections: Section[];\n patterns: string[];\n path?: string;\n input: Buffer;\n format: (opts?: ParseOptions) => string;\n dedupe: (opts?: ParseOptions) => ParsedGitignore;\n globs: (opts?: ParseOptions) => GlobResult[];\n}\n\ninterface GlobResult {\n type: \"ignore\" | \"unignore\";\n path: string | null;\n patterns: string[];\n index: number;\n}\n\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n v !== null && typeof v === \"object\" && !Array.isArray(v);\n\nconst isValidPath = (input: unknown): input is string =>\n typeof input === \"string\" && input.length <= MAX_PATH_LENGTH && !INVALID_PATH_CHARS_REGEX.test(input);\n\nconst split = (str: string): string[] => str.split(/\\r\\n?|\\n/);\nconst isComment = (str: string): boolean => str.startsWith(\"#\");\nconst isParsed = (input: unknown): input is ParsedGitignore =>\n isObject(input) && Array.isArray(input.patterns) && Array.isArray(input.sections);\n\nconst patterns = (input: string): string[] =>\n split(input)\n .map((l) => l.trim())\n .filter((line) => line !== \"\" && !isComment(line));\n\nconst parse = (input: string | ParsedGitignore, options: ParseOptions = {}): ParsedGitignore => {\n let filepath = options.path;\n\n if (isParsed(input)) return input;\n if (isValidPath(input) && fs.existsSync(input)) {\n filepath = input;\n input = fs.readFileSync(input, \"utf8\");\n }\n\n const lines = split(input);\n const names = new Map<string, Section>();\n\n let parsed: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let section: Section = { name: \"default\", patterns: [] };\n let prev: Section | null = null;\n\n for (const line of lines) {\n const value = line.trim();\n\n if (value.startsWith(\"#\")) {\n const [, name] = /^#+\\s*(.*)\\s*$/.exec(value) || [];\n\n if (prev) {\n names.delete(prev.name);\n prev.comment = prev.comment ? `${prev.comment}\\n${value}` : value;\n prev.name = name ? `${prev.name.trim()}\\n${name.trim()}` : prev.name.trim();\n names.set(prev.name.toLowerCase().trim(), prev);\n continue;\n }\n\n section = { name: name?.trim() || \"\", comment: value, patterns: [] };\n names.set(section.name.toLowerCase(), section);\n parsed.sections.push(section);\n prev = section;\n continue;\n }\n\n if (value !== \"\") {\n section.patterns.push(value);\n parsed.patterns.push(value);\n }\n\n prev = null;\n }\n\n if (options.dedupe === true || options.unique === true) {\n parsed = dedupe(parsed, { ...options, format: false });\n }\n\n parsed.path = filepath;\n parsed.input = Buffer.from(input);\n parsed.format = (opts?: ParseOptions) => format(parsed, { ...options, ...opts });\n parsed.dedupe = (opts?: ParseOptions) => dedupe(parsed, { ...options, ...opts });\n parsed.globs = (opts?: ParseOptions) => globs(parsed, { path: filepath, ...options, ...opts });\n return parsed;\n};\n\nconst parseFile = (filepath: string, options?: ParseOptions): ParsedGitignore =>\n parse(fs.readFileSync(filepath, \"utf8\"), options);\n\nconst dedupe = (input: string | ParsedGitignore, options: ParseOptions): ParsedGitignore => {\n const parsed = parse(input, { ...options, dedupe: false });\n\n const names = new Map<string, Section>();\n const res: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let current: Section;\n\n // first, combine duplicate sections\n for (const section of parsed.sections) {\n const { name = \"\", comment, patterns } = section;\n const key = name.trim().toLowerCase();\n\n for (const pattern of patterns) {\n if (!res.patterns.includes(pattern)) {\n res.patterns.push(pattern);\n }\n }\n\n if (name && names.has(key)) {\n current = names.get(key)!;\n current.patterns = [...current.patterns, ...patterns];\n } else {\n current = { name, comment, patterns };\n res.sections.push(current);\n names.set(key, current);\n }\n }\n\n // next, de-dupe patterns in each section\n for (const section of res.sections) {\n section.patterns = [...new Set(section.patterns)];\n }\n\n return res;\n};\n\nconst glob = (pattern: string): string => {\n // Return if a glob pattern has already been specified for sub-directories\n if (GLOBSTAR_REGEX.test(pattern)) {\n return pattern;\n }\n\n // If there is a separator at the beginning or middle (or both) of the pattern,\n // then the pattern is relative to the directory level of the particular .gitignore\n // file itself. Otherwise the pattern may also match at any level below the\n // .gitignore level. relative paths only\n let relative = false;\n if (pattern.startsWith(\"/\")) {\n pattern = pattern.slice(1);\n relative = true;\n } else if (pattern.slice(1, pattern.length - 1).includes(\"/\")) {\n relative = true;\n }\n\n // If there is a separator at the end of the pattern then the pattern will only match directories.\n pattern += pattern.endsWith(\"/\") ? \"**/\" : \"/**\";\n\n // If not relative, the pattern can match any files and directories.\n return relative ? pattern : `**/${pattern}`;\n};\n\nconst globs = (input: string | ParsedGitignore, options: ParseOptions = {}): GlobResult[] => {\n const parsed = parse(input, options);\n const result: GlobResult[] = [];\n let index = 0;\n\n const globPatterns = parsed.patterns\n .concat(options.ignore || [])\n .concat((options.unignore || []).map((p) => (!p.startsWith(\"!\") ? `!${p}` : p)));\n\n const push = (prefix: string, pattern: string) => {\n const prev = result[result.length - 1];\n const type = prefix ? \"unignore\" : \"ignore\";\n\n if (prev && prev.type === type) {\n if (!prev.patterns.includes(pattern)) {\n prev.patterns.push(pattern);\n }\n } else {\n result.push({ type, path: options.path || null, patterns: [pattern], index });\n index++;\n }\n };\n\n for (let pattern of globPatterns) {\n let prefix = \"\";\n\n // An optional prefix \"!\" which negates the pattern; any matching file excluded by\n // a previous pattern will become included again\n if (pattern.startsWith(\"!\")) {\n pattern = pattern.slice(1);\n prefix = \"!\";\n }\n\n // add the raw pattern to the results\n push(prefix, pattern.startsWith(\"/\") ? pattern.slice(1) : pattern);\n\n // add the glob pattern to the results\n push(prefix, glob(pattern));\n }\n\n return result;\n};\n\n/**\n * Formats a .gitignore section\n */\nconst formatSection = (section: Section = { name: \"\", patterns: [] }): string => {\n const output = [section.comment || \"\"];\n\n if (section.patterns?.length) {\n output.push(section.patterns.join(\"\\n\"));\n output.push(\"\");\n }\n\n return output.join(\"\\n\");\n};\n\n/**\n * Format a .gitignore file from the given input or object from `.parse()`.\n * @param {String | ParsedGitignore} input File path or contents.\n * @param {ParseOptions} options\n * @return {String} Returns formatted string.\n * @api public\n */\nconst format = (input: string | ParsedGitignore, options: ParseOptions = {}): string => {\n const parsed = parse(input, options);\n\n const fn = options.formatSection || formatSection;\n const sections = parsed.sections || parsed;\n const output: string[] = [];\n\n for (const section of ([] as Section[]).concat(sections)) {\n output.push(fn(section));\n }\n\n return output.join(\"\\n\");\n};\n\nexport {\n parse,\n parseFile,\n dedupe,\n format,\n globs,\n formatSection,\n patterns,\n type ParseOptions,\n type Section,\n type ParsedGitignore,\n type GlobResult,\n};\n\nexport default parse;\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n"],"mappings":";;AAAA,OAAOA,MAAU,YACjB,OAAOC,MAAQ,UACf,OAAOC,OAAY,cACnB,OAAOC,OAAQ,YCHR,IAAMC,EAAmB,cAEzB,IAAMC,GACX,QAAQ,IAAI,gCAAkC,uCAEnCC,EAAe,QAAQ,IAAI,6BAA+B,yBAC1DC,GAAkB,QAAQ,IAAI,gCAAkC,qBAChEC,EAAiC,GDF9C,OAAOC,MAAU,YACjB,OAAOC,OAAW,aAClB,OAAS,YAAAC,OAAgB,cEPzB,OACE,gBAAgBC,MAIX,OAEP,OAAOC,MAAW,QAElB,IAAMC,EAAU,GAIT,SAASC,EAAaC,EAA4BC,EAA4BC,EAAc,GAAO,CAExG,IAAMC,EAASP,EAAiBI,IAAU,QAAU,OAASA,EAAO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QAAS,EACX,CAEJ,CAEA,MAAO,CACL,WAAAf,EACA,cAAeX,EAAc,IAAK0B,GAAMA,EAAE,KAAK,EAC/C,YAAAzB,EACA,QAASA,EAAY,SAAW,CAClC,CACF,CAEA,eAAeiB,GAAQpD,EAAmC,CACxD,IAAMgE,EAAO,MAAMC,GAAO,OAAO,OAAO,QAASrE,EAAG,aAAaI,CAAQ,CAAC,EAE1E,OAAO,MAAM,KAAK,IAAI,WAAWgE,CAAI,CAAC,EACnC,IAAKE,GAAMA,EAAE,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAC1C,KAAK,EAAE,CACZ,CAEA,SAASlB,IAA2B,CAClC,IAAMmB,EAAWC,GAAe,iEAAkE,CAAC,EAC7FC,EAAM,IAAI,KACVC,EAAOD,EAAI,eAAe,EAC1BE,GAASF,EAAI,YAAY,EAAI,GAAG,SAAS,EAAE,SAAS,EAAG,GAAG,EAC1DG,EAAMH,EAAI,WAAW,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EACjDI,EAAQJ,EAAI,YAAY,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EACpDK,EAAUL,EAAI,cAAc,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EACxDM,EAAUN,EAAI,cAAc,EAAE,SAAS,EAAE,SAAS,EAAG,GAAG,EAC9D,MAAO,GAAGC,CAAI,GAAGC,CAAK,GAAGC,CAAG,GAAGC,CAAK,GAAGC,CAAO,GAAGC,CAAO,IAAIR,EAAS,CAAC,EACxE","names":["path","fs","crypto","fg","CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","DEFAULT_UPLOAD_MAX_CONCURRENCY","http","https","pipeline","createLoggerBase","chalk","VERSION","createLogger","level","allowClearScreen","showVersion","logger","message","options","chalk","FormData","fs","INVALID_PATH_CHARS_REGEX","GLOBSTAR_REGEX","MAX_PATH_LENGTH","isObject","v","isValidPath","input","split","str","isParsed","input","isObject","parse","input","options","filepath","isParsed","isValidPath","lines","split","names","parsed","section","prev","line","value","name","dedupe","opts","format","globs","dedupe","input","options","parsed","parse","names","res","current","section","name","comment","patterns","key","pattern","glob","GLOBSTAR_REGEX","relative","globs","result","index","globPatterns","p","push","prefix","prev","type","formatSection","output","format","fn","sections","parse_gitignore_default","parse","PQueue","ora","customAlphabet","Conf","path","crypto","fs","fileURLToPath","chalk","__dirname","fileURLToPath","key","getKey","accessStore","Conf","CLI_PROJECT_NAME","findNearestNodeModules","currentDir","__dirname","path","nodeModulesPath","fs","getKey","tmpSecureStoreDir","keyPath","key","crypto","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","toURL","path","apiBaseURL","API_BASE_URL","formatResponse","response","data","UploadError","error","error_description","filename","defaultConfig","agent","http","discoverFiles","templateDir","gitignore","path","gitignored","fs","parse_gitignore_default","fg","uploadFile","filePath","relativePath","uploadUrl","templateId","spinner","token","config","uploadWithRetry","attempt","performUpload","logger","resolve","reject","stats","fileName","startTime","form","FormData","fileStream","totalUploaded","updateProgress","chunk","options","req","https","res","responseBody","endTime","uploadStats","errorObject","parsedError","pipeline","err","reportUploadStatistics","uploadedFiles","failedFiles","chalk","failure","uploadTemplate","dryRun","fullConfig","queue","PQueue","DEFAULT_UPLOAD_MAX_CONCURRENCY","files","filesCount","signatures","uploadId","generateUploadId","completedUploads","file","md5","sha1sum","ora","uploadPromises","fullPath","url","API_BASE_URL","result","results","r","finalizeUrl","finalizeResponse","post","hash","crypto","b","randomId","customAlphabet","now","year","month","day","hours","minutes","seconds"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const CLI_PROJECT_NAME = "upstart-cli";
|
|
2
|
-
export declare const CLI_LOGIN_POLL_INTERVAL = 5000;
|
|
3
|
-
export declare const CLI_LOGIN_CLIENT_ID: string;
|
|
4
|
-
export declare const API_BASE_URL: string;
|
|
5
|
-
export declare const EDITOR_BASE_URL: string;
|
|
6
|
-
export declare const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;
|
|
7
|
-
export declare const OAUTH_ENDPOINT_DEVICE_CODE = "oauth/devicecode";
|
|
8
|
-
export declare const OAUTH_ENDPOINT_TOKEN = "oauth/token";
|
|
9
|
-
export declare const OAUTH_ENDPOINT_USER_INFO = "oauth/userinfo";
|
|
10
|
-
export declare const API_ENDPOINT_REGISTER_TEMPLATE = "v1/templates";
|
|
11
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/node/cli/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,mBAAmB,QACsD,CAAC;AAEvF,eAAO,MAAM,YAAY,QAAsE,CAAC;AAChG,eAAO,MAAM,eAAe,QAAqE,CAAC;AAClG,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAC7D,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAClD,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAEzD,eAAO,MAAM,8BAA8B,iBAAiB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
|
-
|
|
3
|
-
var _="upstart-cli",t=5e3,o=process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",E=process.env.PUBLIC_UPSTART_API_BASE_URL??"https://api.upstart.gg",I=process.env.PUBLIC_UPSTART_EDITOR_BASE_URL??"https://upstart.gg",T=10,e="oauth/devicecode",s="oauth/token",p="oauth/userinfo",A="v1/templates";export{E as API_BASE_URL,A as API_ENDPOINT_REGISTER_TEMPLATE,o as CLI_LOGIN_CLIENT_ID,t as CLI_LOGIN_POLL_INTERVAL,_ as CLI_PROJECT_NAME,T as DEFAULT_UPLOAD_MAX_CONCURRENCY,I as EDITOR_BASE_URL,e as OAUTH_ENDPOINT_DEVICE_CODE,s as OAUTH_ENDPOINT_TOKEN,p as OAUTH_ENDPOINT_USER_INFO};
|
|
4
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node/cli/constants.ts"],"sourcesContent":["export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n"],"mappings":";;AAAO,IAAMA,EAAmB,cACnBC,EAA0B,IAC1BC,EACX,QAAQ,IAAI,gCAAkC,uCAEnCC,EAAe,QAAQ,IAAI,6BAA+B,yBAC1DC,EAAkB,QAAQ,IAAI,gCAAkC,qBAChEC,EAAiC,GAEjCC,EAA6B,mBAC7BC,EAAuB,cACvBC,EAA2B,iBAE3BC,EAAiC","names":["CLI_PROJECT_NAME","CLI_LOGIN_POLL_INTERVAL","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","DEFAULT_UPLOAD_MAX_CONCURRENCY","OAUTH_ENDPOINT_DEVICE_CODE","OAUTH_ENDPOINT_TOKEN","OAUTH_ENDPOINT_USER_INFO","API_ENDPOINT_REGISTER_TEMPLATE"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-logged-in.d.ts","sourceRoot":"","sources":["../../../src/node/cli/is-logged-in.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAAC,WAAW,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAwBtE"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
|
-
|
|
3
|
-
var x=Object.defineProperty;var p=(e,r)=>()=>(e&&(r=e(e=0)),r);var O=(e,r)=>{for(var o in r)x(e,o,{get:r[o],enumerable:!0})};var y,b,f,M,l,m=p(()=>{"use strict";y="upstart-cli",b=process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",f=process.env.PUBLIC_UPSTART_API_BASE_URL??"https://api.upstart.gg",M=process.env.PUBLIC_UPSTART_EDITOR_BASE_URL??"https://upstart.gg",l="oauth/userinfo"});var d=p(()=>{"use strict"});import P from"conf";import g from"node:path";import I from"node:crypto";import i from"node:fs";import{fileURLToPath as U}from"node:url";import Q from"chalk";function A(){let e=h;for(;e!==g.parse(e).root;){let r=g.join(e,"node_modules");if(i.existsSync(r))return r;e=g.dirname(e)}return null}function N(){let e=A();if(!e)throw new Error("Could not find nearest node_modules directory.");let r=g.join(e,".enpage-tmp");i.existsSync(r)||i.mkdirSync(r,{recursive:!0,mode:448});let o=g.join(r,".enpage-key");if(!i.existsSync(o)){let t=I.randomBytes(32).toString("hex");return i.writeFileSync(o,t,{mode:384}),t}return i.readFileSync(o,"utf8")}var h,k,a,_=p(()=>{"use strict";m();d();h=U(new URL(".",import.meta.url)),k=N(),a=new P({projectName:y,encryptionKey:k,clearInvalidConfig:!0})});import{createLogger as w}from"vite";import c from"chalk";function D(e,r,o=!1){let s=w(e==="debug"?"info":e,{prefix:"[upstart]",allowClearScreen:r});return o&&s.info(c.hex("#7270c6").bold(`\u{1F680} Upstart v${C}
|
|
4
|
-
`)),{...s,success:(t,n)=>s.info(c.green(t),n),error:(t,n)=>s.error(c.red(t),n),warn:(t,n)=>s.warn(c.yellow(t),n),warnOnce:(t,n)=>s.warnOnce(c.yellow(t),n),debug:(t,n)=>{e==="debug"&&s.info(c.gray(t),n)}}}var C,u,T=p(()=>{"use strict";C=.1;u=D()});var R={};O(R,{get:()=>v,post:()=>B});async function B(e,r,o={}){a.get("access_token")&&(o.Authorization=`Bearer ${a.get("access_token")}`);let s=await fetch(E(e),{method:"POST",headers:{"Content-Type":r instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...o},body:r instanceof URLSearchParams?r:JSON.stringify(r)}).catch(t=>{u.error(`Fatal Error requesting API: ${t.message} (${t.cause.code})`),u.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return L(s)}async function v(e,r={}){a.get("access_token")&&(r.Authorization=`Bearer ${a.get("access_token")}`);let o=await fetch(E(e),{headers:r,method:"GET"}).catch(s=>{u.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),u.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return L(o)}function E(e){let r=new URL(f.endsWith("/")?f:`${f}/`);return new URL(e,r)}async function L(e){let r=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:r}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:r}}var S=p(()=>{"use strict";T();m();_()});m();_();async function ce(e=!1){let r=a.get("access_token"),o=a.get("expires_at");if(!r)return!1;if(o&&o<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{get:s}=await Promise.resolve().then(()=>(S(),R)),{isSuccess:t}=await s(l);return t}export{ce as isLoggedIn};
|
|
5
|
-
//# sourceMappingURL=is-logged-in.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node/cli/constants.ts","../../../src/node/cli/utils.ts","../../../src/node/cli/store.ts","../../../src/node/shared/logger.ts","../../../src/node/cli/api.ts","../../../src/node/cli/is-logged-in.ts"],"sourcesContent":["export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","export function getPackageManager() {\n // Detect package manager\n let packageManager: string | undefined;\n if (process.env.npm_config_user_agent) {\n const pmPart = process.env.npm_config_user_agent.split(\" \")[0];\n packageManager = pmPart.slice(0, pmPart.lastIndexOf(\"/\"));\n }\n\n // Display message\n if (!packageManager) {\n console.log(\"Warning: could not detect package manager\");\n packageManager = \"npm\";\n }\n\n return packageManager;\n}\n\nexport function formatAPIError(error: { error: string; error_description?: string }) {\n return `[${error.error}]${error.error_description ? `: ${error.error_description}` : \"\"}`;\n}\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\n// import { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\nconst VERSION = 0.1;\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${VERSION}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n","import { OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport { accessStore } from \"./store\";\n\nexport async function isLoggedIn(checkRemote = false): Promise<boolean> {\n const token = accessStore.get(\"access_token\");\n const expiration = accessStore.get(\"expires_at\");\n\n if (!token) {\n return false;\n }\n\n if (expiration && expiration < Date.now()) {\n console.log(\"Seems like your token expired...\");\n return false;\n }\n\n if (!checkRemote) {\n return true;\n }\n\n // Check if token is valid\n\n // import dynamically \"./api\" to avoid circular dependency\n const { get } = await import(\"./api\");\n const { isSuccess } = await get(OAUTH_ENDPOINT_USER_INFO);\n\n return isSuccess;\n}\n"],"mappings":";;6HAAA,IAAaA,EAEAC,E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AAyB,CACtE,IAAMC,EAAQC,EAAY,IAAI,cAAc,EACtCC,EAAaD,EAAY,IAAI,YAAY,EAE/C,GAAI,CAACD,EACH,MAAO,GAGT,GAAIE,GAAcA,EAAa,KAAK,IAAI,EACtC,eAAQ,IAAI,kCAAkC,EACvC,GAGT,GAAI,CAACH,EACH,MAAO,GAMT,GAAM,CAAE,IAAAI,CAAI,EAAI,KAAM,qCAChB,CAAE,UAAAC,CAAU,EAAI,MAAMD,EAAIE,CAAwB,EAExD,OAAOD,CACT","names":["CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","OAUTH_ENDPOINT_USER_INFO","init_constants","__esmMin","init_utils","__esmMin","Conf","path","crypto","fs","fileURLToPath","chalk","findNearestNodeModules","currentDir","__dirname","nodeModulesPath","getKey","tmpSecureStoreDir","keyPath","key","accessStore","init_store","__esmMin","init_constants","init_utils","CLI_PROJECT_NAME","createLoggerBase","chalk","createLogger","level","allowClearScreen","showVersion","logger","VERSION","message","options","init_logger","__esmMin","api_exports","__export","get","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","apiBaseURL","API_BASE_URL","init_api","__esmMin","init_logger","init_constants","init_store","init_constants","init_store","isLoggedIn","checkRemote","token","accessStore","expiration","get","isSuccess","OAUTH_ENDPOINT_USER_INFO"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../src/node/cli/program.ts"],"names":[],"mappings":""}
|
package/dist/node/cli/program.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
3
|
-
|
|
4
|
-
var Fr=Object.create;var Be=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var Ur=Object.getPrototypeOf,jr=Object.prototype.hasOwnProperty;var Mt=(i,t)=>()=>(i&&(t=i(i=0)),t);var Cs=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),$r=(i,t)=>{for(var e in t)Be(i,e,{get:t[e],enumerable:!0})},Wr=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ir(t))!jr.call(i,r)&&r!==e&&Be(i,r,{get:()=>t[r],enumerable:!(s=Mr(t,r))||s.enumerable});return i};var Br=(i,t,e)=>(e=i!=null?Fr(Ur(i)):{},Wr(t||!i||!i.__esModule?Be(e,"default",{value:i,enumerable:!0}):e,i));function oe(){let i;if(process.env.npm_config_user_agent){let t=process.env.npm_config_user_agent.split(" ")[0];i=t.slice(0,t.lastIndexOf("/"))}return i||(console.log("Warning: could not detect package manager"),i="npm"),i}function _s(i){return`[${i.error}]${i.error_description?`: ${i.error_description}`:""}`}var ze=Mt(()=>{"use strict"});var ks,Ge,ct,gh,Ns,Ps,Ds,Ls,Fs,lt=Mt(()=>{"use strict";ks="upstart-cli",Ge=process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",ct=process.env.PUBLIC_UPSTART_API_BASE_URL??"https://api.upstart.gg",gh=process.env.PUBLIC_UPSTART_EDITOR_BASE_URL??"https://upstart.gg",Ns=10,Ps="oauth/devicecode",Ds="oauth/token",Ls="oauth/userinfo",Fs="v1/templates"});import zr from"conf";import It from"node:path";import Gr from"node:crypto";import dt from"node:fs";import{fileURLToPath as Hr}from"node:url";import qr from"chalk";function Ms(){let i=M.get("access_token");if(!i){let t=oe();throw new Error(`Access token not found. Please run ${qr.cyan(`${t} run enpage:login`)} to authenticate.`)}return i}function Yr(){let i=Vr;for(;i!==It.parse(i).root;){let t=It.join(i,"node_modules");if(dt.existsSync(t))return t;i=It.dirname(i)}return null}function Jr(){let i=Yr();if(!i)throw new Error("Could not find nearest node_modules directory.");let t=It.join(i,".enpage-tmp");dt.existsSync(t)||dt.mkdirSync(t,{recursive:!0,mode:448});let e=It.join(t,".enpage-key");if(!dt.existsSync(e)){let r=Gr.randomBytes(32).toString("hex");return dt.writeFileSync(e,r,{mode:384}),r}return dt.readFileSync(e,"utf8")}var Vr,Kr,M,pt=Mt(()=>{"use strict";lt();ze();Vr=Hr(new URL(".",import.meta.url)),Kr=Jr(),M=new zr({projectName:ks,encryptionKey:Kr,clearInvalidConfig:!0})});import{createLogger as Xr}from"vite";import mt from"chalk";function He(i,t,e=!1){let s=Xr(i==="debug"?"info":i,{prefix:"[upstart]",allowClearScreen:t});return e&&s.info(mt.hex("#7270c6").bold(`\u{1F680} Upstart v${Zr}
|
|
5
|
-
`)),{...s,success:(r,n)=>s.info(mt.green(r),n),error:(r,n)=>s.error(mt.red(r),n),warn:(r,n)=>s.warn(mt.yellow(r),n),warnOnce:(r,n)=>s.warnOnce(mt.yellow(r),n),debug:(r,n)=>{i==="debug"&&s.info(mt.gray(r),n)}}}var Zr,C,Ut=Mt(()=>{"use strict";Zr=.1;C=He()});var Ws={};$r(Ws,{get:()=>fn,post:()=>st});async function st(i,t,e={}){M.get("access_token")&&(e.Authorization=`Bearer ${M.get("access_token")}`);let s=await fetch(js(i),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...e},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(r=>{C.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),C.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return $s(s)}async function fn(i,t={}){M.get("access_token")&&(t.Authorization=`Bearer ${M.get("access_token")}`);let e=await fetch(js(i),{headers:t,method:"GET"}).catch(s=>{C.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),C.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return $s(e)}function js(i){let t=new URL(ct.endsWith("/")?ct:`${ct}/`);return new URL(i,t)}async function $s(i){let t=i.headers.get("content-type")?.startsWith("application/json")?await i.json():await i.text();return i.ok?{isSuccess:!0,isError:!1,status:i.status,statusText:i.statusText,data:t}:{isSuccess:!1,isError:!0,status:i.status,statusText:i.statusText,data:t}}var jt=Mt(()=>{"use strict";Ut();lt();pt()});var si=Cs((Oc,ei)=>{"use strict";ei.exports=Qs;function Qs(i,t,e){i instanceof RegExp&&(i=Zs(i,e)),t instanceof RegExp&&(t=Zs(t,e));var s=ti(i,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+i.length,s[1]),post:e.slice(s[1]+t.length)}}function Zs(i,t){var e=t.match(i);return e?e[0]:null}Qs.range=ti;function ti(i,t,e){var s,r,n,o,a,h=e.indexOf(i),c=e.indexOf(t,h+1),l=h;if(h>=0&&c>0){if(i===t)return[h,c];for(s=[],n=e.length;l>=0&&!a;)l==h?(s.push(l),h=e.indexOf(i,l+1)):s.length==1?a=[s.pop(),c]:(r=s.pop(),r<n&&(n=r,o=c),c=e.indexOf(t,l+1)),l=h<c&&h>=0?h:c;s.length&&(a=[n,o])}return a}});var li=Cs((Ac,ci)=>{"use strict";var ii=si();ci.exports=zn;var ri="\0SLASH"+Math.random()+"\0",ni="\0OPEN"+Math.random()+"\0",Ve="\0CLOSE"+Math.random()+"\0",oi="\0COMMA"+Math.random()+"\0",ai="\0PERIOD"+Math.random()+"\0";function qe(i){return parseInt(i,10)==i?parseInt(i,10):i.charCodeAt(0)}function Wn(i){return i.split("\\\\").join(ri).split("\\{").join(ni).split("\\}").join(Ve).split("\\,").join(oi).split("\\.").join(ai)}function Bn(i){return i.split(ri).join("\\").split(ni).join("{").split(Ve).join("}").split(oi).join(",").split(ai).join(".")}function hi(i){if(!i)return[""];var t=[],e=ii("{","}",i);if(!e)return i.split(",");var s=e.pre,r=e.body,n=e.post,o=s.split(",");o[o.length-1]+="{"+r+"}";var a=hi(n);return n.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function zn(i){return i?(i.substr(0,2)==="{}"&&(i="\\{\\}"+i.substr(2)),zt(Wn(i),!0).map(Bn)):[]}function Gn(i){return"{"+i+"}"}function Hn(i){return/^-?0\d/.test(i)}function qn(i,t){return i<=t}function Vn(i,t){return i>=t}function zt(i,t){var e=[],s=ii("{","}",i);if(!s)return[i];var r=s.pre,n=s.post.length?zt(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<n.length;o++){var a=r+"{"+s.body+"}"+n[o];e.push(a)}else{var h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),l=h||c,f=s.body.indexOf(",")>=0;if(!l&&!f)return s.post.match(/,.*\}/)?(i=s.pre+"{"+s.body+Ve+s.post,zt(i)):[i];var u;if(l)u=s.body.split(/\.\./);else if(u=hi(s.body),u.length===1&&(u=zt(u[0],!1).map(Gn),u.length===1))return n.map(function(Ft){return s.pre+u[0]+Ft});var d;if(l){var g=qe(u[0]),p=qe(u[1]),y=Math.max(u[0].length,u[1].length),m=u.length==3?Math.abs(qe(u[2])):1,b=qn,w=p<g;w&&(m*=-1,b=Vn);var S=u.some(Hn);d=[];for(var E=g;b(E,p);E+=m){var v;if(c)v=String.fromCharCode(E),v==="\\"&&(v="");else if(v=String(E),S){var N=y-v.length;if(N>0){var V=new Array(N+1).join("0");E<0?v="-"+V+v.slice(1):v=V+v}}d.push(v)}}else{d=[];for(var L=0;L<u.length;L++)d.push.apply(d,zt(u[L],!1))}for(var L=0;L<d.length;L++)for(var o=0;o<n.length;o++){var a=r+d[L]+n[o];(!t||l||a)&&e.push(a)}}return e}});import{program as Lt}from"commander";ze();pt();import{resolve as J}from"node:path";import{existsSync as Bt,readFileSync as Dn,writeFileSync as Ln}from"node:fs";import it from"chalk";lt();Ut();import $t from"node:path";import Wt from"node:fs";import un from"node:crypto";import dn from"fast-glob";import zs from"node:http";import pn from"node:https";import{pipeline as mn}from"node:stream";import Bs from"chalk";import gn from"form-data";import*as ae from"node:fs";var Qr=/[<>"|?*\n\r\t\f\x00-\x1F]/,tn=/(?:^|\/)[*]{2}($|\/)/,en=248,sn=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),rn=i=>typeof i=="string"&&i.length<=en&&!Qr.test(i),nn=i=>i.split(/\r\n?|\n/);var on=i=>sn(i)&&Array.isArray(i.patterns)&&Array.isArray(i.sections);var he=(i,t={})=>{let e=t.path;if(on(i))return i;rn(i)&&ae.existsSync(i)&&(e=i,i=ae.readFileSync(i,"utf8"));let s=nn(i),r=new Map,n={sections:[],patterns:[]},o={name:"default",patterns:[]},a=null;for(let h of s){let c=h.trim();if(c.startsWith("#")){let[,l]=/^#+\s*(.*)\s*$/.exec(c)||[];if(a){r.delete(a.name),a.comment=a.comment?`${a.comment}
|
|
6
|
-
${c}`:c,a.name=l?`${a.name.trim()}
|
|
7
|
-
${l.trim()}`:a.name.trim(),r.set(a.name.toLowerCase().trim(),a);continue}o={name:l?.trim()||"",comment:c,patterns:[]},r.set(o.name.toLowerCase(),o),n.sections.push(o),a=o;continue}c!==""&&(o.patterns.push(c),n.patterns.push(c)),a=null}return(t.dedupe===!0||t.unique===!0)&&(n=Is(n,{...t,format:!1})),n.path=e,n.input=Buffer.from(i),n.format=h=>ln(n,{...t,...h}),n.dedupe=h=>Is(n,{...t,...h}),n.globs=h=>hn(n,{path:e,...t,...h}),n};var Is=(i,t)=>{let e=he(i,{...t,dedupe:!1}),s=new Map,r={sections:[],patterns:[]},n;for(let o of e.sections){let{name:a="",comment:h,patterns:c}=o,l=a.trim().toLowerCase();for(let f of c)r.patterns.includes(f)||r.patterns.push(f);a&&s.has(l)?(n=s.get(l),n.patterns=[...n.patterns,...c]):(n={name:a,comment:h,patterns:c},r.sections.push(n),s.set(l,n))}for(let o of r.sections)o.patterns=[...new Set(o.patterns)];return r},an=i=>{if(tn.test(i))return i;let t=!1;return i.startsWith("/")?(i=i.slice(1),t=!0):i.slice(1,i.length-1).includes("/")&&(t=!0),i+=i.endsWith("/")?"**/":"/**",t?i:`**/${i}`},hn=(i,t={})=>{let e=he(i,t),s=[],r=0,n=e.patterns.concat(t.ignore||[]).concat((t.unignore||[]).map(a=>a.startsWith("!")?a:`!${a}`)),o=(a,h)=>{let c=s[s.length-1],l=a?"unignore":"ignore";c&&c.type===l?c.patterns.includes(h)||c.patterns.push(h):(s.push({type:l,path:t.path||null,patterns:[h],index:r}),r++)};for(let a of n){let h="";a.startsWith("!")&&(a=a.slice(1),h="!"),o(h,a.startsWith("/")?a.slice(1):a),o(h,an(a))}return s},cn=(i={name:"",patterns:[]})=>{let t=[i.comment||""];return i.patterns?.length&&(t.push(i.patterns.join(`
|
|
8
|
-
`)),t.push("")),t.join(`
|
|
9
|
-
`)},ln=(i,t={})=>{let e=he(i,t),s=t.formatSection||cn,r=e.sections||e,n=[];for(let o of[].concat(r))n.push(s(o));return n.join(`
|
|
10
|
-
`)};var Us=he;jt();import wn from"p-queue";import yn from"ora";import{customAlphabet as Sn}from"nanoid";var gt=class extends Error{constructor(e,s,r){super(`${e}: ${s}`);this.error=e;this.error_description=s;this.filename=r;this.name="UploadError"}},bn={maxDataSize:12*1024*1024,retryAttempts:2,retryDelay:1e3},En=new zs.Agent({keepAlive:!0,maxSockets:10,keepAliveMsecs:3e3});async function xn(i){let t=$t.join(i,".gitignore"),s=Wt.existsSync(t)?Us(Wt.readFileSync(t,"utf-8")).patterns:[];return dn("**/*",{cwd:i,onlyFiles:!0,dot:!0,absolute:!0,ignore:["node_modules/**",".cache/**","**/.DS_Store",".gitignore",".env",".env.*",".git/**","dist/**",...s]})}async function vn(i,t,e,s,r,n,o){let a=async h=>{try{return await Tn(i,t,e,s,r,n,o)}catch(c){if(h<o.retryAttempts)return C.warn(`Retrying upload for ${t} (attempt ${h+1})`),await new Promise(l=>setTimeout(l,o.retryDelay)),a(h+1);throw c}};return a(0)}async function Tn(i,t,e,s,r,n,o){return new Promise((a,h)=>{let c=Wt.statSync(i),l=$t.basename(i),f=Date.now(),u=new gn({maxDataSize:o.maxDataSize}),d=Wt.createReadStream(i),g=0,p=w=>{g+=w.length};d.on("data",p),u.append("file",d,{filename:l,knownLength:c.size});let y={agent:En,method:"POST",headers:{authorization:`Bearer ${n}`,"x-upstart-template-file-path":t,"x-upstart-template-id":s,...u.getHeaders()}},b=(e.startsWith("https")?pn:zs).request(e,y,w=>{let S="";w.on("data",E=>{S+=E}),w.on("end",()=>{let E=Date.now(),v={fileName:l,fileSize:c.size,uploadDuration:E-f,statusCode:w.statusCode??0,serverResponse:S};if(w.statusCode&&w.statusCode>=200&&w.statusCode<300)r.text=`Uploaded ${t}`,a(v);else{let N;if(w.headers["content-type"]?.startsWith("application/json")){let V=JSON.parse(S);N=new gt(V.error||"unknown_error",V.error_description||"Unknown error occurred",t)}else N=new gt("unknown_error",S||"Unknown error occurred",t);r.fail(`Failed to upload ${t} [${N.error}] ${N.error_description}`),h(N)}})});b.on("error",w=>{h(new gt("request_error",w.message,t))}),mn(u,b,w=>{w&&h(new gt("pipeline_error",`Pipeline failed for ${l}: ${w.message}`,t))})})}function Rn(i,t,e){e.length>0?(C.error(Bs.red(`Failed to upload ${e.length} files:`)),e.forEach(s=>{let r=s.reason;C.error(`- ${r.filename}: ${r.error_description} (${r.error})`)})):C.info(Bs.green(`Uploaded ${t.length} files successfully for template ${i}.
|
|
11
|
-
`))}async function Gs(i,t,e,s=!1,r={}){let n={...bn,...r},o=new wn({concurrency:Ns}),a=await xn(t),h=a.length,c={},l=An(),f=0;for(let m of a){let b=$t.relative(t,m),w=await On(m);c[b]=w}s&&(C.info(`Dry run mode enabled. Skipping upload.
|
|
12
|
-
`),C.info("The following files would have been uploaded:"),a.forEach(m=>C.info(`- ${m}`)),process.exit(0));let u=yn(`Uploading ${h} files...`).start(),d=a.map(m=>{let b=$t.resolve(t,m),w=$t.relative(t,m),S=`${ct}/v1/templates/${i}/upload/${l}`;return o.add(async()=>{let E=await vn(b,w,S,i,u,e,n);return f++,E})}),g=await Promise.allSettled(d);u.stop();let p=g.filter(m=>m.status==="fulfilled"),y=g.filter(m=>m.status==="rejected");if(Rn(i,p.map(m=>m.value),y),!y.length&&p.length){let m=`${ct}/v1/templates/${i}/upload/${l}/finalize`,w=await st(m,{signatures:c});if(w.isError)return C.error(`Failed to finalize upload: ${w.data.error_description} (${w.data.error})`),{filesCount:h,uploadedFiles:p.map(S=>S.value),failedFiles:[],success:!1}}return{filesCount:h,uploadedFiles:p.map(m=>m.value),failedFiles:y,success:y.length===0}}async function On(i){let t=await un.subtle.digest("SHA-1",Wt.readFileSync(i));return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")}function An(){let i=Sn("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",5),t=new Date,e=t.getUTCFullYear(),s=(t.getUTCMonth()+1).toString().padStart(2,"0"),r=t.getUTCDate().toString().padStart(2,"0"),n=t.getUTCHours().toString().padStart(2,"0"),o=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${e}${s}${r}${n}${o}${a}_${i()}`}jt();lt();import Ys from"node:path";Ut();import Cn from"node:fs";import{readFile as _n}from"node:fs/promises";import kn from"fast-glob";import{basename as Hs,dirname as Nn,extname as Pn}from"node:path";async function qs(i,t=C){Cn.existsSync(i)||(t.error(`\u{1F534} No enpage.config.js found!
|
|
13
|
-
Your project must have an enpage.config.js file in the root directory.
|
|
14
|
-
|
|
15
|
-
`),process.exit(1));let e=await import(i),s=Nn(i),r={},n=await kn(["README.enpage.md","README.enpage.*.md"],{cwd:s,onlyFiles:!0,absolute:!0,caseSensitiveMatch:!1});for(let o of n){let a=Hs(o,".md"),h=Pn(a),c=(h===".enpage"?"en":h.substring(1)).toLowerCase();t.debug(`Found template readme file (${c}): ${Hs(o)}`),r[c]=await _n(o,"utf-8")}return e}function Vs(i,t){for(let e in i.site.datasources)if(i.site.datasources[e].provider==="http-json"&&!i.site.datasources[e].sampleData)throw t.error(`\u{1F534} Error: Datasource "${e}" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a "sampleData" key to your ${e} datasource.`),new Error(`Missing sample data for datasource "${e}"`);return i}lt();pt();async function Ks(i=!1){let t=M.get("access_token"),e=M.get("expires_at");if(!t)return!1;if(e&&e<Date.now())return console.log("Seems like your token expired..."),!1;if(!i)return!0;let{get:s}=await Promise.resolve().then(()=>(jt(),Ws)),{isSuccess:r}=await s(Ls);return r}async function Js({options:i,args:t,logger:e}){if(!await Ks(!0)){let f=oe();e.error(` ${it.redBright("Error")}: User token not found. Please run ${it.cyan(`${f} run enpage:login`)} to authenticate or set the ${it.cyan("ENPAGE_API_TOKEN")} environment variable.
|
|
16
|
-
`),process.exit(1)}let s=t.length?Ys.isAbsolute(t[0])?t[0]:J(process.cwd(),t[0]):process.cwd();Bt(s)||(e.error(` Template directory not found: ${s}. Aborting.
|
|
17
|
-
`),process.exit(1));let r=t.length>1?Ys.isAbsolute(t[1])?t[1]:J(process.cwd(),t[1]):J(s,"dist");Bt(r)||(e.error(` Dist directory not found: ${r}.
|
|
18
|
-
Please run 'build' before publishing. Aborting.
|
|
19
|
-
`),process.exit(1)),Bt(J(s,"enpage.config.js"))||(e.error(` ${it.redBright("Error")}: file enpage.config.js not found in ${s}. Aborting.
|
|
20
|
-
`),process.exit(1));let n=await qs(J(s,"enpage.config.js"),e);Vs(n,e);let o=Ms(),a=Fn(s);a||(e.error(` ${it.redBright("Error")}: package.json file not found in ${s}. Aborting.
|
|
21
|
-
`),process.exit(1));let h=await Mn(a);if(h||(e.error(` ${it.redBright("Error")}: cannot read/parse package.json file in ${s}. Aborting.
|
|
22
|
-
`),process.exit(1)),!h.enpage?.id){let{data:f,isError:u,status:d}=await st(Fs,{});u&&(e.error(` ${it.redBright("Error")}: Cannot register template: ${_s(f)}
|
|
23
|
-
`),process.exit(1)),h.enpage??={},h.enpage.id=f.template.id;try{i.dryRun||Ln(a,JSON.stringify(h,null,2))}catch{e.error(` ${it.redBright("Error")}: Cannot update template id in package.json file located in ${s}. Aborting.
|
|
24
|
-
`),process.exit(1)}}let c=h.enpage.id;e.info(`Submitting template to Enpage...
|
|
25
|
-
`),(await Gs(c,s,o,i.dryRun)).success||(e.error(`
|
|
26
|
-
Upload failed. See details above.
|
|
27
|
-
`),process.exit(1)),e.success(`Template ${c} published.
|
|
28
|
-
`)}function Fn(i){return Bt(J(i,"package.json"))?J(i,"package.json"):Bt(J(i,"template-package.json"))?J(i,"template-package.json"):!1}function Mn(i){try{return JSON.parse(Dn(i,"utf-8"))}catch{return null}}lt();jt();pt();import In from"chalk";import{confirm as Un}from"@inquirer/prompts";import jn from"open";async function $n(i,t){for(;;){let e=new URLSearchParams({grant_type:"device_code",device_code:i,client_id:Ge}),s=await st(Ds,e),{data:r,isSuccess:n}=s;if(n)return r;if(r.error==="authorization_pending")await new Promise(o=>setTimeout(o,5e3));else return t.error(`Error while polling for login: ${r.error_description??r.error}`),!1}}async function Xs({options:i,logger:t}){t.info(`Logging in to Enpage...
|
|
29
|
-
`);let{isError:e,data:s}=await st(Ps,{client_id:Ge,scope:"profile,templates:publish"});e&&(t.error("Failed to get device code. Please try again."),t.error(`Error: ${s.error_description??s.error}`),process.exit(1));let{verification_uri:r,device_code:n}=s;await Un({message:"Would you like to open the login page in your browser?",default:!0}).catch(h=>{process.exit(0)})?jn(r):t.info(`
|
|
30
|
-
Please visit the following URL to login:
|
|
31
|
-
${r}
|
|
32
|
-
`),t.info(In.gray(`
|
|
33
|
-
Waiting for login...
|
|
34
|
-
`));let a=await $n(n,t);a||(t.error("Login failed. Please try again."),process.exit(1)),M.set({...a,...a.expires_in?{expires_at:Date.now()+a.expires_in*1e3}:{}}),t.info(`Login successful!
|
|
35
|
-
`),process.exitCode=0}import{build as Rs}from"vite";import fh,{resolve as Nr}from"node:path";import{fileURLToPath as uh}from"node:url";var yi=Br(li(),1);var Gt=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")};var Kn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Ht=i=>i.replace(/[[\]\\-]/g,"\\$&"),Yn=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fi=i=>i.join(""),ui=(i,t)=>{let e=t;if(i.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],r=[],n=e+1,o=!1,a=!1,h=!1,c=!1,l=e,f="";t:for(;n<i.length;){let p=i.charAt(n);if((p==="!"||p==="^")&&n===e+1){c=!0,n++;continue}if(p==="]"&&o&&!h){l=n+1;break}if(o=!0,p==="\\"&&!h){h=!0,n++;continue}if(p==="["&&!h){for(let[y,[m,b,w]]of Object.entries(Kn))if(i.startsWith(y,n)){if(f)return["$.",!1,i.length-e,!0];n+=y.length,w?r.push(m):s.push(m),a=a||b;continue t}}if(h=!1,f){p>f?s.push(Ht(f)+"-"+Ht(p)):p===f&&s.push(Ht(p)),f="",n++;continue}if(i.startsWith("-]",n+1)){s.push(Ht(p+"-")),n+=2;continue}if(i.startsWith("-",n+1)){f=p,n+=2;continue}s.push(Ht(p)),n++}if(l<n)return["",!1,0,!1];if(!s.length&&!r.length)return["$.",!1,i.length-e,!0];if(r.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!c){let p=s[0].length===2?s[0].slice(-1):s[0];return[Yn(p),!1,l-e,!1]}let u="["+(c?"^":"")+fi(s)+"]",d="["+(c?"":"^")+fi(r)+"]";return[s.length&&r.length?"("+u+"|"+d+")":s.length?u:d,a,l-e,!0]};var B=(i,{windowsPathsNoEscape:t=!1}={})=>t?i.replace(/\[([^\/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var Jn=new Set(["!","?","+","*","@"]),di=i=>Jn.has(i),Xn="(?!(?:^|/)\\.\\.?(?:$|/))",ce="(?!\\.)",Zn=new Set(["[","."]),Qn=new Set(["..","."]),to=new Set("().*{}+?[]^$\\!"),eo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ke="[^/]",pi=Ke+"*?",mi=Ke+"+?",wt=class i{type;#t;#e;#n=!1;#r=[];#o;#b;#w;#a=!1;#f;#h;#c=!1;constructor(t,e,s={}){this.type=t,t&&(this.#e=!0),this.#o=e,this.#t=this.#o?this.#o.#t:this,this.#f=this.#t===this?s:this.#t.#f,this.#w=this.#t===this?[]:this.#t.#w,t==="!"&&!this.#t.#a&&this.#w.push(this),this.#b=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#e!==void 0)return this.#e;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#e=!0;return this.#e}toString(){return this.#h!==void 0?this.#h:this.type?this.#h=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#h=this.#r.map(t=>String(t)).join("")}#s(){if(this!==this.#t)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let t;for(;t=this.#w.pop();){if(t.type!=="!")continue;let e=t,s=e.#o;for(;s;){for(let r=e.#b+1;!s.type&&r<s.#r.length;r++)for(let n of t.#r){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(s.#r[r])}e=s,s=e.#o}}return this}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof i&&e.#o===this))throw new Error("invalid part: "+e);this.#r.push(e)}}toJSON(){let t=this.type===null?this.#r.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#a&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#b===0)return!0;let t=this.#o;for(let e=0;e<this.#b;e++){let s=t.#r[e];if(!(s instanceof i&&s.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#b===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new i(this.type,t);for(let s of this.#r)e.copyIn(s);return e}static#u(t,e,s,r){let n=!1,o=!1,a=-1,h=!1;if(e.type===null){let d=s,g="";for(;d<t.length;){let p=t.charAt(d++);if(n||p==="\\"){n=!n,g+=p;continue}if(o){d===a+1?(p==="^"||p==="!")&&(h=!0):p==="]"&&!(d===a+2&&h)&&(o=!1),g+=p;continue}else if(p==="["){o=!0,a=d,h=!1,g+=p;continue}if(!r.noext&&di(p)&&t.charAt(d)==="("){e.push(g),g="";let y=new i(p,e);d=i.#u(t,y,d,r),e.push(y);continue}g+=p}return e.push(g),d}let c=s+1,l=new i(null,e),f=[],u="";for(;c<t.length;){let d=t.charAt(c++);if(n||d==="\\"){n=!n,u+=d;continue}if(o){c===a+1?(d==="^"||d==="!")&&(h=!0):d==="]"&&!(c===a+2&&h)&&(o=!1),u+=d;continue}else if(d==="["){o=!0,a=c,h=!1,u+=d;continue}if(di(d)&&t.charAt(c)==="("){l.push(u),u="";let g=new i(d,l);l.push(g),c=i.#u(t,g,c,r);continue}if(d==="|"){l.push(u),u="",f.push(l),l=new i(null,e);continue}if(d===")")return u===""&&e.#r.length===0&&(e.#c=!0),l.push(u),u="",e.push(...f,l),c;u+=d}return e.type=null,e.#e=void 0,e.#r=[t.substring(s-1)],c}static fromGlob(t,e={}){let s=new i(null,void 0,e);return i.#u(t,s,0,e),s}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[e,s,r,n]=this.toRegExpSource();if(!(r||this.#e||this.#f.nocase&&!this.#f.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let a=(this.#f.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#f}toRegExpSource(t){let e=t??!!this.#f.dot;if(this.#t===this&&this.#s(),!this.type){let h=this.isStart()&&this.isEnd(),c=this.#r.map(d=>{let[g,p,y,m]=typeof d=="string"?i.#p(d,this.#e,h):d.toRegExpSource(t);return this.#e=this.#e||y,this.#n=this.#n||m,g}).join(""),l="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Qn.has(this.#r[0]))){let g=Zn,p=e&&g.has(c.charAt(0))||c.startsWith("\\.")&&g.has(c.charAt(2))||c.startsWith("\\.\\.")&&g.has(c.charAt(4)),y=!e&&!t&&g.has(c.charAt(0));l=p?Xn:y?ce:""}let f="";return this.isEnd()&&this.#t.#a&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[l+c+f,B(c),this.#e=!!this.#e,this.#n]}let s=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",n=this.#y(e);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let h=this.toString();return this.#r=[h],this.type=null,this.#e=void 0,[h,B(this.toString()),!1,!1]}let o=!s||t||e||!ce?"":this.#y(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!e?ce:"")+mi;else{let h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?ce:"")+pi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+n+h}return[a,B(n),this.#e=!!this.#e,this.#n]}#y(t){return this.#r.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,r,n,o]=e.toRegExpSource(t);return this.#n=this.#n||o,s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#p(t,e,s=!1){let r=!1,n="",o=!1;for(let a=0;a<t.length;a++){let h=t.charAt(a);if(r){r=!1,n+=(to.has(h)?"\\":"")+h;continue}if(h==="\\"){a===t.length-1?n+="\\\\":r=!0;continue}if(h==="["){let[c,l,f,u]=ui(t,a);if(f){n+=c,o=o||l,a+=f-1,e=e||u;continue}}if(h==="*"){s&&t==="*"?n+=mi:n+=pi,e=!0;continue}if(h==="?"){n+=Ke,e=!0;continue}n+=eo(h)}return[n,B(t),!!e,o]}};var yt=(i,{windowsPathsNoEscape:t=!1}={})=>t?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&");var P=(i,t,e={})=>(Gt(t),!e.nocomment&&t.charAt(0)==="#"?!1:new I(t,e).match(i)),so=/^\*+([^+@!?\*\[\(]*)$/,io=i=>t=>!t.startsWith(".")&&t.endsWith(i),ro=i=>t=>t.endsWith(i),no=i=>(i=i.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(i)),oo=i=>(i=i.toLowerCase(),t=>t.toLowerCase().endsWith(i)),ao=/^\*+\.\*+$/,ho=i=>!i.startsWith(".")&&i.includes("."),co=i=>i!=="."&&i!==".."&&i.includes("."),lo=/^\.\*+$/,fo=i=>i!=="."&&i!==".."&&i.startsWith("."),uo=/^\*+$/,po=i=>i.length!==0&&!i.startsWith("."),mo=i=>i.length!==0&&i!=="."&&i!=="..",go=/^\?+([^+@!?\*\[\(]*)?$/,wo=([i,t=""])=>{let e=Si([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},yo=([i,t=""])=>{let e=bi([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},So=([i,t=""])=>{let e=bi([i]);return t?s=>e(s)&&s.endsWith(t):e},bo=([i,t=""])=>{let e=Si([i]);return t?s=>e(s)&&s.endsWith(t):e},Si=([i])=>{let t=i.length;return e=>e.length===t&&!e.startsWith(".")},bi=([i])=>{let t=i.length;return e=>e.length===t&&e!=="."&&e!==".."},Ei=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",gi={win32:{sep:"\\"},posix:{sep:"/"}},Eo=Ei==="win32"?gi.win32.sep:gi.posix.sep;P.sep=Eo;var A=Symbol("globstar **");P.GLOBSTAR=A;var xo="[^/]",vo=xo+"*?",To="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ro="(?:(?!(?:\\/|^)\\.).)*?",Oo=(i,t={})=>e=>P(e,i,t);P.filter=Oo;var j=(i,t={})=>Object.assign({},i,t),Ao=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return P;let t=P;return Object.assign((s,r,n={})=>t(s,r,j(i,n)),{Minimatch:class extends t.Minimatch{constructor(r,n={}){super(r,j(i,n))}static defaults(r){return t.defaults(j(i,r)).Minimatch}},AST:class extends t.AST{constructor(r,n,o={}){super(r,n,j(i,o))}static fromGlob(r,n={}){return t.AST.fromGlob(r,j(i,n))}},unescape:(s,r={})=>t.unescape(s,j(i,r)),escape:(s,r={})=>t.escape(s,j(i,r)),filter:(s,r={})=>t.filter(s,j(i,r)),defaults:s=>t.defaults(j(i,s)),makeRe:(s,r={})=>t.makeRe(s,j(i,r)),braceExpand:(s,r={})=>t.braceExpand(s,j(i,r)),match:(s,r,n={})=>t.match(s,r,j(i,n)),sep:t.sep,GLOBSTAR:A})};P.defaults=Ao;var xi=(i,t={})=>(Gt(i),t.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:(0,yi.default)(i));P.braceExpand=xi;var Co=(i,t={})=>new I(i,t).makeRe();P.makeRe=Co;var _o=(i,t,e={})=>{let s=new I(t,e);return i=i.filter(r=>s.match(r)),s.options.nonull&&!i.length&&i.push(t),i};P.match=_o;var wi=/[?*]|[+@!]\(.*?\)|\[|\]/,ko=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),I=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Gt(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Ei,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let r=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=n[0]===""&&n[1]===""&&(n[2]==="?"||!wi.test(n[2]))&&!wi.test(n[3]),c=/^[a-z]:/i.test(n[0]);if(h)return[...n.slice(0,4),...n.slice(4).map(l=>this.parse(l))];if(c)return[n[0],...n.slice(1).map(l=>this.parse(l))]}return n.map(h=>this.parse(h))});if(this.debug(this.pattern,r),this.set=r.filter(n=>n.indexOf(!1)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s=0;s<t.length;s++)for(let r=0;r<t[s].length;r++)t[s][r]==="**"&&(t[s][r]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let r=s;for(;e[r+1]==="**";)r++;r!==s&&e.splice(s,r-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,r)=>{let n=s[s.length-1];return r==="**"&&n==="**"?s:r===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(r),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let n=t[r];r===1&&n===""&&t[0]===""||(n==="."||n==="")&&(e=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let r=t[s-1];r&&r!=="."&&r!==".."&&r!=="**"&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let r=-1;for(;(r=s.indexOf("**",r+1))!==-1;){let o=r;for(;s[o+1]==="**";)o++;o>r&&s.splice(r+1,o-r);let a=s[r+1],h=s[r+2],c=s[r+3];if(a!==".."||!h||h==="."||h===".."||!c||c==="."||c==="..")continue;e=!0,s.splice(r,1);let l=s.slice(0);l[r]="**",t.push(l),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(e=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){let o=s[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let h=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...h),s.length===0&&s.push(""),n-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let r=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(r){t[e]=[],t[s]=r;break}}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let r=0,n=0,o=[],a="";for(;r<t.length&&n<e.length;)if(t[r]===e[n])o.push(a==="b"?e[n]:t[r]),r++,n++;else if(s&&t[r]==="**"&&e[n]===t[r+1])o.push(t[r]),r++;else if(s&&e[n]==="**"&&t[r]===e[n+1])o.push(e[n]),n++;else if(t[r]==="*"&&e[n]&&(this.options.dot||!e[n].startsWith("."))&&e[n]!=="**"){if(a==="b")return!1;a="a",o.push(t[r]),r++,n++}else if(e[n]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",o.push(e[n]),r++,n++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let r=this.options;if(this.isWindows){let p=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!p&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),m=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),b=!m&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),w=y?3:p?0:void 0,S=b?3:m?0:void 0;if(typeof w=="number"&&typeof S=="number"){let[E,v]=[t[w],e[S]];E.toLowerCase()===v.toLowerCase()&&(e[S]=E,S>w?e=e.slice(S):w>S&&(t=t.slice(w)))}}let{optimizationLevel:n=1}=this.options;n>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,a=0,h=t.length,c=e.length;o<h&&a<c;o++,a++){this.debug("matchOne loop");var l=e[a],f=t[o];if(this.debug(e,l,f),l===!1)return!1;if(l===A){this.debug("GLOBSTAR",[e,l,f]);var u=o,d=a+1;if(d===c){for(this.debug("** at the end");o<h;o++)if(t[o]==="."||t[o]===".."||!r.dot&&t[o].charAt(0)===".")return!1;return!0}for(;u<h;){var g=t[u];if(this.debug(`
|
|
36
|
-
globstar while`,t,u,e,d,g),this.matchOne(t.slice(u),e.slice(d),s))return this.debug("globstar found match!",u,h,g),!0;if(g==="."||g===".."||!r.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,u,e,d);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(s&&(this.debug(`
|
|
37
|
-
>>> no match, partial?`,t,u,e,d),u===h))}let p;if(typeof l=="string"?(p=f===l,this.debug("string match",l,f,p)):(p=l.test(f),this.debug("pattern match",l,f,p)),!p)return!1}if(o===h&&a===c)return!0;if(o===h)return s;if(a===c)return o===h-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return xi(this.pattern,this.options)}parse(t){Gt(t);let e=this.options;if(t==="**")return A;if(t==="")return"";let s,r=null;(s=t.match(uo))?r=e.dot?mo:po:(s=t.match(so))?r=(e.nocase?e.dot?oo:no:e.dot?ro:io)(s[1]):(s=t.match(go))?r=(e.nocase?e.dot?yo:wo:e.dot?So:bo)(s):(s=t.match(ao))?r=e.dot?co:ho:(s=t.match(lo))&&(r=fo);let n=wt.fromGlob(t,this.options).toMMPattern();return r&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:r}),n}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?vo:e.dot?To:Ro,r=new Set(e.nocase?["i"]:[]),n=t.map(h=>{let c=h.map(l=>{if(l instanceof RegExp)for(let f of l.flags.split(""))r.add(f);return typeof l=="string"?ko(l):l===A?A:l._src});return c.forEach((l,f)=>{let u=c[f+1],d=c[f-1];l!==A||d===A||(d===void 0?u!==void 0&&u!==A?c[f+1]="(?:\\/|"+s+"\\/)?"+u:c[f]=s:u===void 0?c[f-1]=d+"(?:\\/|"+s+")?":u!==A&&(c[f-1]=d+"(?:\\/|\\/"+s+"\\/)"+u,c[f+1]=A))}),c.filter(l=>l!==A).join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let n=this.set;this.debug(this.pattern,"set",n);let o=r[r.length-1];if(!o)for(let a=r.length-2;!o&&a>=0;a--)o=r[a];for(let a=0;a<n.length;a++){let h=n[a],c=r;if(s.matchBase&&h.length===1&&(c=[o]),this.matchOne(c,h,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return P.defaults(t).Minimatch}};P.AST=wt;P.Minimatch=I;P.escape=yt;P.unescape=B;import{fileURLToPath as ha}from"node:url";var St=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ti=new Set,Ye=typeof process=="object"&&process?process:{},Ri=(i,t,e,s)=>{typeof Ye.emitWarning=="function"?Ye.emitWarning(i,t,e,s):console.error(`[${e}] ${t}: ${i}`)},le=globalThis.AbortController,vi=globalThis.AbortSignal;if(typeof le>"u"){vi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,r){this._onabort.push(r)}},le=class{constructor(){t()}signal=new vi;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s)}}};let i=Ye.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{i&&(i=!1,Ri("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var No=i=>!Ti.has(i),Vc=Symbol("type"),rt=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),Oi=i=>rt(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?bt:null:null,bt=class extends Array{constructor(t){super(t),this.fill(0)}},Je=class i{heap;length;static#t=!1;static create(t){let e=Oi(t);if(!e)return[];i.#t=!0;let s=new i(t,e);return i.#t=!1,s}constructor(t,e){if(!i.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},qt=class i{#t;#e;#n;#r;#o;#b;#w;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#f;#h;#c;#s;#u;#y;#p;#m;#A;#g;#C;#x;#E;#S;#R;#d;#k;static unsafeExposeInternals(t){return{starts:t.#x,ttls:t.#E,sizes:t.#C,keyMap:t.#h,keyList:t.#c,valList:t.#s,next:t.#u,prev:t.#y,get head(){return t.#p},get tail(){return t.#m},free:t.#A,isBackgroundFetch:e=>t.#l(e),backgroundFetch:(e,s,r,n)=>t.#F(e,s,r,n),moveToTail:e=>t.#U(e),indexes:e=>t.#O(e),rindexes:e=>t.#_(e),isStale:e=>t.#T(e)}}get max(){return this.#t}get maxSize(){return this.#e}get calculatedSize(){return this.#f}get size(){return this.#a}get fetchMethod(){return this.#b}get memoMethod(){return this.#w}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#o}constructor(t){let{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:h,dispose:c,onInsert:l,disposeAfter:f,noDisposeOnSet:u,noUpdateTTL:d,maxSize:g=0,maxEntrySize:p=0,sizeCalculation:y,fetchMethod:m,memoMethod:b,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:v,ignoreFetchAbort:N}=t;if(e!==0&&!rt(e))throw new TypeError("max option must be a nonnegative integer");let V=e?Oi(e):Array;if(!V)throw new Error("invalid max value: "+e);if(this.#t=e,this.#e=g,this.maxEntrySize=p||this.#e,this.sizeCalculation=y,this.sizeCalculation){if(!this.#e&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(b!==void 0&&typeof b!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#w=b,m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#b=m,this.#R=!!m,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#s=new Array(e).fill(void 0),this.#u=new V(e),this.#y=new V(e),this.#p=0,this.#m=0,this.#A=Je.create(e),this.#a=0,this.#f=0,typeof c=="function"&&(this.#n=c),typeof l=="function"&&(this.#r=l),typeof f=="function"?(this.#o=f,this.#g=[]):(this.#o=void 0,this.#g=void 0),this.#S=!!this.#n,this.#k=!!this.#r,this.#d=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#e!==0&&!rt(this.#e))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#$()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#i()}if(this.#t===0&&this.ttl===0&&this.#e===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#e){let L="LRU_CACHE_UNBOUNDED";No(L)&&(Ti.add(L),Ri("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",L,i))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#i(){let t=new bt(this.#t),e=new bt(this.#t);this.#E=t,this.#x=e,this.#N=(n,o,a=St.now())=>{if(e[n]=o!==0?a:0,t[n]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{this.#T(n)&&this.#P(this.#c[n],"expire")},o+1);h.unref&&h.unref()}},this.#D=n=>{e[n]=t[n]!==0?St.now():0},this.#v=(n,o)=>{if(t[o]){let a=t[o],h=e[o];if(!a||!h)return;n.ttl=a,n.start=h,n.now=s||r();let c=n.now-h;n.remainingTTL=a-c}};let s=0,r=()=>{let n=St.now();if(this.ttlResolution>0){s=n;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref()}return n};this.getRemainingTTL=n=>{let o=this.#h.get(n);if(o===void 0)return 0;let a=t[o],h=e[o];if(!a||!h)return 1/0;let c=(s||r())-h;return a-c},this.#T=n=>{let o=e[n],a=t[n];return!!a&&!!o&&(s||r())-o>a}}#D=()=>{};#v=()=>{};#N=()=>{};#T=()=>!1;#$(){let t=new bt(this.#t);this.#f=0,this.#C=t,this.#L=e=>{this.#f-=t[e],t[e]=0},this.#W=(e,s,r,n)=>{if(this.#l(s))return 0;if(!rt(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,e),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#M=(e,s,r)=>{if(t[e]=s,this.#e){let n=this.#e-t[e];for(;this.#f>n;)this.#I(!0)}this.#f+=t[e],r&&(r.entrySize=s,r.totalCalculatedSize=this.#f)}}#L=t=>{};#M=(t,e,s)=>{};#W=(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;!(!this.#B(e)||((t||!this.#T(e))&&(yield e),e===this.#p));)e=this.#y[e]}*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;!(!this.#B(e)||((t||!this.#T(e))&&(yield e),e===this.#m));)e=this.#u[e]}#B(t){return t!==void 0&&this.#h.get(this.#c[t])===t}*entries(){for(let t of this.#O())this.#s[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#s[t])&&(yield[this.#c[t],this.#s[t]])}*rentries(){for(let t of this.#_())this.#s[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#s[t])&&(yield[this.#c[t],this.#s[t]])}*keys(){for(let t of this.#O()){let e=this.#c[t];e!==void 0&&!this.#l(this.#s[t])&&(yield e)}}*rkeys(){for(let t of this.#_()){let e=this.#c[t];e!==void 0&&!this.#l(this.#s[t])&&(yield e)}}*values(){for(let t of this.#O())this.#s[t]!==void 0&&!this.#l(this.#s[t])&&(yield this.#s[t])}*rvalues(){for(let t of this.#_())this.#s[t]!==void 0&&!this.#l(this.#s[t])&&(yield this.#s[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let s of this.#O()){let r=this.#s[s],n=this.#l(r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,this.#c[s],this))return this.get(this.#c[s],e)}}forEach(t,e=this){for(let s of this.#O()){let r=this.#s[s],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#c[s],this)}}rforEach(t,e=this){for(let s of this.#_()){let r=this.#s[s],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&t.call(e,n,this.#c[s],this)}}purgeStale(){let t=!1;for(let e of this.#_({allowStale:!0}))this.#T(e)&&(this.#P(this.#c[e],"expire"),t=!0);return t}info(t){let e=this.#h.get(t);if(e===void 0)return;let s=this.#s[e],r=this.#l(s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(this.#E&&this.#x){let o=this.#E[e],a=this.#x[e];if(o&&a){let h=o-(St.now()-a);n.ttl=h,n.start=Date.now()}}return this.#C&&(n.size=this.#C[e]),n}dump(){let t=[];for(let e of this.#O({allowStale:!0})){let s=this.#c[e],r=this.#s[e],n=this.#l(r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(this.#E&&this.#x){o.ttl=this.#E[e];let a=St.now()-this.#x[e];o.start=Math.floor(Date.now()-a)}this.#C&&(o.size=this.#C[e]),t.unshift([s,o])}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let r=Date.now()-s.start;s.start=St.now()-r}this.set(e,s.value,s)}}set(t,e,s={}){if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:c=this.noUpdateTTL}=s,l=this.#W(t,e,s.size||0,a);if(this.maxEntrySize&&l>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.#P(t,"set"),this;let f=this.#a===0?void 0:this.#h.get(t);if(f===void 0)f=this.#a===0?this.#m:this.#A.length!==0?this.#A.pop():this.#a===this.#t?this.#I(!1):this.#a,this.#c[f]=t,this.#s[f]=e,this.#h.set(t,f),this.#u[this.#m]=f,this.#y[f]=this.#m,this.#m=f,this.#a++,this.#M(f,l,h),h&&(h.set="add"),c=!1,this.#k&&this.#r?.(e,t,"add");else{this.#U(f);let u=this.#s[f];if(e!==u){if(this.#R&&this.#l(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=u;d!==void 0&&!o&&(this.#S&&this.#n?.(d,t,"set"),this.#d&&this.#g?.push([d,t,"set"]))}else o||(this.#S&&this.#n?.(u,t,"set"),this.#d&&this.#g?.push([u,t,"set"]));if(this.#L(f),this.#M(f,l,h),this.#s[f]=e,h){h.set="replace";let d=u&&this.#l(u)?u.__staleWhileFetching:u;d!==void 0&&(h.oldValue=d)}}else h&&(h.set="update");this.#k&&this.onInsert?.(e,t,e===u?"update":"replace")}if(r!==0&&!this.#E&&this.#i(),this.#E&&(c||this.#N(f,r,n),h&&this.#v(h,f)),!o&&this.#d&&this.#g){let u=this.#g,d;for(;d=u?.shift();)this.#o?.(...d)}return this}pop(){try{for(;this.#a;){let t=this.#s[this.#p];if(this.#I(!0),this.#l(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#d&&this.#g){let t=this.#g,e;for(;e=t?.shift();)this.#o?.(...e)}}}#I(t){let e=this.#p,s=this.#c[e],r=this.#s[e];return this.#R&&this.#l(r)?r.__abortController.abort(new Error("evicted")):(this.#S||this.#d)&&(this.#S&&this.#n?.(r,s,"evict"),this.#d&&this.#g?.push([r,s,"evict"])),this.#L(e),t&&(this.#c[e]=void 0,this.#s[e]=void 0,this.#A.push(e)),this.#a===1?(this.#p=this.#m=0,this.#A.length=0):this.#p=this.#u[e],this.#h.delete(s),this.#a--,e}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,n=this.#h.get(t);if(n!==void 0){let o=this.#s[n];if(this.#l(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#T(n))r&&(r.has="stale",this.#v(r,n));else return s&&this.#D(n),r&&(r.has="hit",this.#v(r,n)),!0}else r&&(r.has="miss");return!1}peek(t,e={}){let{allowStale:s=this.allowStale}=e,r=this.#h.get(t);if(r===void 0||!s&&this.#T(r))return;let n=this.#s[r];return this.#l(n)?n.__staleWhileFetching:n}#F(t,e,s,r){let n=e===void 0?void 0:this.#s[e];if(this.#l(n))return n;let o=new le,{signal:a}=s;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let h={signal:o.signal,options:s,context:r},c=(p,y=!1)=>{let{aborted:m}=o.signal,b=s.ignoreFetchAbort&&p!==void 0;if(s.status&&(m&&!y?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,b&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),m&&!b&&!y)return f(o.signal.reason);let w=d;return this.#s[e]===d&&(p===void 0?w.__staleWhileFetching?this.#s[e]=w.__staleWhileFetching:this.#P(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,p,h.options))),p},l=p=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=p),f(p)),f=p=>{let{aborted:y}=o.signal,m=y&&s.allowStaleOnFetchAbort,b=m||s.allowStaleOnFetchRejection,w=b||s.noDeleteOnFetchRejection,S=d;if(this.#s[e]===d&&(!w||S.__staleWhileFetching===void 0?this.#P(t,"fetch"):m||(this.#s[e]=S.__staleWhileFetching)),b)return s.status&&S.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw p},u=(p,y)=>{let m=this.#b?.(t,n,h);m&&m instanceof Promise&&m.then(b=>p(b===void 0?void 0:b),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(p(void 0),s.allowStaleOnFetchAbort&&(p=b=>c(b,!0)))})};s.status&&(s.status.fetchDispatched=!0);let d=new Promise(u).then(c,l),g=Object.assign(d,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,g,{...h.options,status:void 0}),e=this.#h.get(t)):this.#s[e]=g,g}#l(t){if(!this.#R)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof le}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:m,signal:b}=e;if(!this.#R)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:m});let w={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:h,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:g,ignoreFetchAbort:d,status:m,signal:b},S=this.#h.get(t);if(S===void 0){m&&(m.fetch="miss");let E=this.#F(t,S,w,p);return E.__returned=E}else{let E=this.#s[S];if(this.#l(E)){let Ft=s&&E.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",Ft&&(m.returnedStale=!0)),Ft?E.__staleWhileFetching:E.__returned=E}let v=this.#T(S);if(!y&&!v)return m&&(m.fetch="hit"),this.#U(S),r&&this.#D(S),m&&this.#v(m,S),E;let N=this.#F(t,S,w,p),L=N.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=v?"stale":"refresh",L&&v&&(m.returnedStale=!0)),L?N.__staleWhileFetching:N.__returned=N}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=this.#w;if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=e,a=this.get(t,o);if(!n&&a!==void 0)return a;let h=s(t,a,{options:o,context:r});return this.set(t,h,o),h}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=e,a=this.#h.get(t);if(a!==void 0){let h=this.#s[a],c=this.#l(h);return o&&this.#v(o,a),this.#T(a)?(o&&(o.get="stale"),c?(o&&s&&h.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?h.__staleWhileFetching:void 0):(n||this.#P(t,"expire"),o&&s&&(o.returnedStale=!0),s?h:void 0)):(o&&(o.get="hit"),c?h.__staleWhileFetching:(this.#U(a),r&&this.#D(a),h))}else o&&(o.get="miss")}#z(t,e){this.#y[e]=t,this.#u[t]=e}#U(t){t!==this.#m&&(t===this.#p?this.#p=this.#u[t]:this.#z(this.#y[t],this.#u[t]),this.#z(this.#m,t),this.#m=t)}delete(t){return this.#P(t,"delete")}#P(t,e){let s=!1;if(this.#a!==0){let r=this.#h.get(t);if(r!==void 0)if(s=!0,this.#a===1)this.#j(e);else{this.#L(r);let n=this.#s[r];if(this.#l(n)?n.__abortController.abort(new Error("deleted")):(this.#S||this.#d)&&(this.#S&&this.#n?.(n,t,e),this.#d&&this.#g?.push([n,t,e])),this.#h.delete(t),this.#c[r]=void 0,this.#s[r]=void 0,r===this.#m)this.#m=this.#y[r];else if(r===this.#p)this.#p=this.#u[r];else{let o=this.#y[r];this.#u[o]=this.#u[r];let a=this.#u[r];this.#y[a]=this.#y[r]}this.#a--,this.#A.push(r)}}if(this.#d&&this.#g?.length){let r=this.#g,n;for(;n=r?.shift();)this.#o?.(...n)}return s}clear(){return this.#j("delete")}#j(t){for(let e of this.#_({allowStale:!0})){let s=this.#s[e];if(this.#l(s))s.__abortController.abort(new Error("deleted"));else{let r=this.#c[e];this.#S&&this.#n?.(s,r,t),this.#d&&this.#g?.push([s,r,t])}}if(this.#h.clear(),this.#s.fill(void 0),this.#c.fill(void 0),this.#E&&this.#x&&(this.#E.fill(0),this.#x.fill(0)),this.#C&&this.#C.fill(0),this.#p=0,this.#m=0,this.#A.length=0,this.#f=0,this.#a=0,this.#d&&this.#g){let e=this.#g,s;for(;s=e?.shift();)this.#o?.(...s)}}};import{posix as Bo,win32 as os}from"node:path";import{fileURLToPath as zo}from"node:url";import{lstatSync as Go,readdir as Ho,readdirSync as qo,readlinkSync as Vo,realpathSync as Ko}from"fs";import*as Yo from"node:fs";import{lstat as Xo,readdir as Zo,readlink as Qo,realpath as ta}from"node:fs/promises";import{EventEmitter as is}from"node:events";import Ni from"node:stream";import{StringDecoder as Po}from"node:string_decoder";var Ai=typeof process=="object"&&process?process:{stdout:null,stderr:null},Do=i=>!!i&&typeof i=="object"&&(i instanceof ot||i instanceof Ni||Lo(i)||Fo(i)),Lo=i=>!!i&&typeof i=="object"&&i instanceof is&&typeof i.pipe=="function"&&i.pipe!==Ni.Writable.prototype.pipe,Fo=i=>!!i&&typeof i=="object"&&i instanceof is&&typeof i.write=="function"&&typeof i.end=="function",X=Symbol("EOF"),Z=Symbol("maybeEmitEnd"),nt=Symbol("emittedEnd"),fe=Symbol("emittingEnd"),Vt=Symbol("emittedError"),ue=Symbol("closed"),Ci=Symbol("read"),de=Symbol("flush"),_i=Symbol("flushChunk"),z=Symbol("encoding"),Et=Symbol("decoder"),T=Symbol("flowing"),Kt=Symbol("paused"),xt=Symbol("resume"),R=Symbol("buffer"),D=Symbol("pipes"),O=Symbol("bufferLength"),Xe=Symbol("bufferPush"),pe=Symbol("bufferShift"),_=Symbol("objectMode"),x=Symbol("destroyed"),Ze=Symbol("error"),Qe=Symbol("emitData"),ki=Symbol("emitEnd"),ts=Symbol("emitEnd2"),K=Symbol("async"),es=Symbol("abort"),me=Symbol("aborted"),Yt=Symbol("signal"),ft=Symbol("dataListeners"),U=Symbol("discarded"),Jt=i=>Promise.resolve().then(i),Mo=i=>i(),Io=i=>i==="end"||i==="finish"||i==="prefinish",Uo=i=>i instanceof ArrayBuffer||!!i&&typeof i=="object"&&i.constructor&&i.constructor.name==="ArrayBuffer"&&i.byteLength>=0,jo=i=>!Buffer.isBuffer(i)&&ArrayBuffer.isView(i),ge=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[xt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ss=class extends ge{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=r=>e.emit("error",r),t.on("error",this.proxyErrors)}},$o=i=>!!i.objectMode,Wo=i=>!i.objectMode&&!!i.encoding&&i.encoding!=="buffer",ot=class extends is{[T]=!1;[Kt]=!1;[D]=[];[R]=[];[_];[z];[K];[Et];[X]=!1;[nt]=!1;[fe]=!1;[ue]=!1;[Vt]=null;[O]=0;[x]=!1;[Yt];[me]=!1;[ft]=0;[U]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");$o(e)?(this[_]=!0,this[z]=null):Wo(e)?(this[z]=e.encoding,this[_]=!1):(this[_]=!1,this[z]=null),this[K]=!!e.async,this[Et]=this[z]?new Po(this[z]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[R]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[D]});let{signal:s}=e;s&&(this[Yt]=s,s.aborted?this[es]():s.addEventListener("abort",()=>this[es]()))}get bufferLength(){return this[O]}get encoding(){return this[z]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[_]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[K]}set async(t){this[K]=this[K]||!!t}[es](){this[me]=!0,this.emit("abort",this[Yt]?.reason),this.destroy(this[Yt]?.reason)}get aborted(){return this[me]}set aborted(t){}write(t,e,s){if(this[me])return!1;if(this[X])throw new Error("write after end");if(this[x])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let r=this[K]?Jt:Mo;if(!this[_]&&!Buffer.isBuffer(t)){if(jo(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Uo(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[_]?(this[T]&&this[O]!==0&&this[de](!0),this[T]?this.emit("data",t):this[Xe](t),this[O]!==0&&this.emit("readable"),s&&r(s),this[T]):t.length?(typeof t=="string"&&!(e===this[z]&&!this[Et]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[z]&&(t=this[Et].write(t)),this[T]&&this[O]!==0&&this[de](!0),this[T]?this.emit("data",t):this[Xe](t),this[O]!==0&&this.emit("readable"),s&&r(s),this[T]):(this[O]!==0&&this.emit("readable"),s&&r(s),this[T])}read(t){if(this[x])return null;if(this[U]=!1,this[O]===0||t===0||t&&t>this[O])return this[Z](),null;this[_]&&(t=null),this[R].length>1&&!this[_]&&(this[R]=[this[z]?this[R].join(""):Buffer.concat(this[R],this[O])]);let e=this[Ci](t||null,this[R][0]);return this[Z](),e}[Ci](t,e){if(this[_])this[pe]();else{let s=e;t===s.length||t===null?this[pe]():typeof s=="string"?(this[R][0]=s.slice(t),e=s.slice(0,t),this[O]-=t):(this[R][0]=s.subarray(t),e=s.subarray(0,t),this[O]-=t)}return this.emit("data",e),!this[R].length&&!this[X]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[X]=!0,this.writable=!1,(this[T]||!this[Kt])&&this[Z](),this}[xt](){this[x]||(!this[ft]&&!this[D].length&&(this[U]=!0),this[Kt]=!1,this[T]=!0,this.emit("resume"),this[R].length?this[de]():this[X]?this[Z]():this.emit("drain"))}resume(){return this[xt]()}pause(){this[T]=!1,this[Kt]=!0,this[U]=!1}get destroyed(){return this[x]}get flowing(){return this[T]}get paused(){return this[Kt]}[Xe](t){this[_]?this[O]+=1:this[O]+=t.length,this[R].push(t)}[pe](){return this[_]?this[O]-=1:this[O]-=this[R][0].length,this[R].shift()}[de](t=!1){do;while(this[_i](this[pe]())&&this[R].length);!t&&!this[R].length&&!this[X]&&this.emit("drain")}[_i](t){return this.emit("data",t),this[T]}pipe(t,e){if(this[x])return t;this[U]=!1;let s=this[nt];return e=e||{},t===Ai.stdout||t===Ai.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[D].push(e.proxyErrors?new ss(this,t,e):new ge(this,t,e)),this[K]?Jt(()=>this[xt]()):this[xt]()),t}unpipe(t){let e=this[D].find(s=>s.dest===t);e&&(this[D].length===1?(this[T]&&this[ft]===0&&(this[T]=!1),this[D]=[]):this[D].splice(this[D].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[U]=!1,this[ft]++,!this[D].length&&!this[T]&&this[xt]();else if(t==="readable"&&this[O]!==0)super.emit("readable");else if(Io(t)&&this[nt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Vt]){let r=e;this[K]?Jt(()=>r.call(this,this[Vt])):r.call(this,this[Vt])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[ft]=this.listeners("data").length,this[ft]===0&&!this[U]&&!this[D].length&&(this[T]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[ft]=0,!this[U]&&!this[D].length&&(this[T]=!1)),e}get emittedEnd(){return this[nt]}[Z](){!this[fe]&&!this[nt]&&!this[x]&&this[R].length===0&&this[X]&&(this[fe]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ue]&&this.emit("close"),this[fe]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==x&&this[x])return!1;if(t==="data")return!this[_]&&!s?!1:this[K]?(Jt(()=>this[Qe](s)),!0):this[Qe](s);if(t==="end")return this[ki]();if(t==="close"){if(this[ue]=!0,!this[nt]&&!this[x])return!1;let n=super.emit("close");return this.removeAllListeners("close"),n}else if(t==="error"){this[Vt]=s,super.emit(Ze,s);let n=!this[Yt]||this.listeners("error").length?super.emit("error",s):!1;return this[Z](),n}else if(t==="resume"){let n=super.emit("resume");return this[Z](),n}else if(t==="finish"||t==="prefinish"){let n=super.emit(t);return this.removeAllListeners(t),n}let r=super.emit(t,...e);return this[Z](),r}[Qe](t){for(let s of this[D])s.dest.write(t)===!1&&this.pause();let e=this[U]?!1:super.emit("data",t);return this[Z](),e}[ki](){return this[nt]?!1:(this[nt]=!0,this.readable=!1,this[K]?(Jt(()=>this[ts]()),!0):this[ts]())}[ts](){if(this[Et]){let e=this[Et].end();if(e){for(let s of this[D])s.dest.write(e);this[U]||super.emit("data",e)}}for(let e of this[D])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[_]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[_]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[_])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[z]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(x,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[U]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[X])return e();let n,o,a=f=>{this.off("data",h),this.off("end",c),this.off(x,l),e(),o(f)},h=f=>{this.off("error",a),this.off("end",c),this.off(x,l),this.pause(),n({value:f,done:!!this[X]})},c=()=>{this.off("error",a),this.off("data",h),this.off(x,l),e(),n({done:!0,value:void 0})},l=()=>a(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,n=f,this.once(x,l),this.once("error",a),this.once("end",c),this.once("data",h)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[U]=!1;let t=!1,e=()=>(this.pause(),this.off(Ze,e),this.off(x,e),this.off("end",e),t=!0,{done:!0,value:void 0}),s=()=>{if(t)return e();let r=this.read();return r===null?e():{done:!1,value:r}};return this.once("end",e),this.once(Ze,e),this.once(x,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[x])return t?this.emit("error",t):this.emit(x),this;this[x]=!0,this[U]=!0,this[R].length=0,this[O]=0;let e=this;return typeof e.close=="function"&&!this[ue]&&e.close(),t?this.emit("error",t):this.emit(x),this}static get isStream(){return Do}};var Jo=Ko.native,Zt={lstatSync:Go,readdir:Ho,readdirSync:qo,readlinkSync:Vo,realpathSync:Jo,promises:{lstat:Xo,readdir:Zo,readlink:Qo,realpath:ta}},Mi=i=>!i||i===Zt||i===Yo?Zt:{...Zt,...i,promises:{...Zt.promises,...i.promises||{}}},Ii=/^\\\\\?\\([a-z]:)\\?$/i,ea=i=>i.replace(/\//g,"\\").replace(Ii,"$1\\"),sa=/[\\\/]/,W=0,Ui=1,ji=2,Y=4,$i=6,Wi=8,ut=10,Bi=12,$=15,Xt=~$,rs=16,Pi=32,Qt=64,G=128,we=256,Se=512,Di=Qt|G|Se,ia=1023,ns=i=>i.isFile()?Wi:i.isDirectory()?Y:i.isSymbolicLink()?ut:i.isCharacterDevice()?ji:i.isBlockDevice()?$i:i.isSocket()?Bi:i.isFIFO()?Ui:W,Li=new Map,te=i=>{let t=Li.get(i);if(t)return t;let e=i.normalize("NFKD");return Li.set(i,e),e},Fi=new Map,ye=i=>{let t=Fi.get(i);if(t)return t;let e=te(i.toLowerCase());return Fi.set(i,e),e},be=class extends qt{constructor(){super({max:256})}},as=class extends qt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},zi=Symbol("PathScurry setAsCwd"),k=class{name;root;roots;parent;nocase;isCWD=!1;#t;#e;get dev(){return this.#e}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#b;get gid(){return this.#b}#w;get rdev(){return this.#w}#a;get blksize(){return this.#a}#f;get ino(){return this.#f}#h;get size(){return this.#h}#c;get blocks(){return this.#c}#s;get atimeMs(){return this.#s}#u;get mtimeMs(){return this.#u}#y;get ctimeMs(){return this.#y}#p;get birthtimeMs(){return this.#p}#m;get atime(){return this.#m}#A;get mtime(){return this.#A}#g;get ctime(){return this.#g}#C;get birthtime(){return this.#C}#x;#E;#S;#R;#d;#k;#i;#D;#v;#N;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=W,s,r,n,o,a){this.name=t,this.#x=n?ye(t):te(t),this.#i=e&ia,this.nocase=n,this.roots=r,this.root=s||this,this.#D=o,this.#S=a.fullpath,this.#d=a.relative,this.#k=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=Mi(a.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#D}resolve(t){if(!t)return this;let e=this.getRootString(t),r=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#T(r):this.#T(r)}#T(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#D.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#D.set(this,e),this.#i&=~rs,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),r=this.nocase?ye(t):te(t);for(let h of s)if(h.#x===r)return h;let n=this.parent?this.sep:"",o=this.#S?this.#S+n+t:void 0,a=this.newChild(t,W,{...e,parent:this,fullpath:o});return this.canReaddir()||(a.#i|=G),s.push(a),a}relative(){if(this.isCWD)return"";if(this.#d!==void 0)return this.#d;let t=this.name,e=this.parent;if(!e)return this.#d=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let t=this.name,e=this.parent;if(!e)return this.#k=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#S!==void 0)return this.#S;let t=this.name,e=this.parent;if(!e)return this.#S=this.name;let r=e.fullpath()+(e.parent?this.sep:"")+t;return this.#S=r}fullpathPosix(){if(this.#R!==void 0)return this.#R;if(this.sep==="/")return this.#R=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#R=`//?/${r}`:this.#R=r}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#R=s}isUnknown(){return(this.#i&$)===W}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#i&$)===Wi}isDirectory(){return(this.#i&$)===Y}isCharacterDevice(){return(this.#i&$)===ji}isBlockDevice(){return(this.#i&$)===$i}isFIFO(){return(this.#i&$)===Ui}isSocket(){return(this.#i&$)===Bi}isSymbolicLink(){return(this.#i&ut)===ut}lstatCached(){return this.#i&Pi?this:void 0}readlinkCached(){return this.#v}realpathCached(){return this.#N}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#v)return!0;if(!this.parent)return!1;let t=this.#i&$;return!(t!==W&&t!==ut||this.#i&we||this.#i&G)}calledReaddir(){return!!(this.#i&rs)}isENOENT(){return!!(this.#i&G)}isNamed(t){return this.nocase?this.#x===ye(t):this.#x===te(t)}async readlink(){let t=this.#v;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#v=s}catch(e){this.#I(e.code);return}}readlinkSync(){let t=this.#v;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#v=s}catch(e){this.#I(e.code);return}}#$(t){this.#i|=rs;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#L()}}#L(){this.#i&G||(this.#i=(this.#i|G)&Xt,this.#M())}#M(){let t=this.children();t.provisional=0;for(let e of t)e.#L()}#W(){this.#i|=Se,this.#O()}#O(){if(this.#i&Qt)return;let t=this.#i;(t&$)===Y&&(t&=Xt),this.#i=t|Qt,this.#M()}#_(t=""){t==="ENOTDIR"||t==="EPERM"?this.#O():t==="ENOENT"?this.#L():this.children().provisional=0}#B(t=""){t==="ENOTDIR"?this.parent.#O():t==="ENOENT"&&this.#L()}#I(t=""){let e=this.#i;e|=we,t==="ENOENT"&&(e|=G),(t==="EINVAL"||t==="UNKNOWN")&&(e&=Xt),this.#i=e,t==="ENOTDIR"&&this.parent&&this.parent.#O()}#F(t,e){return this.#z(t,e)||this.#l(t,e)}#l(t,e){let s=ns(t),r=this.newChild(t.name,s,{parent:this}),n=r.#i&$;return n!==Y&&n!==ut&&n!==W&&(r.#i|=Qt),e.unshift(r),e.provisional++,r}#z(t,e){for(let s=e.provisional;s<e.length;s++){let r=e[s];if((this.nocase?ye(t.name):te(t.name))===r.#x)return this.#U(t,r,s,e)}}#U(t,e,s,r){let n=e.name;return e.#i=e.#i&Xt|ns(t),n!==t.name&&(e.name=t.name),s!==r.provisional&&(s===r.length-1?r.pop():r.splice(s,1),r.unshift(e)),r.provisional++,e}async lstat(){if(!(this.#i&G))try{return this.#P(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#B(t.code)}}lstatSync(){if(!(this.#i&G))try{return this.#P(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#B(t.code)}}#P(t){let{atime:e,atimeMs:s,birthtime:r,birthtimeMs:n,blksize:o,blocks:a,ctime:h,ctimeMs:c,dev:l,gid:f,ino:u,mode:d,mtime:g,mtimeMs:p,nlink:y,rdev:m,size:b,uid:w}=t;this.#m=e,this.#s=s,this.#C=r,this.#p=n,this.#a=o,this.#c=a,this.#g=h,this.#y=c,this.#e=l,this.#b=f,this.#f=u,this.#n=d,this.#A=g,this.#u=p,this.#r=y,this.#w=m,this.#h=b,this.#o=w;let S=ns(t);this.#i=this.#i&Xt|S|Pi,S!==W&&S!==Y&&S!==ut&&(this.#i|=Qt)}#j=[];#H=!1;#q(t){this.#H=!1;let e=this.#j.slice();this.#j.length=0,e.forEach(s=>s(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let n=s.slice(0,s.provisional);e?t(null,n):queueMicrotask(()=>t(null,n));return}if(this.#j.push(t),this.#H)return;this.#H=!0;let r=this.fullpath();this.#t.readdir(r,{withFileTypes:!0},(n,o)=>{if(n)this.#_(n.code),s.provisional=0;else{for(let a of o)this.#F(a,s);this.#$(s)}this.#q(s.slice(0,s.provisional))})}#G;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#G)await this.#G;else{let s=()=>{};this.#G=new Promise(r=>s=r);try{for(let r of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#F(r,t);this.#$(t)}catch(r){this.#_(r.code),t.provisional=0}this.#G=void 0,s()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#t.readdirSync(e,{withFileTypes:!0}))this.#F(s,t);this.#$(t)}catch(s){this.#_(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#i&Di)return!1;let t=$&this.#i;return t===W||t===Y||t===ut}shouldWalk(t,e){return(this.#i&Y)===Y&&!(this.#i&Di)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#N)return this.#N;if(!((Se|we|G)&this.#i))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#N=this.resolve(t)}catch{this.#W()}}realpathSync(){if(this.#N)return this.#N;if(!((Se|we|G)&this.#i))try{let t=this.#t.realpathSync(this.fullpath());return this.#N=this.resolve(t)}catch{this.#W()}}[zi](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],r=this;for(;r&&r.parent;)e.add(r),r.#d=s.join(this.sep),r.#k=s.join("/"),r=r.parent,s.push("..");for(r=t;r&&r.parent&&!e.has(r);)r.#d=void 0,r.#k=void 0,r=r.parent}},Ee=class i extends k{sep="\\";splitSep=sa;constructor(t,e=W,s,r,n,o,a){super(t,e,s,r,n,o,a)}newChild(t,e=W,s={}){return new i(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return os.parse(t).root}getRoot(t){if(t=ea(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=s;return this.roots[t]=new vt(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Ii,"$1\\"),t===e}},xe=class i extends k{splitSep="/";sep="/";constructor(t,e=W,s,r,n,o,a){super(t,e,s,r,n,o,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=W,s={}){return new i(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},ve=class{root;rootPath;roots;cwd;#t;#e;#n;nocase;#r;constructor(t=process.cwd(),e,s,{nocase:r,childrenCacheSize:n=16*1024,fs:o=Zt}={}){this.#r=Mi(o),(t instanceof URL||t.startsWith("file://"))&&(t=zo(t));let a=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new be,this.#e=new be,this.#n=new as(n);let h=a.substring(this.rootPath.length).split(s);if(h.length===1&&!h[0]&&h.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let c=this.root,l=h.length-1,f=e.sep,u=this.rootPath,d=!1;for(let g of h){let p=l--;c=c.child(g,{relative:new Array(p).fill("..").join(f),relativePosix:new Array(p).fill("..").join("/"),fullpath:u+=(d?"":f)+g}),d=!0}this.cwd=c}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#t.get(e);if(s!==void 0)return s;let r=this.cwd.resolve(e).fullpath();return this.#t.set(e,r),r}resolvePosix(...t){let e="";for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#e.get(e);if(s!==void 0)return s;let r=this.cwd.resolve(e).fullpathPosix();return this.#e.set(e,r),r}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let r=await t.readdir();return s?r:r.map(n=>n.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(r=>r.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(s?t:t.fullpath());let h=new Set,c=(f,u)=>{h.add(f),f.readdirCB((d,g)=>{if(d)return u(d);let p=g.length;if(!p)return u();let y=()=>{--p===0&&u()};for(let m of g)(!n||n(m))&&a.push(s?m:m.fullpath()),r&&m.isSymbolicLink()?m.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(h,o)?c(b,y):y()):m.shouldWalk(h,o)?c(m,y):y()},!0)},l=t;return new Promise((f,u)=>{c(l,d=>{if(d)return u(d);f(a)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=[];(!n||n(t))&&a.push(s?t:t.fullpath());let h=new Set([t]);for(let c of h){let l=c.readdirSync();for(let f of l){(!n||n(f))&&a.push(s?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(r&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(h,o)&&h.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e;(!n||n(t))&&(yield s?t:t.fullpath());let a=new Set([t]);for(let h of a){let c=h.readdirSync();for(let l of c){(!n||n(l))&&(yield s?l:l.fullpath());let f=l;if(l.isSymbolicLink()){if(!(r&&(f=l.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(a,o)&&a.add(f)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new ot({objectMode:!0});(!n||n(t))&&a.write(s?t:t.fullpath());let h=new Set,c=[t],l=0,f=()=>{let u=!1;for(;!u;){let d=c.shift();if(!d){l===0&&a.end();return}l++,h.add(d);let g=(y,m,b=!1)=>{if(y)return a.emit("error",y);if(r&&!b){let w=[];for(let S of m)S.isSymbolicLink()&&w.push(S.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(w.length){Promise.all(w).then(()=>g(null,m,!0));return}}for(let w of m)w&&(!n||n(w))&&(a.write(s?w:w.fullpath())||(u=!0));l--;for(let w of m){let S=w.realpathCached()||w;S.shouldWalk(h,o)&&c.push(S)}u&&!a.flowing?a.once("drain",f):p||f()},p=!0;d.readdirCB(g,!0),p=!1}};return f(),a}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof k||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:r=!1,filter:n,walkFilter:o}=e,a=new ot({objectMode:!0}),h=new Set;(!n||n(t))&&a.write(s?t:t.fullpath());let c=[t],l=0,f=()=>{let u=!1;for(;!u;){let d=c.shift();if(!d){l===0&&a.end();return}l++,h.add(d);let g=d.readdirSync();for(let p of g)(!n||n(p))&&(a.write(s?p:p.fullpath())||(u=!0));l--;for(let p of g){let y=p;if(p.isSymbolicLink()){if(!(r&&(y=p.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(h,o)&&c.push(y)}}u&&!a.flowing&&a.once("drain",f)};return f(),a}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[zi](e)}},vt=class extends ve{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,os,"\\",{...e,nocase:s}),this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(t){return os.parse(t).root.toUpperCase()}newRoot(t){return new Ee(this.rootPath,Y,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Tt=class extends ve{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,Bo,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new xe(this.rootPath,Y,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},ee=class extends Tt{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},nl=process.platform==="win32"?Ee:xe,Gi=process.platform==="win32"?vt:process.platform==="darwin"?ee:Tt;var ra=i=>i.length>=1,na=i=>i.length>=1,Rt=class i{#t;#e;#n;length;#r;#o;#b;#w;#a;#f;#h=!0;constructor(t,e,s,r){if(!ra(t))throw new TypeError("empty pattern list");if(!na(e))throw new TypeError("empty glob list");if(e.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#e=e,this.#n=s,this.#r=r,this.#n===0){if(this.isUNC()){let[n,o,a,h,...c]=this.#t,[l,f,u,d,...g]=this.#e;c[0]===""&&(c.shift(),g.shift());let p=[n,o,a,h,""].join("/"),y=[l,f,u,d,""].join("/");this.#t=[p,...c],this.#e=[y,...g],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[a,...h]=this.#e;o[0]===""&&(o.shift(),h.shift());let c=n+"/",l=a+"/";this.#t=[c,...o],this.#e=[l,...h],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===A}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#b=this.#b||(this.#n===0?this.isAbsolute()?this.#e[0]+this.#e.slice(1).join("/"):this.#e.join("/"):this.#e.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new i(this.#t,this.#e,this.#n+1,this.#r),this.#o.#f=this.#f,this.#o.#a=this.#a,this.#o.#w=this.#w,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=this.#r==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#w!==void 0?this.#w:this.#w=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#h)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#h?!1:(this.#h=!1,!0)}};var oa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ot=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:r,noglobstar:n,platform:o=oa}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:r,noglobstar:n,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let e=new I(t,this.mmopts);for(let s=0;s<e.set.length;s++){let r=e.set[s],n=e.globParts[s];if(!r||!n)throw new Error("invalid pattern object");for(;r[0]==="."&&n[0]===".";)r.shift(),n.shift();let o=new Rt(r,n,0,this.platform),a=new I(o.globString(),this.mmopts),h=n[n.length-1]==="**",c=o.isAbsolute();c?this.absolute.push(a):this.relative.push(a),h&&(c?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let e=t.fullpath(),s=`${e}/`,r=t.relative()||".",n=`${r}/`;for(let o of this.relative)if(o.match(r)||o.match(n))return!0;for(let o of this.absolute)if(o.match(e)||o.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let r of this.relativeChildren)if(r.match(s))return!0;for(let r of this.absoluteChildren)if(r.match(e))return!0;return!1}};var hs=class i{store;constructor(t=new Map){this.store=t}copy(){return new i(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),r=this.store.get(s);r?r.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},cs=class{store=new Map;add(t,e,s){let r=(e?2:0)|(s?1:0),n=this.store.get(t);this.store.set(t,n===void 0?r:r&n)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},ls=class{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(r=>r.globString()===e.globString())||s.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},se=class i{hasWalkedCache;matches=new cs;subwalks=new ls;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new hs}processPatterns(t,e){this.patterns=e;let s=e.map(r=>[t,r]);for(let[r,n]of s){this.hasWalkedCache.storeWalked(r,n);let o=n.root(),a=n.isAbsolute()&&this.opts.absolute!==!1;if(o){r=r.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=n.rest();if(f)n=f;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let h,c,l=!1;for(;typeof(h=n.pattern())=="string"&&(c=n.rest());)r=r.resolve(h),n=c,l=!0;if(h=n.pattern(),c=n.rest(),l){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof h=="string"){let f=h===".."||h===""||h===".";this.matches.add(r.resolve(h),a,f);continue}else if(h===A){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let f=c?.pattern(),u=c?.rest();if(!c||(f===""||f===".")&&!u)this.matches.add(r,a,f===""||f===".");else if(f===".."){let d=r.parent||r;u?this.hasWalkedCache.hasWalked(d,u)||this.subwalks.add(d,u):this.matches.add(d,a,!0)}}else h instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new i(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),r=this.child();for(let n of e)for(let o of s){let a=o.isAbsolute(),h=o.pattern(),c=o.rest();h===A?r.testGlobstar(n,o,c,a):h instanceof RegExp?r.testRegExp(n,h,c,a):r.testString(n,h,c,a)}return r}testGlobstar(t,e,s,r){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,r,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let n=s.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(t,n,s.rest(),r);else if(n===".."){let o=t.parent||t;this.subwalks.add(o,s)}else n instanceof RegExp&&this.testRegExp(t,n,s.rest(),r)}}testRegExp(t,e,s,r){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,r,!1))}testString(t,e,s,r){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,r,!1))}};var aa=(i,t)=>typeof i=="string"?new Ot([i],t):Array.isArray(i)?new Ot(i,t):i,Te=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#e;#n;signal;maxDepth;includeChildMatches;constructor(t,e,s){if(this.patterns=t,this.path=e,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#e=aa(s.ignore??[],s),!this.includeChildMatches&&typeof this.#e.add!="function")){let r="cannot ignore child matches, ignore lacks add() method.";throw new Error(r)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#r(t){return this.seen.has(t)||!!this.#e?.ignored?.(t)}#o(t){return!!this.#e?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let n=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=await n.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(n,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#r(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let n=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&n?.isSymbolicLink()){let o=n.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(n,e)}matchFinish(t,e){if(this.#r(t))return;if(!this.includeChildMatches&&this.#e?.add){let n=`${t.relativePosix()}/**`;this.#e.add(n)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let r=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let n=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(n+r)}else{let n=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(n?o+n+r:"."+r)}}async match(t,e,s){let r=await this.matchCheck(t,s);r&&this.matchFinish(r,e)}matchSync(t,e,s){let r=this.matchCheckSync(t,s);r&&this.matchFinish(r,e)}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new se(this.opts),s)}walkCB2(t,e,s,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,r));return}s.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,h,c]of s.matches.entries())this.#r(a)||(n++,this.match(a,h,c).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let h=a.readdirCached();a.calledReaddir()?this.walkCB3(a,h,s,o):a.readdirCB((c,l)=>this.walkCB3(a,l,s,o),!0)}o()}walkCB3(t,e,s,r){s=s.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,h,c]of s.matches.entries())this.#r(a)||(n++,this.match(a,h,c).then(()=>o()));for(let[a,h]of s.subwalks.entries())n++,this.walkCB2(a,h,s.child(),o);o()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new se(this.opts),s)}walkCB2Sync(t,e,s,r){if(this.#o(t))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,r));return}s.processPatterns(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,h,c]of s.matches.entries())this.#r(a)||this.matchSync(a,h,c);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let h=a.readdirSync();this.walkCB3Sync(a,h,s,o)}o()}walkCB3Sync(t,e,s,r){s=s.filterEntries(t,e);let n=1,o=()=>{--n===0&&r()};for(let[a,h,c]of s.matches.entries())this.#r(a)||this.matchSync(a,h,c);for(let[a,h]of s.subwalks.entries())n++,this.walkCB2Sync(a,h,s.child(),o);o()}},ie=class extends Te{matches=new Set;constructor(t,e,s){super(t,e,s)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},re=class extends Te{results;constructor(t,e,s){super(t,e,s),this.results=new ot({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var ca=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",H=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=ha(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(h=>h.includes("/")?h:`./**/${h}`)}if(this.pattern=t,this.platform=e.platform||ca,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let h=e.platform==="win32"?vt:e.platform==="darwin"?ee:e.platform?Tt:Gi;this.scurry=new h(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",r={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(h=>new I(h,r)),[o,a]=n.reduce((h,c)=>(h[0].push(...c.set),h[1].push(...c.globParts),h),[[],[]]);this.patterns=o.map((h,c)=>{let l=a[c];if(!l)throw new Error("invalid pattern object");return new Rt(h,l,0,this.platform)})}async walk(){return[...await new ie(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new ie(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new re(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new re(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var fs=(i,t={})=>{Array.isArray(i)||(i=[i]);for(let e of i)if(new I(e,t).hasMagic())return!0;return!1};function Oe(i,t={}){return new H(i,t).streamSync()}function qi(i,t={}){return new H(i,t).stream()}function Ae(i,t={}){return new H(i,t).walkSync()}async function Hi(i,t={}){return new H(i,t).walk()}function Ce(i,t={}){return new H(i,t).iterateSync()}function Vi(i,t={}){return new H(i,t).iterate()}var la=Oe,fa=Object.assign(qi,{sync:Oe}),ua=Ce,da=Object.assign(Vi,{sync:Ce}),pa=Object.assign(Ae,{stream:Oe,iterate:Ce}),Re=Object.assign(Hi,{glob:Hi,globSync:Ae,sync:pa,globStream:qi,stream:fa,globStreamSync:Oe,streamSync:la,globIterate:Vi,iterate:da,globIterateSync:Ce,iterateSync:ua,Glob:H,hasMagic:fs,escape:yt,unescape:B});Re.glob=Re;var at=(i,t)=>typeof i>"u"||typeof i===t,Ki=i=>!!i&&typeof i=="object"&&at(i.preserveRoot,"boolean")&&at(i.tmp,"string")&&at(i.maxRetries,"number")&&at(i.retryDelay,"number")&&at(i.backoff,"number")&&at(i.maxBackoff,"number")&&(at(i.glob,"boolean")||i.glob&&typeof i.glob=="object")&&at(i.filter,"function"),Yi=i=>{if(!Ki(i))throw new Error("invalid rimraf options")},Ji=i=>{Yi(i);let{glob:t,...e}=i;if(!t)return e;let s=t===!0?i.signal?{signal:i.signal}:{}:i.signal?{signal:i.signal,...t}:t;return{...e,glob:{...s,absolute:!0,withFileTypes:!1}}},Xi=(i={})=>Ji(i),Zi=(i={})=>Ji(i);import{parse as Qi,resolve as ma}from"path";import{inspect as ga}from"util";var q=process.env.__TESTING_RIMRAF_PLATFORM__||process.platform;var wa=(i,t={})=>{let e=typeof i;if(e!=="string"){let r=i&&e==="object"&&i.constructor,o=`The "path" argument must be of type string. Received ${r&&r.name?`an instance of ${r.name}`:e==="object"?ga(i):`type ${e} ${i}`}`;throw Object.assign(new TypeError(o),{path:i,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(i)){let r="path must be a string without null bytes";throw Object.assign(new TypeError(r),{path:i,code:"ERR_INVALID_ARG_VALUE"})}i=ma(i);let{root:s}=Qi(i);if(i===s&&t.preserveRoot!==!1){let r="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(r),{path:i,code:"ERR_PRESERVE_ROOT"})}if(q==="win32"){let r=/[*|"<>?:]/,{root:n}=Qi(i);if(r.test(i.substring(n.length)))throw Object.assign(new Error("Illegal characters in path."),{path:i,code:"EINVAL"})}return i},ne=wa;import Q from"fs";import{chmodSync as _e,mkdirSync as Gl,renameSync as er,rmdirSync as At,rmSync as sr,statSync as ir,lstatSync as Ct,unlinkSync as _t}from"fs";import{readdirSync as ya}from"fs";var tr=i=>ya(i,{withFileTypes:!0}),Sa=(i,t)=>new Promise((e,s)=>Q.chmod(i,t,(r,...n)=>r?s(r):e(...n))),ba=(i,t)=>new Promise((e,s)=>Q.mkdir(i,t,(r,n)=>r?s(r):e(n))),Ea=i=>new Promise((t,e)=>Q.readdir(i,{withFileTypes:!0},(s,r)=>s?e(s):t(r))),xa=(i,t)=>new Promise((e,s)=>Q.rename(i,t,(r,...n)=>r?s(r):e(...n))),va=(i,t)=>new Promise((e,s)=>Q.rm(i,t,(r,...n)=>r?s(r):e(...n))),Ta=i=>new Promise((t,e)=>Q.rmdir(i,(s,...r)=>s?e(s):t(...r))),Ra=i=>new Promise((t,e)=>Q.stat(i,(s,r)=>s?e(s):t(r))),Oa=i=>new Promise((t,e)=>Q.lstat(i,(s,r)=>s?e(s):t(r))),Aa=i=>new Promise((t,e)=>Q.unlink(i,(s,...r)=>s?e(s):t(...r))),F={chmod:Sa,mkdir:ba,readdir:Ea,rename:xa,rm:va,rmdir:Ta,stat:Ra,lstat:Oa,unlink:Aa};import{parse as rr,resolve as nr}from"path";var{readdir:Ca}=F,kt=i=>Ca(i).catch(t=>t),Nt=i=>{try{return tr(i)}catch(t){return t}};var tt=async i=>i.catch(t=>{if(t.code!=="ENOENT")throw t}),et=i=>{try{return i()}catch(t){if(t?.code!=="ENOENT")throw t}};var{lstat:_a,rmdir:ka,unlink:Na}=F,ke=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return await or(i,t,await _a(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},Ne=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return ar(i,t,Ct(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},or=async(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;let s=e.isDirectory()?await kt(i):null;if(!Array.isArray(s)){if(s){if(s.code==="ENOENT")return!0;if(s.code!=="ENOTDIR")throw s}return t.filter&&!await t.filter(i,e)?!1:(await tt(Na(i)),!0)}return!(await Promise.all(s.map(n=>or(nr(i,n.name),t,n)))).reduce((n,o)=>n&&o,!0)||t.preserveRoot===!1&&i===rr(i).root||t.filter&&!await t.filter(i,e)?!1:(await tt(ka(i)),!0)},ar=(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;let s=e.isDirectory()?Nt(i):null;if(!Array.isArray(s)){if(s){if(s.code==="ENOENT")return!0;if(s.code!=="ENOTDIR")throw s}return t.filter&&!t.filter(i,e)?!1:(et(()=>_t(i)),!0)}let r=!0;for(let n of s){let o=nr(i,n.name);r=ar(o,t,n)&&r}return t.preserveRoot===!1&&i===rr(i).root||!r||t.filter&&!t.filter(i,e)?!1:(et(()=>At(i)),!0)};import{parse as gr,resolve as wr}from"path";var{chmod:Pa}=F,us=i=>async t=>{try{return await i(t)}catch(e){let s=e;if(s?.code==="ENOENT")return;if(s?.code==="EPERM"){try{await Pa(t,438)}catch(r){if(r?.code==="ENOENT")return;throw e}return await i(t)}throw e}},ds=i=>t=>{try{return i(t)}catch(e){let s=e;if(s?.code==="ENOENT")return;if(s?.code==="EPERM"){try{_e(t,438)}catch(r){if(r?.code==="ENOENT")return;throw e}return i(t)}throw e}};var hr=new Set(["EMFILE","ENFILE","EBUSY"]),ps=i=>{let t=async(e,s,r=1,n=0)=>{let o=s.maxBackoff||200,a=s.backoff||1.2,h=s.maxRetries||10,c=0;for(;;)try{return await i(e)}catch(l){let f=l;if(f?.path===e&&f?.code&&hr.has(f.code)){if(r=Math.ceil(r*a),n=r+n,n<o)return new Promise((u,d)=>{setTimeout(()=>{t(e,s,r,n).then(u,d)},r)});if(c<h){c++;continue}}throw l}};return t},ms=i=>(e,s)=>{let r=s.maxRetries||10,n=0;for(;;)try{return i(e)}catch(o){let a=o;if(a?.path===e&&a?.code&&hr.has(a.code)&&n<r){n++;continue}throw o}};import{basename as $a,parse as Le,resolve as Fe}from"path";import{tmpdir as De}from"os";import{parse as Pe,resolve as cr}from"path";var{stat:Da}=F,La=i=>{try{return ir(i).isDirectory()}catch{return!1}},Fa=i=>Da(i).then(t=>t.isDirectory(),()=>!1),Ma=async i=>{let{root:t}=Pe(i),e=De(),{root:s}=Pe(e);if(t.toLowerCase()===s.toLowerCase())return e;let r=cr(t,"/temp");return await Fa(r)?r:t},Ia=i=>{let{root:t}=Pe(i),e=De(),{root:s}=Pe(e);if(t.toLowerCase()===s.toLowerCase())return e;let r=cr(t,"/temp");return La(r)?r:t},Ua=async()=>De(),ja=()=>De(),lr=q==="win32"?Ma:Ua,fr=q==="win32"?Ia:ja;var{lstat:Wa,rename:Ba,unlink:ur,rmdir:za,chmod:Ga}=F,mr=i=>`.${$a(i)}.${Math.random()}`,Ha=async i=>ur(i).catch(t=>{if(t.code==="EPERM")return Ga(i,438).then(()=>ur(i),e=>{if(e.code!=="ENOENT")throw t});if(t.code==="ENOENT")return;throw t}),qa=i=>{try{_t(i)}catch(t){if(t?.code==="EPERM")try{return _e(i,438)}catch(e){if(e?.code==="ENOENT")return;throw t}else if(t?.code==="ENOENT")return;throw t}},Me=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return await gs(i,t,await Wa(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},gs=async(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;if(!t.tmp)return gs(i,{...t,tmp:await lr(i)},e);if(i===t.tmp&&Le(i).root!==i)throw new Error("cannot delete temp directory used for deletion");let s=e.isDirectory()?await kt(i):null;if(!Array.isArray(s)){if(s){if(s.code==="ENOENT")return!0;if(s.code!=="ENOTDIR")throw s}return t.filter&&!await t.filter(i,e)?!1:(await tt(dr(i,t.tmp,Ha)),!0)}return!(await Promise.all(s.map(n=>gs(Fe(i,n.name),t,n)))).reduce((n,o)=>n&&o,!0)||t.preserveRoot===!1&&i===Le(i).root||t.filter&&!await t.filter(i,e)?!1:(await tt(dr(i,t.tmp,za)),!0)},dr=async(i,t,e)=>{let s=Fe(t,mr(i));return await Ba(i,s),await e(s)},Ie=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return ws(i,t,Ct(i))}catch(e){if(e?.code==="ENOENT")return!0;throw e}},ws=(i,t,e)=>{if(t?.signal?.aborted)throw t.signal.reason;if(!t.tmp)return ws(i,{...t,tmp:fr(i)},e);let s=t.tmp;if(i===t.tmp&&Le(i).root!==i)throw new Error("cannot delete temp directory used for deletion");let r=e.isDirectory()?Nt(i):null;if(!Array.isArray(r)){if(r){if(r.code==="ENOENT")return!0;if(r.code!=="ENOTDIR")throw r}return t.filter&&!t.filter(i,e)?!1:(et(()=>pr(i,s,qa)),!0)}let n=!0;for(let o of r){let a=Fe(i,o.name);n=ws(a,t,o)&&n}return!n||t.preserveRoot===!1&&i===Le(i).root||t.filter&&!t.filter(i,e)?!1:(et(()=>pr(i,s,At)),!0)},pr=(i,t,e)=>{let s=Fe(t,mr(i));return er(i,s),e(s)};var{unlink:Va,rmdir:Ka,lstat:Ya}=F,Ja=ps(us(Va)),Xa=ms(ds(_t)),Za=ps(us(Ka)),Qa=ms(ds(At)),th=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;let{filter:e,...s}=t;try{return await Za(i,s)}catch(r){if(r?.code==="ENOTEMPTY")return await Me(i,s);throw r}},eh=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;let{filter:e,...s}=t;try{return Qa(i,s)}catch(r){if(r?.code==="ENOTEMPTY")return Ie(i,s);throw r}},ht=Symbol("start"),yr=Symbol("child"),Ue=Symbol("finish"),je=async(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return await ys(i,t,await Ya(i),ht)}catch(e){if(e?.code==="ENOENT")return!0;throw e}},$e=(i,t)=>{if(t?.signal?.aborted)throw t.signal.reason;try{return Ss(i,t,Ct(i),ht)}catch(e){if(e?.code==="ENOENT")return!0;throw e}},ys=async(i,t,e,s=ht)=>{if(t?.signal?.aborted)throw t.signal.reason;let r=e.isDirectory()?await kt(i):null;if(!Array.isArray(r)){if(r){if(r.code==="ENOENT")return!0;if(r.code!=="ENOTDIR")throw r}return t.filter&&!await t.filter(i,e)?!1:(await tt(Ja(i,t)),!0)}let n=s===ht?yr:s,o=(await Promise.all(r.map(a=>ys(wr(i,a.name),t,a,n)))).reduce((a,h)=>a&&h,!0);if(s===ht)return ys(i,t,e,Ue);if(s===Ue){if(t.preserveRoot===!1&&i===gr(i).root||!o||t.filter&&!await t.filter(i,e))return!1;await tt(th(i,t))}return!0},Ss=(i,t,e,s=ht)=>{let r=e.isDirectory()?Nt(i):null;if(!Array.isArray(r)){if(r){if(r.code==="ENOENT")return!0;if(r.code!=="ENOTDIR")throw r}return t.filter&&!t.filter(i,e)?!1:(et(()=>Xa(i,t)),!0)}let n=!0;for(let o of r){let a=s===ht?yr:s,h=wr(i,o.name);n=Ss(h,t,o,a)&&n}if(s===ht)return Ss(i,t,e,Ue);if(s===Ue){if(t.preserveRoot===!1&&i===gr(i).root||!n||t.filter&&!t.filter(i,e))return!1;et(()=>{eh(i,t)})}return!0};var bs=q==="win32"?je:ke,Es=q==="win32"?$e:Ne;var{rm:sh}=F,xs=async(i,t)=>(await sh(i,{...t,force:!0,recursive:!0}),!0),vs=(i,t)=>(sr(i,{...t,force:!0,recursive:!0}),!0);var ih=process.env.__TESTING_RIMRAF_NODE_VERSION__||process.version,rh=ih.replace(/^v/,"").split("."),[Sr=0,nh=0]=rh.map(i=>parseInt(i,10)),br=Sr>14||Sr===14&&nh>=14,Er=!br||q==="win32"?()=>!1:i=>!i?.signal&&!i?.filter,xr=!br||q==="win32"?()=>!1:i=>!i?.signal&&!i?.filter;var Pt=i=>async(t,e)=>{let s=Xi(e);return s.glob&&(t=await Re(t,s.glob)),Array.isArray(t)?!!(await Promise.all(t.map(r=>i(ne(r,s),s)))).reduce((r,n)=>r&&n,!0):!!await i(ne(t,s),s)},Dt=i=>(t,e)=>{let s=Zi(e);return s.glob&&(t=Ae(t,s.glob)),Array.isArray(t)?!!t.map(r=>i(ne(r,s),s)).reduce((r,n)=>r&&n,!0):!!i(ne(t,s),s)},Rr=Dt(vs),oh=Object.assign(Pt(xs),{sync:Rr}),Or=Dt(Es),ah=Object.assign(Pt(bs),{sync:Or}),Ar=Dt($e),hh=Object.assign(Pt(je),{sync:Ar}),Cr=Dt(Ne),ch=Object.assign(Pt(ke),{sync:Cr}),_r=Dt(Ie),lh=Object.assign(Pt(Me),{sync:_r}),Ts=Dt((i,t)=>xr(t)?vs(i,t):Es(i,t)),kr=Ts,vr=Pt((i,t)=>Er(t)?xs(i,t):bs(i,t)),Tr=Object.assign(vr,{rimraf:vr,sync:Ts,rimrafSync:Ts,manual:ah,manualSync:Or,native:oh,nativeSync:Rr,posix:ch,posixSync:Cr,windows:hh,windowsSync:Ar,moveRemove:lh,moveRemoveSync:_r});Tr.rimraf=Tr;var Pr=uh(new URL(".",import.meta.url)),Os=Nr(Pr,"../builder/vite-config.js"),dh=Nr(Pr,"../builder/vite-entry-server.js");async function Dr({options:i,logger:t}){t.info(`Building template...
|
|
38
|
-
`),i.clean&&kr(fh.join(process.cwd(),"dist"));let e="production";i.ssr==="local"&&(e="development",process.env.NODE_ENV=e),i.ssr?(await Rs({configFile:Os,customLogger:t,mode:e,logLevel:i.logLevel,clearScreen:i.clearScreen,build:{ssrManifest:!0,emptyOutDir:!0}}),await Rs({configFile:Os,customLogger:t,mode:e,logLevel:i.logLevel,clearScreen:i.clearScreen,ssr:{target:"webworker"},build:{ssr:dh}})):await Rs({configFile:Os,customLogger:t,logLevel:i.logLevel,clearScreen:i.clearScreen,build:{emptyOutDir:!0}})}Ut();pt();async function Lr({options:i,logger:t}){t.info("Logging out fom Enpage..."),M.clear(),t.info(`Done.
|
|
39
|
-
`),process.exit(0)}var As;Lt.name("enpage").option("-l, --logLevel <level>","[string] info | warn | error | silent | debug").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("--dry-run","[boolean] run command without making changes").hook("preAction",i=>{As=He(i.optsWithGlobals().logLevel,i.optsWithGlobals().clearScreen,!0),process.removeAllListeners("warning"),process.on("warning",t=>{t.name==="DeprecationWarning"&&t.message.includes("util.isArray")||As.warnOnce(`Warning: ${t.name} - ${t.message}`)})});Lt.command("build").description("Build template").option("--ssr [type]",`Enable server side rendering.
|
|
40
|
-
Pass --ssr to generate a SSR-enabled build.
|
|
41
|
-
Pass --ssr=local to generate a SSR-enabled build that can be tested locally.`,Boolean,!1).option("--no-clean","Don't clean directory before buidling").action(function(){Dr(We(this))});Lt.command("publish").description("Publish a template to Enpage").argument("[directory]","Directory to publish").option("--no-check","Don't check for required files").action(function(){Js(We(this))});Lt.command("login").description("Login to Enpage").action(function(){Xs(We(this))});Lt.command("logout").description("Logout from Enpage").action(function(){Lr(We(this))});Lt.parse();function We(i){return{options:i.optsWithGlobals(),args:i.args,logger:As}}
|
|
42
|
-
/*!
|
|
43
|
-
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
44
|
-
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
45
|
-
* Released under the MIT License.
|
|
46
|
-
*
|
|
47
|
-
* Converted to typescript by Matthias E. <matthias@upstart.gg>
|
|
48
|
-
*/
|
|
49
|
-
//# sourceMappingURL=program.js.map
|