launchset 1.2.0 → 1.3.0

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.
@@ -1,5 +1,5 @@
1
1
  import { n as LaunchsetError, t as EXPECTED_ERROR } from "./errors-CHdD4g_K.js";
2
- import { A as isPlainVersion, H as BUMPS, N as marketingVersion, U as escapeRegExp, V as versionParts, _ as ciProfile, b as isForgeHost, c as hostConfigIssues, d as CI_SYSTEMS, f as DEFAULT_HOST, h as ciFromEnv, k as highestVersion, l as resolveConfig, m as HOSTS, o as defineConfig, p as FORGE_HOSTS, r as DOCKER_TAG_PLACEHOLDERS, t as ConfigError, v as ciSystemFor, w as baseVersionOf, y as hostProfile } from "./schema-CKljQNeI.js";
2
+ import { E as baseVersionOf, F as marketingVersion, G as escapeRegExp, M as isPlainVersion, S as isForgeHost, U as versionParts, W as BUMPS, _ as ciFromEnv, b as ciSystemFor, c as hostConfigIssues, f as versionFileFormat, g as HOSTS, h as FORGE_HOSTS, j as highestVersion, l as resolveConfig, m as DEFAULT_HOST, o as defineConfig, p as CI_SYSTEMS, r as DOCKER_TAG_PLACEHOLDERS, t as ConfigError, u as rootVersionHint, x as hostProfile, y as ciProfile } from "./schema-WH9ljSlL.js";
3
3
  import semver, { parse as parse$1 } from "semver";
4
4
  import { existsSync, readFileSync } from "node:fs";
5
5
  import { readFile, readdir, stat, writeFile } from "node:fs/promises";
