@sebbo2002/semantic-release-jsr 3.2.1 → 3.2.2-develop.10
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -35
- package/dist/{index.d.ts → index.d.mts} +39 -35
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -16
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@semantic-release/error`);c=s(c,1);let l=require(`jsr`),u=require(`node:fs`),d=require(`node:fs/promises`),f=require(`node:os`),p=require(`node:path`);async function m(e,t){let n=e.cwd||t?.cwd||process.cwd(),r=e.pkgJsonPath||(0,p.join)(n,`package.json`);!e.pkgJsonPath&&!(0,u.existsSync)(r)&&(r=null);let i,a=[],o=(0,p.join)(n,`jsr.json`),s=(0,p.join)(n,`deno.json`);(0,u.existsSync)(o)&&a.push(o),(0,u.existsSync)(s)&&a.push(s),r&&a.push(r);for(let e of a){let t=await(0,d.readFile)(e,`utf8`),n=JSON.parse(t);!i&&n.name&&(i=n.name)}if(!i)throw new c.default(`No name found in jsr.json or deno.json`,`ERR_NO_NAME`,`A package name is required to publish to JSR.io`);let l=e.publishArgs?.slice(0)||[];return(e.allowDirty===void 0||e.allowDirty)&&!l.includes(`--allow-dirty`)&&l.push(`--allow-dirty`),{cwd:n,name:i,prepare:{versionJsonPaths:a},publish:{binFolder:_(),canary:!1,pkgJsonPath:r,publishArgs:l}}}let h;function g(e,t){let n=`https://jsr.io/${e.name}/versions`;return t.nextRelease&&(n=`https://jsr.io/${e.name}@${t.nextRelease.version}`),{name:`JSR.io`,url:n}}function _(){if(h)return h;let e=(0,u.mkdtempSync)((0,p.join)((0,f.tmpdir)(),`semantic-release-jsr-`));return h=e,e}async function v(e,t){t.logger.log(`Run jsr publish in ${e.cwd} with ${JSON.stringify(e.publish)}`);let n=Date.now();try{await(0,l.publish)(e.cwd,e.publish),t.logger.log(`jsr publish run successfully (took ${Date.now()-n} ms)`)}catch(e){throw t.logger.log(`jsr publish failed after ${Date.now()-n} ms:`),t.logger.error(e instanceof Error?e.stack:e),e}}async function y(){h&&=(await(0,d.rm)(h,{force:!0,recursive:!0}),void 0)}async function b(e,t){if(!t.nextRelease)return;t.logger.log(`Updating version in ${e}`);let n=t.nextRelease.version,r=await(0,d.readFile)(e,`utf8`);if(JSON.parse(r).version===n){t.logger.log(`Skipped, ${e} is already up to date`);return}let i=r.replace(/^([\s\S]*"version"\s*:\s*")([^"]+)("[\s\S]*$)/,`$1${n}$3`);if(JSON.parse(i).version!==n)throw new c.default(`Failed to replace version in ${e}`,`ERR_VERSION_REPLACE`,`The version in ${e} could not be updated to ${n}. Please check if the file is valid JSON and contains a "version" field.`);await(0,d.writeFile)(e,i,`utf8`),t.logger.log(`Wrote new version to ${e}`)}async function x(e,t){t.logger.log(`Removing temporary folder`),await y()}async function S(e,t){let n=await m(e,t);for(let e of n.prepare.versionJsonPaths)await b(e,t)}async function C(e,t){let n=await m(e,t);return await v(n,t),g(n,t)}async function w(e,t){t.logger.log(`Removing temporary folder`),await y()}async function T(e,t){let n=await m(e,t);t.logger.info(`Run jsr publish --dry-run to verify configuration`),await v({...n,publish:{...n.publish,publishArgs:[...n.publish.publishArgs,`--dry-run`]}},t)}exports.fail=x,exports.generatePublishResponse=g,exports.getTemporaryBinFolder=_,exports.jsrPublish=v,exports.parseConfig=m,exports.prepare=S,exports.publish=C,exports.removeTemporaryBinFolder=y,exports.success=w,exports.updateVersionJson=b,exports.verifyConditions=T;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/command.ts"],"sourcesContent":["export {\n fail,\n prepare,\n publish,\n success,\n verifyConditions,\n} from './command.ts';\n\nexport {\n type NormalizedPluginConfig,\n type PluginConfig,\n type PublishResponse,\n type PublishResponseContext,\n} from './types.ts';\n\nexport {\n generatePublishResponse,\n getTemporaryBinFolder,\n publish as jsrPublish,\n parseConfig,\n removeTemporaryBinFolder,\n updateVersionJson,\n} from './utils.ts';\n","import type {\n PrepareContext,\n PublishContext,\n VerifyConditionsContext,\n VerifyReleaseContext,\n} from 'semantic-release';\n\nimport SemanticReleaseError from '@semantic-release/error';\nimport { publish as jsrPublish } from 'jsr';\nimport { existsSync, mkdtempSync } from 'node:fs';\nimport { readFile, rm, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport type {\n NormalizedPluginConfig,\n PluginConfig,\n PublishResponse,\n PublishResponseContext,\n} from './types.ts';\n\nexport async function parseConfig(\n config: PluginConfig,\n context?: PrepareContext | PublishContext | VerifyConditionsContext,\n): Promise<NormalizedPluginConfig> {\n const cwd = config.cwd || context?.cwd || process.cwd();\n\n let pkgJsonPath: null | string =\n config.pkgJsonPath || join(cwd, 'package.json');\n if (!config.pkgJsonPath && !existsSync(pkgJsonPath)) {\n pkgJsonPath = null;\n }\n\n let name: string | undefined;\n const versionJsonPaths: string[] = [];\n const jsrJsonPath = join(cwd, 'jsr.json');\n const denoJsonPath = join(cwd, 'deno.json');\n if (existsSync(jsrJsonPath)) {\n versionJsonPaths.push(jsrJsonPath);\n }\n if (existsSync(denoJsonPath)) {\n versionJsonPaths.push(denoJsonPath);\n }\n if (pkgJsonPath) {\n versionJsonPaths.push(pkgJsonPath);\n }\n\n for (const path of versionJsonPaths) {\n const content = await readFile(path, 'utf8');\n const json = JSON.parse(content);\n if (!name && json.name) {\n name = json.name;\n }\n }\n if (!name) {\n throw new SemanticReleaseError(\n 'No name found in jsr.json or deno.json',\n 'ERR_NO_NAME',\n 'A package name is required to publish to JSR.io',\n );\n }\n\n const publishArgs = config.publishArgs?.slice(0) || [];\n if (\n (config.allowDirty === undefined || config.allowDirty) &&\n !publishArgs.includes('--allow-dirty')\n ) {\n publishArgs.push('--allow-dirty');\n }\n\n return {\n cwd,\n name,\n prepare: {\n versionJsonPaths,\n },\n publish: {\n binFolder: getTemporaryBinFolder(),\n canary: false,\n pkgJsonPath: pkgJsonPath,\n publishArgs,\n },\n };\n}\n\nlet temporaryBinFolder: string | undefined;\nexport function generatePublishResponse(\n config: NormalizedPluginConfig,\n context: PublishResponseContext,\n): PublishResponse {\n let url = `https://jsr.io/${config.name}/versions`;\n if (context.nextRelease) {\n url = `https://jsr.io/${config.name}@${context.nextRelease.version}`;\n }\n\n return {\n name: 'JSR.io',\n url,\n };\n}\n\nexport function getTemporaryBinFolder(): string {\n if (temporaryBinFolder) {\n return temporaryBinFolder;\n }\n\n const path = mkdtempSync(join(tmpdir(), 'semantic-release-jsr-'));\n temporaryBinFolder = path;\n return path;\n}\n\nexport async function publish(\n config: NormalizedPluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n context.logger.log(\n `Run jsr publish in ${config.cwd} with ${JSON.stringify(config.publish)}`,\n );\n\n const ms = Date.now();\n try {\n await jsrPublish(config.cwd, config.publish);\n context.logger.log(\n `jsr publish run successfully (took ${Date.now() - ms} ms)`,\n );\n } catch (error) {\n context.logger.log(`jsr publish failed after ${Date.now() - ms} ms:`);\n context.logger.error(error instanceof Error ? error.stack : error);\n throw error;\n }\n}\n\nexport async function removeTemporaryBinFolder() {\n if (temporaryBinFolder) {\n await rm(temporaryBinFolder, { force: true, recursive: true });\n temporaryBinFolder = undefined;\n }\n}\n\nexport async function updateVersionJson(\n file: string,\n context: VerifyReleaseContext,\n) {\n if (!context.nextRelease) {\n return;\n }\n\n context.logger.log(`Updating version in ${file}`);\n const nextVersion = context.nextRelease.version;\n const content = await readFile(file, 'utf8');\n const oldJson = JSON.parse(content);\n if (oldJson.version === nextVersion) {\n context.logger.log(`Skipped, ${file} is already up to date`);\n return;\n }\n\n const versionRegex = /^([\\s\\S]*\"version\"\\s*:\\s*\")([^\"]+)(\"[\\s\\S]*$)/;\n\n const updatedContent = content.replace(versionRegex, `$1${nextVersion}$3`);\n const newJson = JSON.parse(updatedContent);\n if (newJson.version !== nextVersion) {\n throw new SemanticReleaseError(\n `Failed to replace version in ${file}`,\n 'ERR_VERSION_REPLACE',\n `The version in ${file} could not be updated to ${nextVersion}. Please check if the file ` +\n `is valid JSON and contains a \"version\" field.`,\n );\n }\n\n await writeFile(file, updatedContent, 'utf8');\n context.logger.log(`Wrote new version to ${file}`);\n}\n","import type {\n FailContext,\n PrepareContext,\n PublishContext,\n SuccessContext,\n VerifyConditionsContext,\n} from 'semantic-release';\n\nimport type { PluginConfig, PublishResponse } from './types.ts';\n\nimport {\n generatePublishResponse,\n parseConfig,\n publish as publishUtil,\n removeTemporaryBinFolder,\n updateVersionJson,\n} from './utils.ts';\n\nexport async function fail(pluginConfig: PluginConfig, context: FailContext) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function prepare(\n pluginConfig: PluginConfig,\n context: PrepareContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n\n for (const file of config.prepare.versionJsonPaths) {\n await updateVersionJson(file, context);\n }\n}\n\nexport async function publish(\n pluginConfig: PluginConfig,\n context: PublishContext,\n): Promise<boolean | PublishResponse> {\n const config = await parseConfig(pluginConfig, context);\n await publishUtil(config, context);\n return generatePublishResponse(config, context);\n}\n\nexport async function success(\n pluginConfig: PluginConfig,\n context: SuccessContext,\n) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function verifyConditions(\n pluginConfig: PluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n context.logger.info('Run jsr publish --dry-run to verify configuration');\n\n await publishUtil(\n {\n ...config,\n publish: {\n ...config.publish,\n publishArgs: [...config.publish.publishArgs, '--dry-run'],\n },\n },\n context,\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,EAAA,4BAAAC,EAAA,0BAAAC,EAAA,eAAAC,EAAA,gBAAAC,EAAA,YAAAC,EAAA,YAAAF,EAAA,6BAAAG,EAAA,YAAAC,EAAA,sBAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAZ,GCOA,IAAAa,EAAiC,wCACjCC,EAAsC,eACtCC,EAAwC,cACxCC,EAAwC,uBACxCC,EAAuB,cACvBC,EAAqB,gBASrB,eAAsBC,EAClBC,EACAC,EAC+B,CAC/B,IAAMC,EAAMF,EAAO,KAAOC,GAAS,KAAO,QAAQ,IAAI,EAElDE,EACAH,EAAO,gBAAe,QAAKE,EAAK,cAAc,EAC9C,CAACF,EAAO,aAAe,IAAC,cAAWG,CAAW,IAC9CA,EAAc,MAGlB,IAAIC,EACEC,EAA6B,CAAC,EAC9BC,KAAc,QAAKJ,EAAK,UAAU,EAClCK,KAAe,QAAKL,EAAK,WAAW,KACtC,cAAWI,CAAW,GACtBD,EAAiB,KAAKC,CAAW,KAEjC,cAAWC,CAAY,GACvBF,EAAiB,KAAKE,CAAY,EAElCJ,GACAE,EAAiB,KAAKF,CAAW,EAGrC,QAAWK,KAAQH,EAAkB,CACjC,IAAMI,EAAU,QAAM,YAASD,EAAM,MAAM,EACrCE,EAAO,KAAK,MAAMD,CAAO,EAC3B,CAACL,GAAQM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EACAC,EACa,CACb,IAAMG,EAAS,MAAMC,EAAYL,EAAcC,CAAO,EACtDA,EAAQ,OAAO,KAAK,mDAAmD,EAEvE,MAAMO,EACF,CACI,GAAGJ,EACH,QAAS,CACL,GAAGA,EAAO,QACV,YAAa,CAAC,GAAGA,EAAO,QAAQ,YAAa,WAAW,CAC5D,CACJ,EACAH,CACJ,CACJ","names":["index_exports","__export","fail","generatePublishResponse","getTemporaryBinFolder","publish","parseConfig","prepare","removeTemporaryBinFolder","success","updateVersionJson","verifyConditions","__toCommonJS","import_error","import_jsr","import_node_fs","import_promises","import_node_os","import_node_path","parseConfig","config","context","cwd","pkgJsonPath","name","versionJsonPaths","jsrJsonPath","denoJsonPath","path","content","json","SemanticReleaseError","publishArgs","getTemporaryBinFolder","temporaryBinFolder","generatePublishResponse","url","publish","ms","jsrPublish","error","removeTemporaryBinFolder","updateVersionJson","file","nextVersion","versionRegex","updatedContent","fail","pluginConfig","context","removeTemporaryBinFolder","prepare","config","parseConfig","file","updateVersionJson","publish","generatePublishResponse","success","verifyConditions"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["SemanticReleaseError","publish","publishUtil"],"sources":["../src/utils.ts","../src/command.ts"],"sourcesContent":["import type {\n PrepareContext,\n PublishContext,\n VerifyConditionsContext,\n VerifyReleaseContext,\n} from 'semantic-release';\n\nimport SemanticReleaseError from '@semantic-release/error';\nimport { publish as jsrPublish } from 'jsr';\nimport { existsSync, mkdtempSync } from 'node:fs';\nimport { readFile, rm, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport type {\n NormalizedPluginConfig,\n PluginConfig,\n PublishResponse,\n PublishResponseContext,\n} from './types.ts';\n\nexport async function parseConfig(\n config: PluginConfig,\n context?: PrepareContext | PublishContext | VerifyConditionsContext,\n): Promise<NormalizedPluginConfig> {\n const cwd = config.cwd || context?.cwd || process.cwd();\n\n let pkgJsonPath: null | string =\n config.pkgJsonPath || join(cwd, 'package.json');\n if (!config.pkgJsonPath && !existsSync(pkgJsonPath)) {\n pkgJsonPath = null;\n }\n\n let name: string | undefined;\n const versionJsonPaths: string[] = [];\n const jsrJsonPath = join(cwd, 'jsr.json');\n const denoJsonPath = join(cwd, 'deno.json');\n if (existsSync(jsrJsonPath)) {\n versionJsonPaths.push(jsrJsonPath);\n }\n if (existsSync(denoJsonPath)) {\n versionJsonPaths.push(denoJsonPath);\n }\n if (pkgJsonPath) {\n versionJsonPaths.push(pkgJsonPath);\n }\n\n for (const path of versionJsonPaths) {\n const content = await readFile(path, 'utf8');\n const json = JSON.parse(content);\n if (!name && json.name) {\n name = json.name;\n }\n }\n if (!name) {\n throw new SemanticReleaseError(\n 'No name found in jsr.json or deno.json',\n 'ERR_NO_NAME',\n 'A package name is required to publish to JSR.io',\n );\n }\n\n const publishArgs = config.publishArgs?.slice(0) || [];\n if (\n (config.allowDirty === undefined || config.allowDirty) &&\n !publishArgs.includes('--allow-dirty')\n ) {\n publishArgs.push('--allow-dirty');\n }\n\n return {\n cwd,\n name,\n prepare: {\n versionJsonPaths,\n },\n publish: {\n binFolder: getTemporaryBinFolder(),\n canary: false,\n pkgJsonPath: pkgJsonPath,\n publishArgs,\n },\n };\n}\n\nlet temporaryBinFolder: string | undefined;\nexport function generatePublishResponse(\n config: NormalizedPluginConfig,\n context: PublishResponseContext,\n): PublishResponse {\n let url = `https://jsr.io/${config.name}/versions`;\n if (context.nextRelease) {\n url = `https://jsr.io/${config.name}@${context.nextRelease.version}`;\n }\n\n return {\n name: 'JSR.io',\n url,\n };\n}\n\nexport function getTemporaryBinFolder(): string {\n if (temporaryBinFolder) {\n return temporaryBinFolder;\n }\n\n const path = mkdtempSync(join(tmpdir(), 'semantic-release-jsr-'));\n temporaryBinFolder = path;\n return path;\n}\n\nexport async function publish(\n config: NormalizedPluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n context.logger.log(\n `Run jsr publish in ${config.cwd} with ${JSON.stringify(config.publish)}`,\n );\n\n const ms = Date.now();\n try {\n await jsrPublish(config.cwd, config.publish);\n context.logger.log(\n `jsr publish run successfully (took ${Date.now() - ms} ms)`,\n );\n } catch (error) {\n context.logger.log(`jsr publish failed after ${Date.now() - ms} ms:`);\n context.logger.error(error instanceof Error ? error.stack : error);\n throw error;\n }\n}\n\nexport async function removeTemporaryBinFolder() {\n if (temporaryBinFolder) {\n await rm(temporaryBinFolder, { force: true, recursive: true });\n temporaryBinFolder = undefined;\n }\n}\n\nexport async function updateVersionJson(\n file: string,\n context: VerifyReleaseContext,\n) {\n if (!context.nextRelease) {\n return;\n }\n\n context.logger.log(`Updating version in ${file}`);\n const nextVersion = context.nextRelease.version;\n const content = await readFile(file, 'utf8');\n const oldJson = JSON.parse(content);\n if (oldJson.version === nextVersion) {\n context.logger.log(`Skipped, ${file} is already up to date`);\n return;\n }\n\n const versionRegex = /^([\\s\\S]*\"version\"\\s*:\\s*\")([^\"]+)(\"[\\s\\S]*$)/;\n\n const updatedContent = content.replace(versionRegex, `$1${nextVersion}$3`);\n const newJson = JSON.parse(updatedContent);\n if (newJson.version !== nextVersion) {\n throw new SemanticReleaseError(\n `Failed to replace version in ${file}`,\n 'ERR_VERSION_REPLACE',\n `The version in ${file} could not be updated to ${nextVersion}. Please check if the file ` +\n `is valid JSON and contains a \"version\" field.`,\n );\n }\n\n await writeFile(file, updatedContent, 'utf8');\n context.logger.log(`Wrote new version to ${file}`);\n}\n","import type {\n FailContext,\n PrepareContext,\n PublishContext,\n SuccessContext,\n VerifyConditionsContext,\n} from 'semantic-release';\n\nimport type { PluginConfig, PublishResponse } from './types.ts';\n\nimport {\n generatePublishResponse,\n parseConfig,\n publish as publishUtil,\n removeTemporaryBinFolder,\n updateVersionJson,\n} from './utils.ts';\n\nexport async function fail(pluginConfig: PluginConfig, context: FailContext) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function prepare(\n pluginConfig: PluginConfig,\n context: PrepareContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n\n for (const file of config.prepare.versionJsonPaths) {\n await updateVersionJson(file, context);\n }\n}\n\nexport async function publish(\n pluginConfig: PluginConfig,\n context: PublishContext,\n): Promise<boolean | PublishResponse> {\n const config = await parseConfig(pluginConfig, context);\n await publishUtil(config, context);\n return generatePublishResponse(config, context);\n}\n\nexport async function success(\n pluginConfig: PluginConfig,\n context: SuccessContext,\n) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function verifyConditions(\n pluginConfig: PluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n context.logger.info('Run jsr publish --dry-run to verify configuration');\n\n await publishUtil(\n {\n ...config,\n publish: {\n ...config.publish,\n publishArgs: [...config.publish.publishArgs, '--dry-run'],\n },\n },\n context,\n );\n}\n"],"mappings":"usBAqBA,eAAsB,EAClB,EACA,EAC+B,CAC/B,IAAM,EAAM,EAAO,KAAO,GAAS,KAAO,QAAQ,KAAK,CAEnD,EACA,EAAO,cAAA,EAAA,EAAA,MAAoB,EAAK,eAAe,CAC/C,CAAC,EAAO,aAAe,EAAA,EAAA,EAAA,YAAY,EAAY,GAC/C,EAAc,MAGlB,IAAI,EACE,EAA6B,EAAE,CAC/B,GAAA,EAAA,EAAA,MAAmB,EAAK,WAAW,CACnC,GAAA,EAAA,EAAA,MAAoB,EAAK,YAAY,EAC3C,EAAA,EAAA,YAAe,EAAY,EACvB,EAAiB,KAAK,EAAY,EAEtC,EAAA,EAAA,YAAe,EAAa,EACxB,EAAiB,KAAK,EAAa,CAEnC,GACA,EAAiB,KAAK,EAAY,CAGtC,IAAK,IAAM,KAAQ,EAAkB,CACjC,IAAM,EAAU,MAAA,EAAA,EAAA,UAAe,EAAM,OAAO,CACtC,EAAO,KAAK,MAAM,EAAQ,CAC5B,CAAC,GAAQ,EAAK,OACd,EAAO,EAAK,MAGpB,GAAI,CAAC,EACD,MAAM,IAAIA,EAAAA,QACN,yCACA,cACA,kDACH,C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
|
|
2
|
-
import { PublishOptions } from
|
|
1
|
+
import { FailContext, NextRelease, PrepareContext, PublishContext, SuccessContext, VerifyConditionsContext, VerifyReleaseContext } from "semantic-release";
|
|
2
|
+
import { PublishOptions } from "jsr";
|
|
3
3
|
|
|
4
|
+
//#region src/types.d.ts
|
|
4
5
|
interface NormalizedPluginConfig {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
cwd: string;
|
|
7
|
+
name: string;
|
|
8
|
+
prepare: {
|
|
9
|
+
versionJsonPaths: string[];
|
|
10
|
+
};
|
|
11
|
+
publish: PublishOptions;
|
|
11
12
|
}
|
|
12
13
|
interface PluginConfig {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Allow `--allow-dirty` to be passed to `jsr publish`.
|
|
16
|
+
* Defaults to `true`, as usually the version is bumped before publishing.
|
|
17
|
+
* Set to `false` to prevent `--allow-dirty` from being passed.
|
|
18
|
+
*/
|
|
19
|
+
allowDirty?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Working directory given to `jsr publish`.
|
|
22
|
+
* Defaults to current directory.
|
|
23
|
+
*/
|
|
24
|
+
cwd?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Path to package.json.
|
|
27
|
+
* Defaults to `cwd` + `/package.json` if it exists.
|
|
28
|
+
*/
|
|
29
|
+
pkgJsonPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Additional arguments to pass to `jsr publish`.
|
|
32
|
+
*/
|
|
33
|
+
publishArgs?: string[];
|
|
33
34
|
}
|
|
34
35
|
interface PublishResponse {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
channel?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
url?: string;
|
|
38
39
|
}
|
|
39
40
|
interface PublishResponseContext {
|
|
40
|
-
|
|
41
|
+
nextRelease?: NextRelease;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/command.d.ts
|
|
43
45
|
declare function fail(pluginConfig: PluginConfig, context: FailContext): Promise<void>;
|
|
44
46
|
declare function prepare(pluginConfig: PluginConfig, context: PrepareContext): Promise<void>;
|
|
45
47
|
declare function publish$1(pluginConfig: PluginConfig, context: PublishContext): Promise<boolean | PublishResponse>;
|
|
46
48
|
declare function success(pluginConfig: PluginConfig, context: SuccessContext): Promise<void>;
|
|
47
49
|
declare function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void>;
|
|
48
|
-
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/utils.d.ts
|
|
49
52
|
declare function parseConfig(config: PluginConfig, context?: PrepareContext | PublishContext | VerifyConditionsContext): Promise<NormalizedPluginConfig>;
|
|
50
53
|
declare function generatePublishResponse(config: NormalizedPluginConfig, context: PublishResponseContext): PublishResponse;
|
|
51
54
|
declare function getTemporaryBinFolder(): string;
|
|
52
55
|
declare function publish(config: NormalizedPluginConfig, context: VerifyConditionsContext): Promise<void>;
|
|
53
56
|
declare function removeTemporaryBinFolder(): Promise<void>;
|
|
54
57
|
declare function updateVersionJson(file: string, context: VerifyReleaseContext): Promise<void>;
|
|
55
|
-
|
|
58
|
+
//#endregion
|
|
56
59
|
export { type NormalizedPluginConfig, type PluginConfig, type PublishResponse, type PublishResponseContext, fail, generatePublishResponse, getTemporaryBinFolder, publish as jsrPublish, parseConfig, prepare, publish$1 as publish, removeTemporaryBinFolder, success, updateVersionJson, verifyConditions };
|
|
60
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,56 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PublishOptions } from "jsr";
|
|
2
|
+
import { FailContext, NextRelease, PrepareContext, PublishContext, SuccessContext, VerifyConditionsContext, VerifyReleaseContext } from "semantic-release";
|
|
3
3
|
|
|
4
|
+
//#region src/types.d.ts
|
|
4
5
|
interface NormalizedPluginConfig {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
cwd: string;
|
|
7
|
+
name: string;
|
|
8
|
+
prepare: {
|
|
9
|
+
versionJsonPaths: string[];
|
|
10
|
+
};
|
|
11
|
+
publish: PublishOptions;
|
|
11
12
|
}
|
|
12
13
|
interface PluginConfig {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Allow `--allow-dirty` to be passed to `jsr publish`.
|
|
16
|
+
* Defaults to `true`, as usually the version is bumped before publishing.
|
|
17
|
+
* Set to `false` to prevent `--allow-dirty` from being passed.
|
|
18
|
+
*/
|
|
19
|
+
allowDirty?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Working directory given to `jsr publish`.
|
|
22
|
+
* Defaults to current directory.
|
|
23
|
+
*/
|
|
24
|
+
cwd?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Path to package.json.
|
|
27
|
+
* Defaults to `cwd` + `/package.json` if it exists.
|
|
28
|
+
*/
|
|
29
|
+
pkgJsonPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Additional arguments to pass to `jsr publish`.
|
|
32
|
+
*/
|
|
33
|
+
publishArgs?: string[];
|
|
33
34
|
}
|
|
34
35
|
interface PublishResponse {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
channel?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
url?: string;
|
|
38
39
|
}
|
|
39
40
|
interface PublishResponseContext {
|
|
40
|
-
|
|
41
|
+
nextRelease?: NextRelease;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/command.d.ts
|
|
43
45
|
declare function fail(pluginConfig: PluginConfig, context: FailContext): Promise<void>;
|
|
44
46
|
declare function prepare(pluginConfig: PluginConfig, context: PrepareContext): Promise<void>;
|
|
45
47
|
declare function publish$1(pluginConfig: PluginConfig, context: PublishContext): Promise<boolean | PublishResponse>;
|
|
46
48
|
declare function success(pluginConfig: PluginConfig, context: SuccessContext): Promise<void>;
|
|
47
49
|
declare function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void>;
|
|
48
|
-
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/utils.d.ts
|
|
49
52
|
declare function parseConfig(config: PluginConfig, context?: PrepareContext | PublishContext | VerifyConditionsContext): Promise<NormalizedPluginConfig>;
|
|
50
53
|
declare function generatePublishResponse(config: NormalizedPluginConfig, context: PublishResponseContext): PublishResponse;
|
|
51
54
|
declare function getTemporaryBinFolder(): string;
|
|
52
55
|
declare function publish(config: NormalizedPluginConfig, context: VerifyConditionsContext): Promise<void>;
|
|
53
56
|
declare function removeTemporaryBinFolder(): Promise<void>;
|
|
54
57
|
declare function updateVersionJson(file: string, context: VerifyReleaseContext): Promise<void>;
|
|
55
|
-
|
|
58
|
+
//#endregion
|
|
56
59
|
export { type NormalizedPluginConfig, type PluginConfig, type PublishResponse, type PublishResponseContext, fail, generatePublishResponse, getTemporaryBinFolder, publish as jsrPublish, parseConfig, prepare, publish$1 as publish, removeTemporaryBinFolder, success, updateVersionJson, verifyConditions };
|
|
60
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"@semantic-release/error";import{publish as t}from"jsr";import{existsSync as n,mkdtempSync as r}from"node:fs";import{readFile as i,rm as a,writeFile as o}from"node:fs/promises";import{tmpdir as s}from"node:os";import{join as c}from"node:path";async function l(t,r){let a=t.cwd||r?.cwd||process.cwd(),o=t.pkgJsonPath||c(a,`package.json`);!t.pkgJsonPath&&!n(o)&&(o=null);let s,l=[],u=c(a,`jsr.json`),d=c(a,`deno.json`);n(u)&&l.push(u),n(d)&&l.push(d),o&&l.push(o);for(let e of l){let t=await i(e,`utf8`),n=JSON.parse(t);!s&&n.name&&(s=n.name)}if(!s)throw new e(`No name found in jsr.json or deno.json`,`ERR_NO_NAME`,`A package name is required to publish to JSR.io`);let p=t.publishArgs?.slice(0)||[];return(t.allowDirty===void 0||t.allowDirty)&&!p.includes(`--allow-dirty`)&&p.push(`--allow-dirty`),{cwd:a,name:s,prepare:{versionJsonPaths:l},publish:{binFolder:f(),canary:!1,pkgJsonPath:o,publishArgs:p}}}let u;function d(e,t){let n=`https://jsr.io/${e.name}/versions`;return t.nextRelease&&(n=`https://jsr.io/${e.name}@${t.nextRelease.version}`),{name:`JSR.io`,url:n}}function f(){if(u)return u;let e=r(c(s(),`semantic-release-jsr-`));return u=e,e}async function p(e,n){n.logger.log(`Run jsr publish in ${e.cwd} with ${JSON.stringify(e.publish)}`);let r=Date.now();try{await t(e.cwd,e.publish),n.logger.log(`jsr publish run successfully (took ${Date.now()-r} ms)`)}catch(e){throw n.logger.log(`jsr publish failed after ${Date.now()-r} ms:`),n.logger.error(e instanceof Error?e.stack:e),e}}async function m(){u&&=(await a(u,{force:!0,recursive:!0}),void 0)}async function h(t,n){if(!n.nextRelease)return;n.logger.log(`Updating version in ${t}`);let r=n.nextRelease.version,a=await i(t,`utf8`);if(JSON.parse(a).version===r){n.logger.log(`Skipped, ${t} is already up to date`);return}let s=a.replace(/^([\s\S]*"version"\s*:\s*")([^"]+)("[\s\S]*$)/,`$1${r}$3`);if(JSON.parse(s).version!==r)throw new e(`Failed to replace version in ${t}`,`ERR_VERSION_REPLACE`,`The version in ${t} could not be updated to ${r}. Please check if the file is valid JSON and contains a "version" field.`);await o(t,s,`utf8`),n.logger.log(`Wrote new version to ${t}`)}async function g(e,t){t.logger.log(`Removing temporary folder`),await m()}async function _(e,t){let n=await l(e,t);for(let e of n.prepare.versionJsonPaths)await h(e,t)}async function v(e,t){let n=await l(e,t);return await p(n,t),d(n,t)}async function y(e,t){t.logger.log(`Removing temporary folder`),await m()}async function b(e,t){let n=await l(e,t);t.logger.info(`Run jsr publish --dry-run to verify configuration`),await p({...n,publish:{...n.publish,publishArgs:[...n.publish.publishArgs,`--dry-run`]}},t)}export{g as fail,d as generatePublishResponse,f as getTemporaryBinFolder,p as jsrPublish,l as parseConfig,_ as prepare,v as publish,m as removeTemporaryBinFolder,y as success,h as updateVersionJson,b as verifyConditions};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["jsrPublish","publish","publishUtil"],"sources":["../src/utils.ts","../src/command.ts"],"sourcesContent":["import type {\n PrepareContext,\n PublishContext,\n VerifyConditionsContext,\n VerifyReleaseContext,\n} from 'semantic-release';\n\nimport SemanticReleaseError from '@semantic-release/error';\nimport { publish as jsrPublish } from 'jsr';\nimport { existsSync, mkdtempSync } from 'node:fs';\nimport { readFile, rm, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport type {\n NormalizedPluginConfig,\n PluginConfig,\n PublishResponse,\n PublishResponseContext,\n} from './types.ts';\n\nexport async function parseConfig(\n config: PluginConfig,\n context?: PrepareContext | PublishContext | VerifyConditionsContext,\n): Promise<NormalizedPluginConfig> {\n const cwd = config.cwd || context?.cwd || process.cwd();\n\n let pkgJsonPath: null | string =\n config.pkgJsonPath || join(cwd, 'package.json');\n if (!config.pkgJsonPath && !existsSync(pkgJsonPath)) {\n pkgJsonPath = null;\n }\n\n let name: string | undefined;\n const versionJsonPaths: string[] = [];\n const jsrJsonPath = join(cwd, 'jsr.json');\n const denoJsonPath = join(cwd, 'deno.json');\n if (existsSync(jsrJsonPath)) {\n versionJsonPaths.push(jsrJsonPath);\n }\n if (existsSync(denoJsonPath)) {\n versionJsonPaths.push(denoJsonPath);\n }\n if (pkgJsonPath) {\n versionJsonPaths.push(pkgJsonPath);\n }\n\n for (const path of versionJsonPaths) {\n const content = await readFile(path, 'utf8');\n const json = JSON.parse(content);\n if (!name && json.name) {\n name = json.name;\n }\n }\n if (!name) {\n throw new SemanticReleaseError(\n 'No name found in jsr.json or deno.json',\n 'ERR_NO_NAME',\n 'A package name is required to publish to JSR.io',\n );\n }\n\n const publishArgs = config.publishArgs?.slice(0) || [];\n if (\n (config.allowDirty === undefined || config.allowDirty) &&\n !publishArgs.includes('--allow-dirty')\n ) {\n publishArgs.push('--allow-dirty');\n }\n\n return {\n cwd,\n name,\n prepare: {\n versionJsonPaths,\n },\n publish: {\n binFolder: getTemporaryBinFolder(),\n canary: false,\n pkgJsonPath: pkgJsonPath,\n publishArgs,\n },\n };\n}\n\nlet temporaryBinFolder: string | undefined;\nexport function generatePublishResponse(\n config: NormalizedPluginConfig,\n context: PublishResponseContext,\n): PublishResponse {\n let url = `https://jsr.io/${config.name}/versions`;\n if (context.nextRelease) {\n url = `https://jsr.io/${config.name}@${context.nextRelease.version}`;\n }\n\n return {\n name: 'JSR.io',\n url,\n };\n}\n\nexport function getTemporaryBinFolder(): string {\n if (temporaryBinFolder) {\n return temporaryBinFolder;\n }\n\n const path = mkdtempSync(join(tmpdir(), 'semantic-release-jsr-'));\n temporaryBinFolder = path;\n return path;\n}\n\nexport async function publish(\n config: NormalizedPluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n context.logger.log(\n `Run jsr publish in ${config.cwd} with ${JSON.stringify(config.publish)}`,\n );\n\n const ms = Date.now();\n try {\n await jsrPublish(config.cwd, config.publish);\n context.logger.log(\n `jsr publish run successfully (took ${Date.now() - ms} ms)`,\n );\n } catch (error) {\n context.logger.log(`jsr publish failed after ${Date.now() - ms} ms:`);\n context.logger.error(error instanceof Error ? error.stack : error);\n throw error;\n }\n}\n\nexport async function removeTemporaryBinFolder() {\n if (temporaryBinFolder) {\n await rm(temporaryBinFolder, { force: true, recursive: true });\n temporaryBinFolder = undefined;\n }\n}\n\nexport async function updateVersionJson(\n file: string,\n context: VerifyReleaseContext,\n) {\n if (!context.nextRelease) {\n return;\n }\n\n context.logger.log(`Updating version in ${file}`);\n const nextVersion = context.nextRelease.version;\n const content = await readFile(file, 'utf8');\n const oldJson = JSON.parse(content);\n if (oldJson.version === nextVersion) {\n context.logger.log(`Skipped, ${file} is already up to date`);\n return;\n }\n\n const versionRegex = /^([\\s\\S]*\"version\"\\s*:\\s*\")([^\"]+)(\"[\\s\\S]*$)/;\n\n const updatedContent = content.replace(versionRegex, `$1${nextVersion}$3`);\n const newJson = JSON.parse(updatedContent);\n if (newJson.version !== nextVersion) {\n throw new SemanticReleaseError(\n `Failed to replace version in ${file}`,\n 'ERR_VERSION_REPLACE',\n `The version in ${file} could not be updated to ${nextVersion}. Please check if the file ` +\n `is valid JSON and contains a \"version\" field.`,\n );\n }\n\n await writeFile(file, updatedContent, 'utf8');\n context.logger.log(`Wrote new version to ${file}`);\n}\n","import type {\n FailContext,\n PrepareContext,\n PublishContext,\n SuccessContext,\n VerifyConditionsContext,\n} from 'semantic-release';\n\nimport type { PluginConfig, PublishResponse } from './types.ts';\n\nimport {\n generatePublishResponse,\n parseConfig,\n publish as publishUtil,\n removeTemporaryBinFolder,\n updateVersionJson,\n} from './utils.ts';\n\nexport async function fail(pluginConfig: PluginConfig, context: FailContext) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function prepare(\n pluginConfig: PluginConfig,\n context: PrepareContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n\n for (const file of config.prepare.versionJsonPaths) {\n await updateVersionJson(file, context);\n }\n}\n\nexport async function publish(\n pluginConfig: PluginConfig,\n context: PublishContext,\n): Promise<boolean | PublishResponse> {\n const config = await parseConfig(pluginConfig, context);\n await publishUtil(config, context);\n return generatePublishResponse(config, context);\n}\n\nexport async function success(\n pluginConfig: PluginConfig,\n context: SuccessContext,\n) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function verifyConditions(\n pluginConfig: PluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n context.logger.info('Run jsr publish --dry-run to verify configuration');\n\n await publishUtil(\n {\n ...config,\n publish: {\n ...config.publish,\n publishArgs: [...config.publish.publishArgs, '--dry-run'],\n },\n },\n context,\n );\n}\n"],"mappings":"gQAqBA,eAAsB,EAClB,EACA,EAC+B,CAC/B,IAAM,EAAM,EAAO,KAAO,GAAS,KAAO,QAAQ,KAAK,CAEnD,EACA,EAAO,aAAe,EAAK,EAAK,eAAe,CAC/C,CAAC,EAAO,aAAe,CAAC,EAAW,EAAY,GAC/C,EAAc,MAGlB,IAAI,EACE,EAA6B,EAAE,CAC/B,EAAc,EAAK,EAAK,WAAW,CACnC,EAAe,EAAK,EAAK,YAAY,CACvC,EAAW,EAAY,EACvB,EAAiB,KAAK,EAAY,CAElC,EAAW,EAAa,EACxB,EAAiB,KAAK,EAAa,CAEnC,GACA,EAAiB,KAAK,EAAY,CAGtC,IAAK,IAAM,KAAQ,EAAkB,CACjC,IAAM,EAAU,MAAM,EAAS,EAAM,OAAO,CACtC,EAAO,KAAK,MAAM,EAAQ,CAC5B,CAAC,GAAQ,EAAK,OACd,EAAO,EAAK,MAGpB,GAAI,CAAC,EACD,MAAM,IAAI,EACN,yCACA,cACA,kDACH,CAGL,IAAM,EAAc,EAAO,aAAa,MAAM,EAAE,EAAI,EAAE,CAQtD,OANK,EAAO,aAAe,IAAA,IAAa,EAAO,aAC3C,CAAC,EAAY,SAAS,gBAAgB,EAEtC,EAAY,KAAK,g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EgC,KAAK,EAAY,IAAI,CAE1E,GADgB,KAAK,MAAM,EAAe,CAC9B,UAAY,EACpB,MAAM,IAAI,EACN,gCAAgC,IAChC,sBACA,kBAAkB,EAAK,2BAA2B,EAAY,0EAEjE,CAGL,MAAM,EAAU,EAAM,EAAgB,OAAO,CAC7C,EAAQ,OAAO,IAAI,wBAAwB,IAAO,CCxJtD,eAAsB,EAAK,EAA4B,EAAsB,CACzE,EAAQ,OAAO,IAAI,4BAA4B,CAC/C,MAAM,GAA0B,CAGpC,eAAsB,EAClB,EACA,EACa,CACb,IAAM,EAAS,MAAM,EAAY,EAAc,EAAQ,CAEvD,IAAK,IAAM,KAAQ,EAAO,QAAQ,iBAC9B,MAAM,EAAkB,EAAM,EAAQ,CAI9C,eAAsBC,EAClB,EACA,EACkC,CAClC,IAAM,EAAS,MAAM,EAAY,EAAc,EAAQ,CAEvD,OADA,MAAMC,EAAY,EAAQ,EAAQ,CAC3B,EAAwB,EAAQ,EAAQ,CAGnD,eAAsB,EAClB,EACA,EACF,CACE,EAAQ,OAAO,IAAI,4BAA4B,CAC/C,MAAM,GAA0B,CAGpC,eAAsB,EAClB,EACA,EACa,CACb,IAAM,EAAS,MAAM,EAAY,EAAc,EAAQ,CACvD,EAAQ,OAAO,KAAK,oDAAoD,CAExE,MAAMA,EACF,CACI,GAAG,EACH,QAAS,CACL,GAAG,EAAO,QACV,YAAa,CAAC,GAAG,EAAO,QAAQ,YAAa,YAAY,CAC5D,CACJ,CACD,EACH"}
|
package/package.json
CHANGED
|
@@ -13,37 +13,37 @@
|
|
|
13
13
|
"@semantic-release/changelog": "^6.0.3",
|
|
14
14
|
"@semantic-release/exec": "^7.1.0",
|
|
15
15
|
"@semantic-release/git": "^10.0.1",
|
|
16
|
-
"@semantic-release/npm": "^13.1.
|
|
16
|
+
"@semantic-release/npm": "^13.1.5",
|
|
17
17
|
"@types/mocha": "^10.0.10",
|
|
18
|
-
"@types/node": "^25.
|
|
18
|
+
"@types/node": "^25.6.0",
|
|
19
19
|
"@types/semantic-release__error": "^3.0.3",
|
|
20
20
|
"@types/signale": "^1.4.7",
|
|
21
|
-
"c8": "^
|
|
22
|
-
"eslint": "^10.
|
|
21
|
+
"c8": "^11.0.0",
|
|
22
|
+
"eslint": "^10.2.0",
|
|
23
23
|
"eslint-config-prettier": "^10.1.8",
|
|
24
|
-
"eslint-plugin-jsonc": "^
|
|
25
|
-
"eslint-plugin-perfectionist": "^5.
|
|
24
|
+
"eslint-plugin-jsonc": "^3.1.2",
|
|
25
|
+
"eslint-plugin-perfectionist": "^5.8.0",
|
|
26
26
|
"esm": "^3.2.25",
|
|
27
|
-
"globals": "^17.
|
|
27
|
+
"globals": "^17.5.0",
|
|
28
28
|
"husky": "^9.1.7",
|
|
29
29
|
"license-checker": "^25.0.1",
|
|
30
30
|
"mocha": "^11.7.5",
|
|
31
31
|
"mochawesome": "^7.1.4",
|
|
32
|
-
"prettier": "^3.8.
|
|
32
|
+
"prettier": "^3.8.3",
|
|
33
33
|
"semantic-release": "^25.0.3",
|
|
34
34
|
"semantic-release-license": "^1.0.3",
|
|
35
35
|
"source-map-support": "^0.5.21",
|
|
36
|
-
"
|
|
36
|
+
"tsdown": "^0.21.9",
|
|
37
37
|
"tsx": "^4.21.0",
|
|
38
|
-
"typedoc": "^0.28.
|
|
39
|
-
"typescript": "^
|
|
40
|
-
"typescript-eslint": "^8.
|
|
38
|
+
"typedoc": "^0.28.19",
|
|
39
|
+
"typescript": "^6.0.3",
|
|
40
|
+
"typescript-eslint": "^8.58.2"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": "20 || >=22.0.0"
|
|
44
44
|
},
|
|
45
45
|
"exports": {
|
|
46
|
-
"import": "./dist/index.
|
|
46
|
+
"import": "./dist/index.mjs",
|
|
47
47
|
"require": "./dist/index.cjs"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"homepage": "https://github.com/sebbo2002/semantic-release-jsr#readme",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"main": "./dist/index.cjs",
|
|
55
|
-
"module": "./dist/index.
|
|
55
|
+
"module": "./dist/index.mjs",
|
|
56
56
|
"name": "@sebbo2002/semantic-release-jsr",
|
|
57
57
|
"repository": {
|
|
58
58
|
"type": "git",
|
|
59
59
|
"url": "git+https://github.com/sebbo2002/semantic-release-jsr.git"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
|
-
"build": "
|
|
62
|
+
"build": "tsdown",
|
|
63
63
|
"build-all": "./.github/workflows/build.sh",
|
|
64
64
|
"coverage": "c8 mocha",
|
|
65
65
|
"license-check": "license-checker --production --summary",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"test": "mocha"
|
|
68
68
|
},
|
|
69
69
|
"type": "module",
|
|
70
|
-
"version": "3.2.
|
|
70
|
+
"version": "3.2.2-develop.10"
|
|
71
71
|
}
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import b from"@semantic-release/error";import{publish as J}from"jsr";import{existsSync as d,mkdtempSync as j}from"fs";import{readFile as w,rm as N,writeFile as $}from"fs/promises";import{tmpdir as S}from"os";import{join as p}from"path";async function l(e,o){let n=e.cwd||o?.cwd||process.cwd(),i=e.pkgJsonPath||p(n,"package.json");!e.pkgJsonPath&&!d(i)&&(i=null);let t,s=[],a=p(n,"jsr.json"),f=p(n,"deno.json");d(a)&&s.push(a),d(f)&&s.push(f),i&&s.push(i);for(let R of s){let v=await w(R,"utf8"),C=JSON.parse(v);!t&&C.name&&(t=C.name)}if(!t)throw new b("No name found in jsr.json or deno.json","ERR_NO_NAME","A package name is required to publish to JSR.io");let m=e.publishArgs?.slice(0)||[];return(e.allowDirty===void 0||e.allowDirty)&&!m.includes("--allow-dirty")&&m.push("--allow-dirty"),{cwd:n,name:t,prepare:{versionJsonPaths:s},publish:{binFolder:x(),canary:!1,pkgJsonPath:i,publishArgs:m}}}var r;function P(e,o){let n=`https://jsr.io/${e.name}/versions`;return o.nextRelease&&(n=`https://jsr.io/${e.name}@${o.nextRelease.version}`),{name:"JSR.io",url:n}}function x(){if(r)return r;let e=j(p(S(),"semantic-release-jsr-"));return r=e,e}async function u(e,o){o.logger.log(`Run jsr publish in ${e.cwd} with ${JSON.stringify(e.publish)}`);let n=Date.now();try{await J(e.cwd,e.publish),o.logger.log(`jsr publish run successfully (took ${Date.now()-n} ms)`)}catch(i){throw o.logger.log(`jsr publish failed after ${Date.now()-n} ms:`),o.logger.error(i instanceof Error?i.stack:i),i}}async function g(){r&&(await N(r,{force:!0,recursive:!0}),r=void 0)}async function y(e,o){if(!o.nextRelease)return;o.logger.log(`Updating version in ${e}`);let n=o.nextRelease.version,i=await w(e,"utf8");if(JSON.parse(i).version===n){o.logger.log(`Skipped, ${e} is already up to date`);return}let s=/^([\s\S]*"version"\s*:\s*")([^"]+)("[\s\S]*$)/,a=i.replace(s,`$1${n}$3`);if(JSON.parse(a).version!==n)throw new b(`Failed to replace version in ${e}`,"ERR_VERSION_REPLACE",`The version in ${e} could not be updated to ${n}. Please check if the file is valid JSON and contains a "version" field.`);await $(e,a,"utf8"),o.logger.log(`Wrote new version to ${e}`)}async function k(e,o){o.logger.log("Removing temporary folder"),await g()}async function F(e,o){let n=await l(e,o);for(let i of n.prepare.versionJsonPaths)await y(i,o)}async function V(e,o){let n=await l(e,o);return await u(n,o),P(n,o)}async function O(e,o){o.logger.log("Removing temporary folder"),await g()}async function A(e,o){let n=await l(e,o);o.logger.info("Run jsr publish --dry-run to verify configuration"),await u({...n,publish:{...n.publish,publishArgs:[...n.publish.publishArgs,"--dry-run"]}},o)}export{k as fail,P as generatePublishResponse,x as getTemporaryBinFolder,u as jsrPublish,l as parseConfig,F as prepare,V as publish,g as removeTemporaryBinFolder,O as success,y as updateVersionJson,A as verifyConditions};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.ts","../src/command.ts"],"sourcesContent":["import type {\n PrepareContext,\n PublishContext,\n VerifyConditionsContext,\n VerifyReleaseContext,\n} from 'semantic-release';\n\nimport SemanticReleaseError from '@semantic-release/error';\nimport { publish as jsrPublish } from 'jsr';\nimport { existsSync, mkdtempSync } from 'node:fs';\nimport { readFile, rm, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport type {\n NormalizedPluginConfig,\n PluginConfig,\n PublishResponse,\n PublishResponseContext,\n} from './types.ts';\n\nexport async function parseConfig(\n config: PluginConfig,\n context?: PrepareContext | PublishContext | VerifyConditionsContext,\n): Promise<NormalizedPluginConfig> {\n const cwd = config.cwd || context?.cwd || process.cwd();\n\n let pkgJsonPath: null | string =\n config.pkgJsonPath || join(cwd, 'package.json');\n if (!config.pkgJsonPath && !existsSync(pkgJsonPath)) {\n pkgJsonPath = null;\n }\n\n let name: string | undefined;\n const versionJsonPaths: string[] = [];\n const jsrJsonPath = join(cwd, 'jsr.json');\n const denoJsonPath = join(cwd, 'deno.json');\n if (existsSync(jsrJsonPath)) {\n versionJsonPaths.push(jsrJsonPath);\n }\n if (existsSync(denoJsonPath)) {\n versionJsonPaths.push(denoJsonPath);\n }\n if (pkgJsonPath) {\n versionJsonPaths.push(pkgJsonPath);\n }\n\n for (const path of versionJsonPaths) {\n const content = await readFile(path, 'utf8');\n const json = JSON.parse(content);\n if (!name && json.name) {\n name = json.name;\n }\n }\n if (!name) {\n throw new SemanticReleaseError(\n 'No name found in jsr.json or deno.json',\n 'ERR_NO_NAME',\n 'A package name is required to publish to JSR.io',\n );\n }\n\n const publishArgs = config.publishArgs?.slice(0) || [];\n if (\n (config.allowDirty === undefined || config.allowDirty) &&\n !publishArgs.includes('--allow-dirty')\n ) {\n publishArgs.push('--allow-dirty');\n }\n\n return {\n cwd,\n name,\n prepare: {\n versionJsonPaths,\n },\n publish: {\n binFolder: getTemporaryBinFolder(),\n canary: false,\n pkgJsonPath: pkgJsonPath,\n publishArgs,\n },\n };\n}\n\nlet temporaryBinFolder: string | undefined;\nexport function generatePublishResponse(\n config: NormalizedPluginConfig,\n context: PublishResponseContext,\n): PublishResponse {\n let url = `https://jsr.io/${config.name}/versions`;\n if (context.nextRelease) {\n url = `https://jsr.io/${config.name}@${context.nextRelease.version}`;\n }\n\n return {\n name: 'JSR.io',\n url,\n };\n}\n\nexport function getTemporaryBinFolder(): string {\n if (temporaryBinFolder) {\n return temporaryBinFolder;\n }\n\n const path = mkdtempSync(join(tmpdir(), 'semantic-release-jsr-'));\n temporaryBinFolder = path;\n return path;\n}\n\nexport async function publish(\n config: NormalizedPluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n context.logger.log(\n `Run jsr publish in ${config.cwd} with ${JSON.stringify(config.publish)}`,\n );\n\n const ms = Date.now();\n try {\n await jsrPublish(config.cwd, config.publish);\n context.logger.log(\n `jsr publish run successfully (took ${Date.now() - ms} ms)`,\n );\n } catch (error) {\n context.logger.log(`jsr publish failed after ${Date.now() - ms} ms:`);\n context.logger.error(error instanceof Error ? error.stack : error);\n throw error;\n }\n}\n\nexport async function removeTemporaryBinFolder() {\n if (temporaryBinFolder) {\n await rm(temporaryBinFolder, { force: true, recursive: true });\n temporaryBinFolder = undefined;\n }\n}\n\nexport async function updateVersionJson(\n file: string,\n context: VerifyReleaseContext,\n) {\n if (!context.nextRelease) {\n return;\n }\n\n context.logger.log(`Updating version in ${file}`);\n const nextVersion = context.nextRelease.version;\n const content = await readFile(file, 'utf8');\n const oldJson = JSON.parse(content);\n if (oldJson.version === nextVersion) {\n context.logger.log(`Skipped, ${file} is already up to date`);\n return;\n }\n\n const versionRegex = /^([\\s\\S]*\"version\"\\s*:\\s*\")([^\"]+)(\"[\\s\\S]*$)/;\n\n const updatedContent = content.replace(versionRegex, `$1${nextVersion}$3`);\n const newJson = JSON.parse(updatedContent);\n if (newJson.version !== nextVersion) {\n throw new SemanticReleaseError(\n `Failed to replace version in ${file}`,\n 'ERR_VERSION_REPLACE',\n `The version in ${file} could not be updated to ${nextVersion}. Please check if the file ` +\n `is valid JSON and contains a \"version\" field.`,\n );\n }\n\n await writeFile(file, updatedContent, 'utf8');\n context.logger.log(`Wrote new version to ${file}`);\n}\n","import type {\n FailContext,\n PrepareContext,\n PublishContext,\n SuccessContext,\n VerifyConditionsContext,\n} from 'semantic-release';\n\nimport type { PluginConfig, PublishResponse } from './types.ts';\n\nimport {\n generatePublishResponse,\n parseConfig,\n publish as publishUtil,\n removeTemporaryBinFolder,\n updateVersionJson,\n} from './utils.ts';\n\nexport async function fail(pluginConfig: PluginConfig, context: FailContext) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function prepare(\n pluginConfig: PluginConfig,\n context: PrepareContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n\n for (const file of config.prepare.versionJsonPaths) {\n await updateVersionJson(file, context);\n }\n}\n\nexport async function publish(\n pluginConfig: PluginConfig,\n context: PublishContext,\n): Promise<boolean | PublishResponse> {\n const config = await parseConfig(pluginConfig, context);\n await publishUtil(config, context);\n return generatePublishResponse(config, context);\n}\n\nexport async function success(\n pluginConfig: PluginConfig,\n context: SuccessContext,\n) {\n context.logger.log('Removing temporary folder');\n await removeTemporaryBinFolder();\n}\n\nexport async function verifyConditions(\n pluginConfig: PluginConfig,\n context: VerifyConditionsContext,\n): Promise<void> {\n const config = await parseConfig(pluginConfig, context);\n context.logger.info('Run jsr publish --dry-run to verify configuration');\n\n await publishUtil(\n {\n ...config,\n publish: {\n ...config.publish,\n publishArgs: [...config.publish.publishArgs, '--dry-run'],\n },\n },\n context,\n );\n}\n"],"mappings":"AAOA,OAAOA,MAA0B,0BACjC,OAAS,WAAWC,MAAkB,MACtC,OAAS,cAAAC,EAAY,eAAAC,MAAmB,KACxC,OAAS,YAAAC,EAAU,MAAAC,EAAI,aAAAC,MAAiB,cACxC,OAAS,UAAAC,MAAc,KACvB,OAAS,QAAAC,MAAY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AAwBoB,CAAI,EAAE,CACrD,CCzJA,eAAsBI,EAAKC,EAA4BC,EAAsB,CACzEA,EAAQ,OAAO,IAAI,2BAA2B,EAC9C,MAAMC,EAAyB,CACnC,CAEA,eAAsBC,EAClBH,EACAC,EACa,CACb,IAAMG,EAAS,MAAMC,EAAYL,EAAcC,CAAO,EAEtD,QAAWK,KAAQF,EAAO,QAAQ,iBAC9B,MAAMG,EAAkBD,EAAML,CAAO,CAE7C,CAEA,eAAsBO,EAClBR,EACAC,EACkC,CAClC,IAAMG,EAAS,MAAMC,EAAYL,EAAcC,CAAO,EACtD,aAAMO,EAAYJ,EAAQH,CAAO,EAC1BQ,EAAwBL,EAAQH,CAAO,CAClD,CAEA,eAAsBS,EAClBV,EACAC,EACF,CACEA,EAAQ,OAAO,IAAI,2BAA2B,EAC9C,MAAMC,EAAyB,CACnC,CAEA,eAAsBS,EAClBX,EACAC,EACa,CACb,IAAMG,EAAS,MAAMC,EAAYL,EAAcC,CAAO,EACtDA,EAAQ,OAAO,KAAK,mDAAmD,EAEvE,MAAMO,EACF,CACI,GAAGJ,EACH,QAAS,CACL,GAAGA,EAAO,QACV,YAAa,CAAC,GAAGA,EAAO,QAAQ,YAAa,WAAW,CAC5D,CACJ,EACAH,CACJ,CACJ","names":["SemanticReleaseError","jsrPublish","existsSync","mkdtempSync","readFile","rm","writeFile","tmpdir","join","parseConfig","config","context","cwd","pkgJsonPath","name","versionJsonPaths","jsrJsonPath","denoJsonPath","path","content","json","publishArgs","getTemporaryBinFolder","temporaryBinFolder","generatePublishResponse","url","publish","ms","error","removeTemporaryBinFolder","updateVersionJson","file","nextVersion","versionRegex","updatedContent","fail","pluginConfig","context","removeTemporaryBinFolder","prepare","config","parseConfig","file","updateVersionJson","publish","generatePublishResponse","success","verifyConditions"]}
|