@@ -48,9 +48,6 @@ const distCoreTarget = `${dist}/${coreLibDir}`;
4848const distCorePackageJsonPath = `${ distCoreTarget } /package.json` ;
4949const distExtensionsAngularTarget = `${ extensionsAngularLibDir } /${ dist } ` ;
5050
51- // The source package.json of every publishable package, keyed by the name used on
52- // the command line. Versions are read from these files at the point of use, never
53- // cached at module load, because a dev publish rewrites them before building.
5451const sourcePackageJsonPaths = {
5552 core : `${ coreLibDir } /package.json` ,
5653 designsystem : `${ designsystemLibDir } /package.json` ,
@@ -70,9 +67,6 @@ function readSourcePackageJson(packageName) {
7067 return fs . readJsonSync ( sourcePackageJsonPaths [ packageName ] ) ;
7168}
7269
73- // The publish closure of a package: the package itself plus everything it depends
74- // on, in publish order. A consumer installing a dev build needs the whole closure,
75- // because the peer dependency ranges are pinned to exact dev versions.
7670function resolvePublishClosure ( packageName ) {
7771 const chain = publishChains . find ( ( candidate ) => candidate . includes ( packageName ) ) ;
7872 return chain . slice ( 0 , chain . indexOf ( packageName ) + 1 ) ;
@@ -117,9 +111,6 @@ function buildPackage(project) {
117111 } ) ;
118112}
119113
120- // designsystem declares `"@kirbydesign/core": "*"` in source; the range that actually
121- // ships is decided here. A release pins a caret range, a dev publish pins the exact
122- // dev version so the closure installs as a consistent set.
123114function writeCoreVersionToPackageJson ( distPackageJsonPath ) {
124115 const { version : coreVersion } = readSourcePackageJson ( 'core' ) ;
125116 const range = isDevPublish ? coreVersion : `^${ coreVersion } ` ;
@@ -134,9 +125,6 @@ function writeCoreVersionToPackageJson(distPackageJsonPath) {
134125 } ) ;
135126}
136127
137- // Dev publishes only. extensions-angular ships a static `^11.8.0` range for releases,
138- // which cannot resolve to a dev designsystem because prereleases never satisfy a caret
139- // range. Pin it to the exact dev version instead.
140128function writeDesignsystemVersionToPackageJson ( distPackageJsonPath ) {
141129 const { version : designsystemVersion } = readSourcePackageJson ( 'designsystem' ) ;
142130
@@ -236,8 +224,7 @@ function createTarballPackage(distTarget) {
236224}
237225
238226// Official SemVer 2.0.0 grammar, from the "suggested regular expression" section of
239- // https://semver.org. Used instead of the `semver` package, which is not a declared
240- // dependency of this repo.
227+ // https://semver.org.
241228const semVerPattern =
242229 / ^ ( 0 | [ 1 - 9 ] \d * ) \. ( 0 | [ 1 - 9 ] \d * ) \. ( 0 | [ 1 - 9 ] \d * ) (?: - ( (?: 0 | [ 1 - 9 ] \d * | \d * [ a - z A - Z - ] [ 0 - 9 a - z A - Z - ] * ) (?: \. (?: 0 | [ 1 - 9 ] \d * | \d * [ a - z A - Z - ] [ 0 - 9 a - z A - Z - ] * ) ) * ) ) ? (?: \+ ( [ 0 - 9 a - z A - Z - ] + (?: \. [ 0 - 9 a - z A - Z - ] + ) * ) ) ? $ / ;
243230
@@ -249,10 +236,6 @@ function shortCommitSha() {
249236 return result . stdout . trim ( ) ;
250237}
251238
252- // A dev version is the package's current version with the commit appended as a
253- // prerelease identifier, e.g. 11.11.0-dev-abc1234. The `dev-` infix is load-bearing:
254- // a bare numeric SHA such as 0123456 is a leading-zero numeric identifier and would
255- // not be valid SemVer.
256239function toDevVersion ( version , shortSha ) {
257240 const devVersion = `${ version } -dev-${ shortSha } ` ;
258241 if ( ! semVerPattern . test ( devVersion ) ) {
@@ -261,11 +244,6 @@ function toDevVersion(version, shortSha) {
261244 return devVersion ;
262245}
263246
264- // Rewrites the version of every package in the closure, in the source package.json,
265- // before anything is built. ng-packagr reads the version from source at build time and
266- // stylelint-plugin is published straight from its source directory, so this is the only
267- // point that reaches all four packaging styles. The edits are never committed; a dev
268- // publish is refused outside CI, where the checkout is throwaway.
269247function applyDevVersions ( packageNames , shortSha ) {
270248 return packageNames . map ( ( packageName ) => {
271249 const packageJsonPath = sourcePackageJsonPaths [ packageName ] ;
@@ -280,9 +258,6 @@ function applyDevVersions(packageNames, shortSha) {
280258 } ) ;
281259}
282260
283- // Resolves as true only when the registry positively reports the version. A network
284- // failure resolves as false, so we attempt the publish and let it fail loudly rather
285- // than silently skipping a package that was never published.
286261function isAlreadyPublished ( packageSpec ) {
287262 return new Promise ( ( resolve ) => {
288263 const child = cp . spawn ( / ^ w i n / . test ( process . platform ) ? 'npm.cmd' : 'npm' , [
@@ -308,8 +283,6 @@ async function publish(distTarget, tarballNamePrefix) {
308283
309284 const { name, version } = fs . readJsonSync ( `${ distTarget } /package.json` ) ;
310285
311- // Re-running a dev publish for the same commit must converge rather than abort on
312- // the first package that already exists, so a partially completed run can be retried.
313286 if ( isDevPublish && ( await isAlreadyPublished ( `${ name } @${ version } ` ) ) ) {
314287 console . log ( `${ name } @${ version } is already published, skipping.` ) ;
315288 return ;
0 commit comments