@@ -2414,6 +2414,9 @@ async function collectSourceFiles(target, root) {
2414
2414
  case "expo":
2415
2415
  await needFile(`${base}.file`, "expo", source.file);
2416
2416
  break;
2417
+ case "flutter":
2418
+ await needFile(`${base}.dir`, "pubspec", join(source.dir, "pubspec.yaml"));
2419
+ break;
2417
2420
  case "capacitor": {
2418
2421
  const groovy = join(source.dir, "android/app/build.gradle");
2419
2422
  const kts = join(source.dir, "android/app/build.gradle.kts");
@@ -2446,7 +2449,10 @@ async function collectSourceFiles(target, root) {
2446
2449
  case "xcconfig":
2447
2450
  await needFile(`${base}.file`, "xcconfig", source.file);
2448
2451
  break;
2449
- case "expo": await needFile(`${base}.file`, "expo", source.file);
2452
+ case "expo":
2453
+ await needFile(`${base}.file`, "expo", source.file);
2454
+ break;
2455
+ case "flutter": await needFile(`${base}.dir`, "pubspec", join(source.dir, "pubspec.yaml"));
2450
2456
  }
2451
2457
  }
2452
2458
  return {
@@ -2661,7 +2667,7 @@ function assertUniquePath(tree, path, file) {
2661
2667
  node = props[0]?.children?.[1];
2662
2668
  }
2663
2669
  }
2664
- function locate$5(text, file, key) {
2670
+ function locate$4(text, file, key) {
2665
2671
  const tree = parseJsonTree(text, file);
2666
2672
  const path = dottedPath(key);
2667
2673
  assertUniquePath(tree, path, file);
@@ -2672,7 +2678,7 @@ function locate$5(text, file, key) {
2672
2678
  }
2673
2679
  const jsonValue = {
2674
2680
  read(text, file, options) {
2675
- const loc = locate$5(text, file, options.key);
2681
+ const loc = locate$4(text, file, options.key);
2676
2682
  return [{
2677
2683
  field: "marketing",
2678
2684
  key: options.key,
@@ -2682,7 +2688,7 @@ const jsonValue = {
2682
2688
  },
2683
2689
  write(text, file, values, options) {
2684
2690
  if (values.marketing === void 0) return text;
2685
- const { node } = locate$5(text, file, options.key);
2691
+ const { node } = locate$4(text, file, options.key);
2686
2692
  return applySplices(text, [{
2687
2693
  start: node.offset,
2688
2694
  end: node.offset + node.length,
@@ -3202,12 +3208,12 @@ function scanEntries(original) {
3202
3208
  }
3203
3209
  /** Like `locate`, but `undefined` when the key is missing. */
3204
3210
  function locateOptional(text, file, key) {
3205
- return hasKey(text, key) ? locate$4(text, file, key) : void 0;
3211
+ return hasKey(text, key) ? locate$3(text, file, key) : void 0;
3206
3212
  }
3207
3213
  function hasKey(text, key) {
3208
3214
  return scanEntries(text).some((e) => e.key === key);
3209
3215
  }
3210
- function locate$4(text, file, key) {
3216
+ function locate$3(text, file, key) {
3211
3217
  const hits = scanEntries(text).filter((e) => e.key === key);
3212
3218
  if (hits.length === 0) throw new StampError(file, `key ${key} not found; add a line like \`${key}=…\` or fix the key name in the config`);
3213
3219
  if (hits.length > 1) throw new StampError(file, `key ${key} is defined more than once (lines ${hits.map((h) => lineOf(text, h.start)).join(" and ")}); launchset can't tell which one wins`);
@@ -3217,7 +3223,7 @@ function locate$4(text, file, key) {
3217
3223
  }
3218
3224
  const gradleProperties = {
3219
3225
  read(text, file, options) {
3220
- const name = locate$4(text, file, options.versionNameKey);
3226
+ const name = locate$3(text, file, options.versionNameKey);
3221
3227
  const code = locateOptional(text, file, options.versionCodeKey);
3222
3228
  const found = (field, key, e) => ({
3223
3229
  field,
@@ -3230,7 +3236,7 @@ const gradleProperties = {
3230
3236
  write(text, file, values, options) {
3231
3237
  const splices = [];
3232
3238
  if (values.marketing !== void 0) {
3233
- const e = locate$4(text, file, options.versionNameKey);
3239
+ const e = locate$3(text, file, options.versionNameKey);
3234
3240
  if (/[\r\n\\]/.test(values.marketing)) throw new StampError(file, `can't write "${values.marketing}" as ${options.versionNameKey}`);
3235
3241
  splices.push({
3236
3242
  start: e.start,
@@ -3239,7 +3245,7 @@ const gradleProperties = {
3239
3245
  });
3240
3246
  }
3241
3247
  if (values.build !== void 0) {
3242
- const e = locate$4(text, file, options.versionCodeKey);
3248
+ const e = locate$3(text, file, options.versionCodeKey);
3243
3249
  if (!Number.isSafeInteger(values.build) || values.build < 1) throw new StampError(file, `can't write ${values.build} as ${options.versionCodeKey}: not a positive integer`);
3244
3250
  splices.push({
3245
3251
  start: e.start,
@@ -3360,7 +3366,7 @@ const LOCATIONS = [{
3360
3366
  "version"
3361
3367
  ]
3362
3368
  }];
3363
- function locate$3(text, file) {
3369
+ function locate$2(text, file) {
3364
3370
  const tree = parseJsonTree(text, file);
3365
3371
  if (tree.type !== "object") throw new StampError(file, `expected a JSON object at the top level, found ${tree.type}`);
3366
3372
  const found = [];
@@ -3381,7 +3387,7 @@ function locate$3(text, file) {
3381
3387
  }
3382
3388
  const npmLockfile = {
3383
3389
  read(text, file) {
3384
- return locate$3(text, file).map((f) => ({
3390
+ return locate$2(text, file).map((f) => ({
3385
3391
  field: "marketing",
3386
3392
  key: f.key,
3387
3393
  value: f.value,
@@ -3391,7 +3397,7 @@ const npmLockfile = {
3391
3397
  write(text, file, values) {
3392
3398
  if (values.marketing === void 0) return text;
3393
3399
  const literal = jsonLiteral(values.marketing, "string");
3394
- return applySplices(text, locate$3(text, file).map((f) => ({
3400
+ return applySplices(text, locate$2(text, file).map((f) => ({
3395
3401
  start: f.offset,
3396
3402
  end: f.offset + f.length,
3397
3403
  text: literal
@@ -3684,6 +3690,25 @@ function inheritsVersionSettings(target, model) {
3684
3690
  if (target.productType !== void 0 && TEST_PRODUCT_TYPES.has(target.productType)) return false;
3685
3691
  return target.configs.some((c) => model.projectConfigs.some((p) => p.name === c.name && configSetsAnything(p)));
3686
3692
  }
3693
+ /**
3694
+ * The version settings each configuration of target `name` builds with: its own value, else
3695
+ * the project-level configuration of the same name's. `undefined` where neither sets it, and
3696
+ * `[]` when there is no such target (used by `init`).
3697
+ */
3698
+ function effectiveVersionSettings(text, file, name) {
3699
+ const model = loadModel(text, file);
3700
+ const target = model.targets.find((t) => t.name === name);
3701
+ if (!target) return [];
3702
+ return target.configs.map((c) => {
3703
+ const project = model.projectConfigs.find((p) => p.name === c.name);
3704
+ const out = { config: c.name };
3705
+ const marketing = (c.marketing ?? project?.marketing)?.node.value;
3706
+ const build = (c.build ?? project?.build)?.node.value;
3707
+ if (marketing !== void 0) out.MARKETING_VERSION = marketing;
3708
+ if (build !== void 0) out.CURRENT_PROJECT_VERSION = build;
3709
+ return out;
3710
+ });
3711
+ }
3687
3712
  /** Every `PBXNativeTarget` of the project, in project order (used by `init`). */
3688
3713
  function listNativeTargets(text, file) {
3689
3714
  return loadModel(text, file).targets.map((t) => {
@@ -3725,7 +3750,7 @@ const PROJECT_LEVEL = "project level";
3725
3750
  * `mode` decides which problems matter: when writing, a conditional assignment of a located field
3726
3751
  * is an error (it would ship another value); when reading, only conditionals are ignored.
3727
3752
  */
3728
- function locate$2(model, targets, fields, required, mode, explicit, file) {
3753
+ function locate$1(model, targets, fields, required, mode, explicit, file) {
3729
3754
  const seen = /* @__PURE__ */ new Set();
3730
3755
  const out = [];
3731
3756
  const take = (field, owner, what, config) => {
@@ -3770,7 +3795,7 @@ function assertLiteral(l, file) {
3770
3795
  const pbxproj = {
3771
3796
  read(text, file, options) {
3772
3797
  const model = loadModel(text, file);
3773
- return locate$2(model, selectTargets(model, options.targets, file), ["marketing", "build"], ["marketing"], "read", Boolean(options.targets?.length), file).map((l) => ({
3798
+ return locate$1(model, selectTargets(model, options.targets, file), ["marketing", "build"], ["marketing"], "read", Boolean(options.targets?.length), file).map((l) => ({
3774
3799
  field: l.field,
3775
3800
  key: `${FIELD_KEY[l.field]} (${l.owner}, ${l.configName})`,
3776
3801
  value: l.node.value,
@@ -3786,7 +3811,7 @@ const pbxproj = {
3786
3811
  const fields = [];
3787
3812
  if (values.marketing !== void 0) fields.push("marketing");
3788
3813
  if (values.build !== void 0) fields.push("build");
3789
- return applySplices(text, locate$2(model, targets, fields, fields, "write", Boolean(options.targets?.length), file).map((l) => {
3814
+ return applySplices(text, locate$1(model, targets, fields, fields, "write", Boolean(options.targets?.length), file).map((l) => {
3790
3815
  assertLiteral(l, file);
3791
3816
  const value = l.field === "marketing" ? values.marketing : String(values.build);
3792
3817
  return {
@@ -3954,6 +3979,190 @@ const plist = {
3954
3979
  return applySplices(text, splices);
3955
3980
  }
3956
3981
  };
3982
+ // src/platforms/yaml.ts
3983
+ /**
3984
+ * Generic YAML stamper (spec 6.6, kind `yaml`): replaces one scalar, addressed by a dotted key
3985
+ * (`appVersion`, `metadata.labels.version`), using the `yaml` library only to find the scalar's
3986
+ * source range. Only the scalar's text changes; plain, 'single' and "double" quote styles are kept.
3987
+ *
3988
+ * In a multi-document file the key must exist in exactly one document. Block scalars (`|`, `>`),
3989
+ * multi-line scalars and anchors/aliases are not supported (error). Marketing version only.
3990
+ */
3991
+ function parse(text, file) {
3992
+ const docs = parseAllDocuments(text);
3993
+ const list = Array.isArray(docs) ? docs : [docs];
3994
+ for (const doc of list) {
3995
+ const err = doc.errors[0];
3996
+ if (err) throw new StampError(file, `invalid YAML (line ${err.linePos?.[0]?.line ?? lineOf(text, err.pos[0])}): ${err.message.split("\n")[0]}`);
3997
+ }
3998
+ return list;
3999
+ }
4000
+ function describe$1(text, file, key, scalar) {
4001
+ const range = scalar.range;
4002
+ const line = range ? lineOf(text, range[0]) : 1;
4003
+ const where = `"${key}" (line ${line})`;
4004
+ if (!range || range[1] === range[0]) throw new StampError(file, `${where} has no value`);
4005
+ const type = scalar.type;
4006
+ if (type !== "PLAIN" && type !== "QUOTE_DOUBLE" && type !== "QUOTE_SINGLE") throw new StampError(file, `${where} is a block scalar; only plain or quoted values are supported`);
4007
+ const source = text.slice(range[0], range[1]);
4008
+ if (/[\r\n]/.test(source)) throw new StampError(file, `${where} spans multiple lines, which isn't supported`);
4009
+ if (type === "PLAIN") return {
4010
+ start: range[0],
4011
+ end: range[1],
4012
+ quote: null,
4013
+ value: source,
4014
+ line
4015
+ };
4016
+ const quote = type === "QUOTE_DOUBLE" ? "\"" : "'";
4017
+ return {
4018
+ start: range[0] + 1,
4019
+ end: range[1] - 1,
4020
+ quote,
4021
+ value: String(scalar.value),
4022
+ line
4023
+ };
4024
+ }
4025
+ /** Walk `path` through maps and sequences; `undefined` when a key is missing. */
4026
+ function walk(doc, path, file, key) {
4027
+ let node = doc.contents;
4028
+ for (const segment of path) {
4029
+ if (isAlias(node)) throw new StampError(file, `"${key}" is reached through an alias (*${node.source}); aliases and anchors can't be stamped`);
4030
+ if (isMap(node)) {
4031
+ const next = node.get(segment, true);
4032
+ if (next === void 0) {
4033
+ if (node.items.some((pair) => isScalar(pair.key) && pair.key.value === "<<")) throw new StampError(file, `"${key}" isn't set directly: a "<<" merge key is in the way and merge keys can't be stamped`);
4034
+ return;
4035
+ }
4036
+ node = next;
4037
+ } else if (isSeq(node) && /^(0|[1-9]\d*)$/.test(segment)) node = node.get(Number(segment), true);
4038
+ else return;
4039
+ }
4040
+ return node;
4041
+ }
4042
+ /**
4043
+ * Find the scalar at the dotted `key` (in exactly one document). Throws `StampError` when it is
4044
+ * missing, ambiguous, a collection, an alias or anchor, a block scalar or multi-line.
4045
+ */
4046
+ function locateYamlScalar(text, file, key) {
4047
+ const path = key.split(".");
4048
+ const hits = [];
4049
+ parse(text, file).forEach((doc, index) => {
4050
+ const node = walk(doc, path, file, key);
4051
+ if (node === void 0 || node === null) return;
4052
+ if (isAlias(node)) throw new StampError(file, `"${key}" is an alias (*${node.source}); aliases and anchors can't be stamped`);
4053
+ if (!isScalar(node)) throw new StampError(file, `"${key}" is a collection, expected a string value`);
4054
+ if (node.anchor) throw new StampError(file, `"${key}" is anchored (&${node.anchor}), so other places may share this value through an alias; anchors can't be stamped`);
4055
+ hits.push({
4056
+ doc: index + 1,
4057
+ scalar: node
4058
+ });
4059
+ });
4060
+ if (hits.length === 0) throw new StampError(file, `key "${key}" not found`);
4061
+ if (hits.length > 1) throw new StampError(file, `key "${key}" exists in more than one YAML document (documents ${hits.map((h) => h.doc).join(", ")}); can't tell which one to stamp`);
4062
+ return describe$1(text, file, key, hits[0].scalar);
4063
+ }
4064
+ const yamlValue = {
4065
+ read(text, file, options) {
4066
+ const loc = locateYamlScalar(text, file, options.key);
4067
+ return [{
4068
+ field: "marketing",
4069
+ key: options.key,
4070
+ value: loc.value,
4071
+ line: loc.line
4072
+ }];
4073
+ },
4074
+ write(text, file, values, options) {
4075
+ if (values.marketing === void 0) return text;
4076
+ const loc = locateYamlScalar(text, file, options.key);
4077
+ const version = values.marketing;
4078
+ if (!/^[0-9A-Za-z][0-9A-Za-z.+_-]*$/.test(version)) throw new StampError(file, `can't write "${version}" as "${options.key}": not a plain version string`);
4079
+ return applySplices(text, [{
4080
+ start: loc.start,
4081
+ end: loc.end,
4082
+ text: version
4083
+ }]);
4084
+ }
4085
+ };
4086
+ // src/platforms/pubspec.ts
4087
+ /**
4088
+ * Flutter / Dart `pubspec.yaml` stamper (spec 6.3 and 6.4 `flutter`, 5 `version.file`).
4089
+ *
4090
+ * The top-level `version` holds both numbers in one value: `1.5.0+217175105` is the build name
4091
+ * `1.5.0` and the build number `217175105`. Flutter passes them to the native projects
4092
+ * (`flutter.versionName` / `flutter.versionCode` in Gradle, `$(FLUTTER_BUILD_NAME)` /
4093
+ * `$(FLUTTER_BUILD_NUMBER)` in `Info.plist`).
4094
+ *
4095
+ * - marketing: the part before `+`. Writing only the marketing version (the release PR) keeps
4096
+ * the `+…` suffix exactly as written, or its absence, so the diff is the version alone.
4097
+ * - build: the part after `+`. Written only in CI (build numbers are never committed, spec 1.1):
4098
+ * replaces the suffix, or appends `+<n>` when there is none.
4099
+ *
4100
+ * The scalar is found with the `yaml` library's node ranges and spliced; plain, 'single' and
4101
+ * "double" quoted values keep their style. Nested `version` keys (a dependency's) are ignored.
4102
+ */
4103
+ /** A version without build metadata: `X.Y.Z` with an optional prerelease. */
4104
+ const BUILD_NAME = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
4105
+ function locateVersion(text, file) {
4106
+ try {
4107
+ return locateYamlScalar(text, file, "version");
4108
+ } catch (error) {
4109
+ if (error instanceof StampError && error.reason.startsWith("key \"version\" not found")) throw new StampError(file, "no top-level version; add one, e.g. `version: 1.0.0+1` (build name + build number)");
4110
+ throw error;
4111
+ }
4112
+ }
4113
+ /** The value as written in the file (the text between the quotes for a quoted scalar). */
4114
+ function source(text, loc, file) {
4115
+ const raw = text.slice(loc.start, loc.end);
4116
+ if (loc.quote === "\"" && raw.includes("\\")) throw new StampError(file, `version (line ${loc.line}) uses escape sequences; write it as a plain value like 1.0.0+1`);
4117
+ return raw;
4118
+ }
4119
+ /** `1.5.0+12` → `{ name: "1.5.0", suffix: "+12" }`; without `+` the suffix is empty. */
4120
+ function splitPubspecVersion(value) {
4121
+ const at = value.indexOf("+");
4122
+ return at === -1 ? {
4123
+ name: value,
4124
+ suffix: ""
4125
+ } : {
4126
+ name: value.slice(0, at),
4127
+ suffix: value.slice(at)
4128
+ };
4129
+ }
4130
+ const pubspec = {
4131
+ read(text, file) {
4132
+ const loc = locateVersion(text, file);
4133
+ const { name, suffix } = splitPubspecVersion(source(text, loc, file));
4134
+ const found = [{
4135
+ field: "marketing",
4136
+ key: "version",
4137
+ value: name,
4138
+ line: loc.line
4139
+ }];
4140
+ if (suffix !== "") found.push({
4141
+ field: "build",
4142
+ key: "version (+build)",
4143
+ value: suffix.slice(1),
4144
+ line: loc.line
4145
+ });
4146
+ return found;
4147
+ },
4148
+ write(text, file, values, options) {
4149
+ if (values.marketing === void 0 && values.build === void 0) return text;
4150
+ if (values.marketing !== void 0) {
4151
+ if (!BUILD_NAME.test(values.marketing)) throw new StampError(file, `can't write "${values.marketing}" as the version: expected X.Y.Z with an optional prerelease`);
4152
+ if (options?.platform === "ios") assertIosMarketing(values.marketing, file);
4153
+ }
4154
+ if (values.build !== void 0) assertBuildNumber(values.build, file);
4155
+ const loc = locateVersion(text, file);
4156
+ const current = splitPubspecVersion(source(text, loc, file));
4157
+ const name = values.marketing ?? current.name;
4158
+ const suffix = values.build !== void 0 ? `+${values.build}` : current.suffix;
4159
+ return applySplices(text, [{
4160
+ start: loc.start,
4161
+ end: loc.end,
4162
+ text: `${name}${suffix}`
4163
+ }]);
4164
+ }
4165
+ };
3957
4166
  // src/platforms/regex.ts
3958
4167
  /**
3959
4168
  * Regex stamper (spec 6.6, kind `regex`): `pattern` must match exactly once in the file; the match
@@ -4052,7 +4261,7 @@ function lineEndingHint(text, mentionsCr) {
4052
4261
  * runs on an LF view of the file, so a `\n` in it matches a CRLF line ending, and the match is
4053
4262
  * mapped back to the original text (decision in design/DECISIONS.md).
4054
4263
  */
4055
- function locate$1(text, file, options) {
4264
+ function locate(text, file, options) {
4056
4265
  const mentionsCr = mentionsCarriageReturn(options.pattern);
4057
4266
  const useLf = text.includes("\r\n") && !mentionsCr;
4058
4267
  const { single, counting } = compile(file, options, useLf);
@@ -4171,7 +4380,7 @@ function render(template, file, values) {
4171
4380
  }
4172
4381
  const regexFile = {
4173
4382
  read(text, file, options) {
4174
- const { start, end } = locate$1(text, file, options);
4383
+ const { start, end } = locate(text, file, options);
4175
4384
  return [{
4176
4385
  field: "marketing",
4177
4386
  key: options.pattern,
@@ -4181,7 +4390,7 @@ const regexFile = {
4181
4390
  },
4182
4391
  write(text, file, values, options) {
4183
4392
  if (values.marketing === void 0 && values.build === void 0) return text;
4184
- return locate$1(text, file, options).replaceWith(render(options.replace, file, values));
4393
+ return locate(text, file, options).replaceWith(render(options.replace, file, values));
4185
4394
  }
4186
4395
  };
4187
4396
  // src/platforms/xcconfig.ts
@@ -4308,106 +4517,6 @@ const xcconfig = {
4308
4517
  function unquote(value) {
4309
4518
  return value.length >= 2 && value.startsWith("\"") && value.endsWith("\"") ? value.slice(1, -1) : value;
4310
4519
  }
4311
- // src/platforms/yaml.ts
4312
- /**
4313
- * Generic YAML stamper (spec 6.6, kind `yaml`): replaces one scalar, addressed by a dotted key
4314
- * (`appVersion`, `metadata.labels.version`), using the `yaml` library only to find the scalar's
4315
- * source range. Only the scalar's text changes; plain, 'single' and "double" quote styles are kept.
4316
- *
4317
- * In a multi-document file the key must exist in exactly one document. Block scalars (`|`, `>`),
4318
- * multi-line scalars and anchors/aliases are not supported (error). Marketing version only.
4319
- */
4320
- function parse(text, file) {
4321
- const docs = parseAllDocuments(text);
4322
- const list = Array.isArray(docs) ? docs : [docs];
4323
- for (const doc of list) {
4324
- const err = doc.errors[0];
4325
- if (err) throw new StampError(file, `invalid YAML (line ${err.linePos?.[0]?.line ?? lineOf(text, err.pos[0])}): ${err.message.split("\n")[0]}`);
4326
- }
4327
- return list;
4328
- }
4329
- function describe$1(text, file, key, scalar) {
4330
- const range = scalar.range;
4331
- const line = range ? lineOf(text, range[0]) : 1;
4332
- const where = `"${key}" (line ${line})`;
4333
- if (!range || range[1] === range[0]) throw new StampError(file, `${where} has no value`);
4334
- const type = scalar.type;
4335
- if (type !== "PLAIN" && type !== "QUOTE_DOUBLE" && type !== "QUOTE_SINGLE") throw new StampError(file, `${where} is a block scalar; only plain or quoted values are supported`);
4336
- const source = text.slice(range[0], range[1]);
4337
- if (/[\r\n]/.test(source)) throw new StampError(file, `${where} spans multiple lines, which isn't supported`);
4338
- if (type === "PLAIN") return {
4339
- start: range[0],
4340
- end: range[1],
4341
- quote: null,
4342
- value: source,
4343
- line
4344
- };
4345
- const quote = type === "QUOTE_DOUBLE" ? "\"" : "'";
4346
- return {
4347
- start: range[0] + 1,
4348
- end: range[1] - 1,
4349
- quote,
4350
- value: String(scalar.value),
4351
- line
4352
- };
4353
- }
4354
- /** Walk `path` through maps and sequences; `undefined` when a key is missing. */
4355
- function walk(doc, path, file, key) {
4356
- let node = doc.contents;
4357
- for (const segment of path) {
4358
- if (isAlias(node)) throw new StampError(file, `"${key}" is reached through an alias (*${node.source}); aliases and anchors can't be stamped`);
4359
- if (isMap(node)) {
4360
- const next = node.get(segment, true);
4361
- if (next === void 0) {
4362
- if (node.items.some((pair) => isScalar(pair.key) && pair.key.value === "<<")) throw new StampError(file, `"${key}" isn't set directly: a "<<" merge key is in the way and merge keys can't be stamped`);
4363
- return;
4364
- }
4365
- node = next;
4366
- } else if (isSeq(node) && /^(0|[1-9]\d*)$/.test(segment)) node = node.get(Number(segment), true);
4367
- else return;
4368
- }
4369
- return node;
4370
- }
4371
- function locate(text, file, key) {
4372
- const path = key.split(".");
4373
- const hits = [];
4374
- parse(text, file).forEach((doc, index) => {
4375
- const node = walk(doc, path, file, key);
4376
- if (node === void 0 || node === null) return;
4377
- if (isAlias(node)) throw new StampError(file, `"${key}" is an alias (*${node.source}); aliases and anchors can't be stamped`);
4378
- if (!isScalar(node)) throw new StampError(file, `"${key}" is a collection, expected a string value`);
4379
- if (node.anchor) throw new StampError(file, `"${key}" is anchored (&${node.anchor}), so other places may share this value through an alias; anchors can't be stamped`);
4380
- hits.push({
4381
- doc: index + 1,
4382
- scalar: node
4383
- });
4384
- });
4385
- if (hits.length === 0) throw new StampError(file, `key "${key}" not found`);
4386
- if (hits.length > 1) throw new StampError(file, `key "${key}" exists in more than one YAML document (documents ${hits.map((h) => h.doc).join(", ")}); can't tell which one to stamp`);
4387
- return describe$1(text, file, key, hits[0].scalar);
4388
- }
4389
- const yamlValue = {
4390
- read(text, file, options) {
4391
- const loc = locate(text, file, options.key);
4392
- return [{
4393
- field: "marketing",
4394
- key: options.key,
4395
- value: loc.value,
4396
- line: loc.line
4397
- }];
4398
- },
4399
- write(text, file, values, options) {
4400
- if (values.marketing === void 0) return text;
4401
- const loc = locate(text, file, options.key);
4402
- const version = values.marketing;
4403
- if (!/^[0-9A-Za-z][0-9A-Za-z.+_-]*$/.test(version)) throw new StampError(file, `can't write "${version}" as "${options.key}": not a plain version string`);
4404
- return applySplices(text, [{
4405
- start: loc.start,
4406
- end: loc.end,
4407
- text: version
4408
- }]);
4409
- }
4410
- };
4411
4520
  // src/platforms/index.ts
4412
4521
  /**
4413
4522
  * Stamping layer (spec 6): maps a target's config to the files it stamps and the stamper
@@ -4478,6 +4587,13 @@ function sourceBinding(target, file) {
4478
4587
  stamper: target.type === "ios" ? expoIos : expoAndroid,
4479
4588
  options: void 0
4480
4589
  };
4590
+ case "pubspec":
4591
+ if (target.type !== "android" && target.type !== "ios") break;
4592
+ return {
4593
+ ...base,
4594
+ stamper: pubspec,
4595
+ options: { platform: target.type }
4596
+ };
4481
4597
  }
4482
4598
  throw new Error(`internal: source format ${file.format} doesn't fit target ${target.name}`);
4483
4599
  }
@@ -4542,11 +4658,22 @@ async function targetBindings(target, root) {
4542
4658
  }
4543
4659
  /**
4544
4660
  * The root version file and, for a `package.json`, a sibling `package-lock.json` /
4545
- * `npm-shrinkwrap.json` (spec 6.6 "npm lockfile").
4661
+ * `npm-shrinkwrap.json` (spec 6.6 "npm lockfile"). A `pubspec.yaml` version file also carries
4662
+ * the build number in CI (its `+N`), so `flutter build` of any target sees the run's numbers.
4546
4663
  */
4547
4664
  async function versionFileBindings(config, root) {
4548
4665
  const file = config.version.file;
4549
4666
  const absolute = resolve(root, file);
4667
+ if (versionFileFormat(file) === "pubspec") return [{
4668
+ path: file,
4669
+ absolute,
4670
+ field: "version.file",
4671
+ stamper: pubspec,
4672
+ options: void 0,
4673
+ value: "version",
4674
+ build: true,
4675
+ ciOnly: false
4676
+ }];
4550
4677
  const bindings = [{
4551
4678
  path: file,
4552
4679
  absolute,
@@ -4581,8 +4708,8 @@ async function readRootVersion(config, root) {
4581
4708
  const text = await readFile(absolute, "utf8").catch((error) => {
4582
4709
  throw new LaunchsetError("version-file-missing", `version.file: can't read ${config.version.file} (${error.code ?? error.message})`);
4583
4710
  });
4584
- const value = jsonValue.read(text, config.version.file, { key: "version" })[0]?.value;
4585
- if (!value) throw new LaunchsetError("no-root-version", `${config.version.file} has no "version"`, { hint: "Add a \"version\" field, e.g. \"version\": \"0.1.0\"." });
4711
+ const value = (versionFileFormat(config.version.file) === "pubspec" ? pubspec.read(text, config.version.file, void 0) : jsonValue.read(text, config.version.file, { key: "version" })).find((f) => f.field === "marketing")?.value;
4712
+ if (!value) throw new LaunchsetError("no-root-version", `${config.version.file} has no "version"`, { hint: rootVersionHint(config.version.file) });
4586
4713
  return value;
4587
4714
  }
4588
4715
  function valuesFor(binding, values, withBuild) {
@@ -4657,11 +4784,18 @@ async function stampForBuild(config, root, plan, targetPlan) {
4657
4784
  if (build !== void 0) values.build = build;
4658
4785
  if (targetPlan.docker) values.imageTag = targetPlan.docker.verifyTag;
4659
4786
  const work = [];
4660
- for (const binding of await versionFileBindings(config, root)) work.push({
4661
- binding,
4662
- values: { marketing: plan.version }
4663
- });
4664
- for (const binding of await targetBindings(target, root)) work.push({
4787
+ const own = await targetBindings(target, root);
4788
+ const ownFiles = new Set(own.filter((b) => b.stamper === pubspec).map((b) => b.absolute));
4789
+ for (const binding of await versionFileBindings(config, root)) {
4790
+ if (ownFiles.has(binding.absolute)) continue;
4791
+ const rootValues = { marketing: plan.version };
4792
+ if (binding.build && build !== void 0) rootValues.build = build;
4793
+ work.push({
4794
+ binding,
4795
+ values: rootValues
4796
+ });
4797
+ }
4798
+ for (const binding of own) work.push({
4665
4799
  binding,
4666
4800
  values: valuesFor(binding, values, true)
4667
4801
  });
@@ -5102,7 +5236,7 @@ const INIT_FLAGS = [
5102
5236
  type: "boolean",
5103
5237
  negatable: true,
5104
5238
  decision: "baseline",
5105
- description: "Create the release tag for the canonical version at HEAD, so it counts as released."
5239
+ description: "Mark the canonical version as released (baseline in the config): the first release workflow run after the merge creates its release tag."
5106
5240
  },
5107
5241
  {
5108
5242
  flag: "--skill",
@@ -5531,13 +5665,20 @@ function androidDir(target) {
5531
5665
  case "gradle-properties": return posix.dirname(posix.normalize(source.file));
5532
5666
  case "capacitor": return posix.join(source.dir, "android");
5533
5667
  case "expo": return "android";
5668
+ case "flutter": return posix.join(source.dir, "android");
5534
5669
  }
5535
5670
  }
5671
+ /** The Flutter project folder of a target with `source: { kind: "flutter" }`, else undefined. */
5672
+ function flutterDir(target) {
5673
+ if (target.type !== "android" && target.type !== "ios") return void 0;
5674
+ return target.source.kind === "flutter" ? posix.normalize(target.source.dir) : void 0;
5675
+ }
5536
5676
  function iosProject(target) {
5537
5677
  const source = target.source;
5538
5678
  switch (source.kind) {
5539
5679
  case "xcodeproj": return posix.normalize(source.file);
5540
5680
  case "capacitor": return posix.join(source.dir, "ios/App/App.xcodeproj");
5681
+ case "flutter": return posix.join(source.dir, "ios/Runner.xcodeproj");
5541
5682
  default: return "<path to App.xcodeproj>";
5542
5683
  }
5543
5684
  }
@@ -5566,6 +5707,17 @@ function buildSnippet(target, mode, hints) {
5566
5707
  target: target.name,
5567
5708
  if: stepCondition(target, mode)
5568
5709
  };
5710
+ const flutter = flutterDir(target);
5711
+ if (flutter !== void 0 && (target.type === "android" || target.type === "ios")) {
5712
+ const file = `snippets/flutter-${target.type}.yml`;
5713
+ return fillTemplate(readTemplate(file), {
5714
+ ...common,
5715
+ flutter_dir: scalar(flutter),
5716
+ flutter_native_dir: scalar(posix.join(flutter, target.type)),
5717
+ pubspec: posix.join(flutter, "pubspec.yaml"),
5718
+ package_name: (target.type === "android" ? target.store?.packageName : void 0) ?? "<your.package.name>"
5719
+ }, file);
5720
+ }
5569
5721
  switch (target.type) {
5570
5722
  case "docker": {
5571
5723
  const hint = hints[target.name] ?? {};
@@ -5729,7 +5881,7 @@ function renderWorkflows(input) {
5729
5881
  if (config.preview.enabled) {
5730
5882
  const label = exprString(config.preview.label);
5731
5883
  const prLabel = `(contains(github.event.pull_request.labels.*.name, ${label}) && (github.event.action != 'labeled' || github.event.label.name == ${label}))`;
5732
- const preview = renderBuildParts(input, previewTargets(config), "preview");
5884
+ const preview = renderBuildParts(input, input.allPreviewSteps ? releaseTargets(config) : previewTargets(config), "preview");
5733
5885
  files.push({
5734
5886
  path: ".github/workflows/launchset-preview.yml",
5735
5887
  content: fillTemplate(readTemplate("launchset-preview.yml"), {
@@ -6068,4 +6220,4 @@ function inspectTargetJobs(input) {
6068
6220
  notInterruptible
6069
6221
  };
6070
6222
  }
6071
- export { gradleProperties as $, latestRelease as $t, packageFile as A, describeManualTarget as At, remoteHost as B, planBuildNumber as Bt, labelRe2 as C, lineOf as Ct, ruleEntry as D, alert as Dt, psQuote as E, forgeWords as Et, parseDecide as F, isoTime as Ft, stampForRelease as G, unknownTarget as Gt, checkConsistency as H, readChangesetFile as Ht, REQUIRED_APP_PERMISSIONS as I, joinWords as It, plist as J, hasMarker as Jt, writeChanges as K, validChangesets as Kt, permissionLabel as L, manualTargetStatuses as Lt, packageVersion as M, firstLine as Mt, readPackageFile as N, invalidChangesetFiles as Nt, shellWord as O, buildTargetPlans as Ot, INIT_FLAGS as P, isoDay as Pt, imageRefs as Q, lastReleaseTag as Qt, detectHost as R, manualTargets as Rt, installItems as S, lineEnd as St, parseGitLabYaml as T, forgeLinks as Tt, readRootVersion as U, renderSummary as Ut, serverUrlFromRemote as V, plural as Vt, stampForBuild as W, snapshotTags as Wt, pbxproj as X, indexTags as Xt, listNativeTargets as Y, highestMarkerVersion as Yt, hasImageRef as Z, isReleased as Zt, GITLAB_CUSTOM_TAGS as _, generateChangesetName as _n, insertSection as _t, inspectTargetJobs as a, prereleaseVersions as an, loadConfig as at, checkGitLabYaml as b, serializeChangeset as bn, detectEol as bt, androidDir as c, renderTag as cn, GitError as ct, iosScheme as d, versionTagShas as dn, TagExistsError as dt, latestReleaseInLine as en, gradle as et, isNpmTarget as f, dockerPlan as fn, parseRepoFromRemote as ft, unique as g, convertChangesetsFile as gn, extractSectionWithHeading as gt, renderWorkflows as h, CHANGESET_DIR as hn, extractSection as ht, checkTemplateFile as i, partialTag as in, CONFIG_FILE_NAMES as it, packageRoot as j, describeMismatch as jt, yamlScalar as k, code as kt, fillTemplate as l, takenVersions as ln, LeaseError as lt, registryOf as m, forgeHints as mn, CHANGELOG_TITLE as mt, DEFAULT_TARGETS_FILE as n, markersFor as nn, expoIos as nt, renderChildPipeline as o, releaseTag as on, statOrNull as ot, readTemplateFile as p, computeBuildNumber as pn, topPathspec as pt, xcconfig as q, autoTargets as qt, PLAN_JOBS as r, missingAutoTargets as rn, isBuildSettingReference as rt, targetJobName as s, releasesAfter as sn, Git as st, DEFAULT_CHILD_FILE as t, markerTag as tn, expoAndroid as tt, iosProject as u, unfinishedReleases as un, TagCleanupError as ut, GitLabReference as v, isChangesetPath as vn, insertSectionSorted as vt, maintenanceCondition as w, lineStart as wt, defaultCliSpec as x, indentAt as xt, branchCondition as y, parseChangeset as yn, renderSection as yt, readCiEnvironment as z, normalizeVersionInput as zt };
6223
+ export { pbxproj as $, indexTags as $t, yamlScalar as A, alert as At, readCiEnvironment as B, manualTargetStatuses as Bt, installItems as C, serializeChangeset as Cn, detectEol as Ct, psQuote as D, lineStart as Dt, parseGitLabYaml as E, lineOf as Et, INIT_FLAGS as F, firstLine as Ft, stampForBuild as G, readChangesetFile as Gt, serverUrlFromRemote as H, normalizeVersionInput as Ht, parseDecide as I, invalidChangesetFiles as It, xcconfig as J, unknownTarget as Jt, stampForRelease as K, renderSummary as Kt, REQUIRED_APP_PERMISSIONS as L, isoDay as Lt, packageRoot as M, code as Mt, packageVersion as N, describeManualTarget as Nt, ruleEntry as O, forgeLinks as Ot, readPackageFile as P, describeMismatch as Pt, listNativeTargets as Q, highestMarkerVersion as Qt, permissionLabel as R, isoTime as Rt, defaultCliSpec as S, parseChangeset as Sn, renderSection as St, maintenanceCondition as T, lineEnd as Tt, checkConsistency as U, planBuildNumber as Ut, remoteHost as V, manualTargets as Vt, readRootVersion as W, plural as Wt, plist as X, autoTargets as Xt, pubspec as Y, validChangesets as Yt, effectiveVersionSettings as Z, hasMarker as Zt, unique as _, forgeHints as _n, CHANGELOG_TITLE as _t, inspectTargetJobs as a, markersFor as an, expoIos as at, branchCondition as b, generateChangesetName as bn, insertSection as bt, androidDir as c, prereleaseVersions as cn, loadConfig as ct, iosProject as d, renderTag as dn, GitError as dt, isReleased as en, hasImageRef as et, iosScheme as f, takenVersions as fn, LeaseError as ft, renderWorkflows as g, computeBuildNumber as gn, topPathspec as gt, registryOf as h, dockerPlan as hn, parseRepoFromRemote as ht, checkTemplateFile as i, markerTag as in, expoAndroid as it, packageFile as j, buildTargetPlans as jt, shellWord as k, forgeWords as kt, fillTemplate as l, releaseTag as ln, statOrNull as lt, readTemplateFile as m, versionTagShas as mn, TagExistsError as mt, DEFAULT_TARGETS_FILE as n, latestRelease as nn, gradleProperties as nt, renderChildPipeline as o, missingAutoTargets as on, isBuildSettingReference as ot, isNpmTarget as p, unfinishedReleases as pn, TagCleanupError as pt, writeChanges as q, snapshotTags as qt, PLAN_JOBS as r, latestReleaseInLine as rn, gradle as rt, targetJobName as s, partialTag as sn, CONFIG_FILE_NAMES as st, DEFAULT_CHILD_FILE as t, lastReleaseTag as tn, imageRefs as tt, flutterDir as u, releasesAfter as un, Git as ut, GITLAB_CUSTOM_TAGS as v, CHANGESET_DIR as vn, extractSection as vt, labelRe2 as w, indentAt as wt, checkGitLabYaml as x, isChangesetPath as xn, insertSectionSorted as xt, GitLabReference as y, convertChangesetsFile as yn, extractSectionWithHeading as yt, detectHost as z, joinWords as zt };