@ankhorage/devtools 1.3.0 → 1.3.1

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.
@@ -2,8 +2,10 @@
2
2
  * Synchronize the consumer `package.json` contract owned by `@ankhorage/devtools`.
3
3
  *
4
4
  * Package synchronization is merge-aware. It installs the current `@ankhorage/devtools` version
5
- * as a development dependency, removes individually installed toolchain packages that devtools now
6
- * owns, and writes the canonical `lint`, `lint:fix`, `format`, `format:check`, and `knip` scripts.
5
+ * as a development dependency for normal consumers, while `@ankhorage/ankh` keeps devtools as a
6
+ * runtime dependency because the CLI loads it as a bundled core provider. Individually installed
7
+ * toolchain packages that devtools now owns are removed, and the canonical `lint`, `lint:fix`,
8
+ * `format`, `format:check`, and `knip` scripts are written.
7
9
  * Unrelated manifest fields, scripts, dependencies, and metadata are preserved.
8
10
  *
9
11
  * Status compares only the fields owned by this contract, so unrelated repository customization
@@ -20,6 +22,7 @@ import { readFile, writeFile } from 'node:fs/promises';
20
22
  import { resolve } from 'node:path';
21
23
  const PACKAGE_PATH = 'package.json';
22
24
  const DEVTOOLS_PACKAGE_NAME = '@ankhorage/devtools';
25
+ const ANKH_PACKAGE_NAME = '@ankhorage/ankh';
23
26
  const STANDARD_SCRIPTS = {
24
27
  lint: 'ankhorage-eslint . --max-warnings=0',
25
28
  'lint:fix': 'ankhorage-eslint . --fix --max-warnings=0',
@@ -79,9 +82,8 @@ export function applyManagedPackageContract(manifest, devtoolsVersion) {
79
82
  }
80
83
  const scripts = { ...toRecord(manifest.scripts), ...STANDARD_SCRIPTS };
81
84
  const devDependencies = removeOwnedDependencies(toRecord(manifest.devDependencies));
82
- devDependencies[DEVTOOLS_PACKAGE_NAME] = `^${devtoolsVersion}`;
83
85
  const dependencies = toRecord(manifest.dependencies);
84
- delete dependencies[DEVTOOLS_PACKAGE_NAME];
86
+ applyDevtoolsDependencyPlacement(manifest, dependencies, devDependencies, devtoolsVersion);
85
87
  return {
86
88
  ...manifest,
87
89
  ...normalizedDependencies(manifest, dependencies),
@@ -98,8 +100,7 @@ export function isManagedPackageContractCurrent(manifest, devtoolsVersion) {
98
100
  const dependencies = toRecord(manifest.dependencies);
99
101
  return (hasStandardScripts(scripts) &&
100
102
  DEVTOOLS_OWNED_DEV_DEPENDENCIES.every((name) => devDependencies[name] === undefined) &&
101
- devDependencies[DEVTOOLS_PACKAGE_NAME] === `^${devtoolsVersion}` &&
102
- dependencies[DEVTOOLS_PACKAGE_NAME] === undefined);
103
+ hasCurrentDevtoolsDependencyPlacement(manifest, dependencies, devDependencies, devtoolsVersion));
103
104
  }
104
105
  export function readCurrentDevtoolsVersion() {
105
106
  const parsed = JSON.parse(readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'));
@@ -124,6 +125,25 @@ async function readPackageManifest(targetDirectory) {
124
125
  throw error;
125
126
  }
126
127
  }
128
+ function applyDevtoolsDependencyPlacement(manifest, dependencies, devDependencies, devtoolsVersion) {
129
+ const versionRange = `^${devtoolsVersion}`;
130
+ if (manifest.name === ANKH_PACKAGE_NAME) {
131
+ dependencies[DEVTOOLS_PACKAGE_NAME] = versionRange;
132
+ delete devDependencies[DEVTOOLS_PACKAGE_NAME];
133
+ return;
134
+ }
135
+ devDependencies[DEVTOOLS_PACKAGE_NAME] = versionRange;
136
+ delete dependencies[DEVTOOLS_PACKAGE_NAME];
137
+ }
138
+ function hasCurrentDevtoolsDependencyPlacement(manifest, dependencies, devDependencies, devtoolsVersion) {
139
+ const versionRange = `^${devtoolsVersion}`;
140
+ if (manifest.name === ANKH_PACKAGE_NAME) {
141
+ return (dependencies[DEVTOOLS_PACKAGE_NAME] === versionRange &&
142
+ devDependencies[DEVTOOLS_PACKAGE_NAME] === undefined);
143
+ }
144
+ return (devDependencies[DEVTOOLS_PACKAGE_NAME] === versionRange &&
145
+ dependencies[DEVTOOLS_PACKAGE_NAME] === undefined);
146
+ }
127
147
  function removeOwnedDependencies(devDependencies) {
128
148
  for (const dependencyName of DEVTOOLS_OWNED_DEV_DEPENDENCIES) {
129
149
  delete devDependencies[dependencyName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankhorage/devtools",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Shared development tools and repository standards for Ankhorage",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ankhorage/devtools#readme",