@opencrvs/create-countryconfig 2.1.0-beta → 2.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +21 -27
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -96,27 +96,29 @@ function getLatestCommonReleaseTag() {
96
96
  }
97
97
 
98
98
  /**
99
- * A prerelease-shaped own version (e.g. "2.1.0-rc.f5ea803", what npm resolves
100
- * `@next` to - a build published from every push to a branch) never has a
101
- * matching release tag, so it's resolved as a branch instead. Its base
102
- * version (stripped of the "-rc.<sha>" suffix) tells apart two different
103
- * situations: an RC for a version already being stabilized on its own
104
- * "release/X.Y.Z" branch (e.g. "2.0.1-rc.*" while a patch release is in
105
- * progress) versus an RC for a version that hasn't been branched off yet and
106
- * only exists on develop (e.g. "2.1.0-rc.*" while that release branch hasn't
107
- * been cut). Scaffold from the release branch when it exists in both
108
- * repositories, otherwise fall back to develop.
99
+ * Resolves the ref that both repositories are cloned from. A single ref
100
+ * clones both, so every candidate must exist in *both* - a tag present in
101
+ * only one of them can't be used.
109
102
  *
110
- * Otherwise, the own "X.Y.Z" version - whether resolved via npm's `latest`
111
- * dist-tag (bare invocation) or an explicit `@X.Y.Z` pin - scaffolds from the
112
- * matching "vX.Y.Z" tag when it exists in both repositories. If it doesn't
113
- * (e.g. `latest` lagging behind the repos, or a pin that predates one repo's
114
- * tagging), fall back to the highest release tag common to both, rather than
115
- * a mismatched pairing of one tagged repo at that version and another repo
116
- * at a different release. Exits with an error if no matching release tag
117
- * exists in both repositories.
103
+ * The exact "v<version>" tag wins whenever it exists: it pins a commit, so
104
+ * a release, an explicit `@X.Y.Z` pin, or a blessed prerelease (npm `@beta`,
105
+ * published from that tag) reproduces however late it's scaffolded.
106
+ *
107
+ * Otherwise a prerelease falls back to a branch, since a rolling release
108
+ * candidate (npm `@next`) is never tagged: "release/X.Y.Z" of the base
109
+ * version when that release has been cut, otherwise develop. A release
110
+ * falls back to the highest tag common to both repositories - never a
111
+ * mismatched pairing of the two at different releases - or errors.
118
112
  */
119
113
  function resolveRef() {
114
+ const versionTag = 'v' + version
115
+ if (
116
+ tagExists(CORE_REPO_URL, versionTag) &&
117
+ tagExists(INFRASTRUCTURE_REPO_URL, versionTag)
118
+ ) {
119
+ return versionTag
120
+ }
121
+
120
122
  if (version.includes('-')) {
121
123
  const releaseBranch = 'release/' + version.split('-')[0]
122
124
  if (
@@ -128,19 +130,11 @@ function resolveRef() {
128
130
  return 'develop'
129
131
  }
130
132
 
131
- const tag = 'v' + version
132
- if (
133
- tagExists(CORE_REPO_URL, tag) &&
134
- tagExists(INFRASTRUCTURE_REPO_URL, tag)
135
- ) {
136
- return tag
137
- }
138
-
139
133
  const latestCommonTag = getLatestCommonReleaseTag()
140
134
  if (latestCommonTag) {
141
135
  console.warn(
142
136
  '\nWarning: tag "' +
143
- tag +
137
+ versionTag +
144
138
  '" was not found in both repositories; falling back to the latest ' +
145
139
  'available release, ' +
146
140
  latestCommonTag +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/create-countryconfig",
3
- "version": "2.1.0-beta",
3
+ "version": "2.1.0-beta.2",
4
4
  "description": "Scaffold a new OpenCRVS country configuration",
5
5
  "bin": {
6
6
  "create-countryconfig": "./index.js"