@ankhorage/devtools 1.5.2 → 1.6.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.
- package/README.md +4 -2
- package/dist/cli/runRepositoryCommand.js +11 -9
- package/dist/policy/bunRuntimePolicy.d.ts +15 -3
- package/dist/policy/bunRuntimePolicy.js +15 -3
- package/dist/tools/prettier/managed.d.ts +5 -0
- package/dist/tools/prettier/managed.js +45 -2
- package/dist/tools/workflows/files/ci.yml +5 -0
- package/dist/tools/workflows/files/release.yml +1 -1
- package/dist/tools/workflows/index.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ Synchronization is deterministic and idempotent:
|
|
|
154
154
|
- missing managed artifacts are created
|
|
155
155
|
- outdated centrally owned artifacts are updated
|
|
156
156
|
- the managed Bun runtime version is applied consistently to package metadata and workflows
|
|
157
|
-
- package changes are followed by `bun install
|
|
157
|
+
- package changes are followed by `bun install` after all managed files have been written, keeping installed dependencies and `bun.lock` synchronized without invalidating the running sync
|
|
158
158
|
- current artifacts are left untouched
|
|
159
159
|
- unrelated files and package fields are preserved
|
|
160
160
|
- repeated sync produces only `unchanged` results
|
|
@@ -232,7 +232,7 @@ Use `eslint.local.config.mjs` for narrow repository-specific flat-config overrid
|
|
|
232
232
|
|
|
233
233
|
## Prettier
|
|
234
234
|
|
|
235
|
-
`ankh devtools prettier sync` owns `.prettierrc.js
|
|
235
|
+
`ankh devtools prettier sync` owns `.prettierrc.js`, emits the correct ESM or CommonJS wrapper based on the repository's `package.json` module type, and creates `prettier.local.config.js` once for narrow repository-specific options.
|
|
236
236
|
|
|
237
237
|
The consumer delegates formatting policy to:
|
|
238
238
|
|
|
@@ -240,6 +240,8 @@ The consumer delegates formatting policy to:
|
|
|
240
240
|
@ankhorage/devtools/prettier
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
+
The wrapper merges shared and local `overrides` in that order. On first synchronization, an existing non-canonical `.prettierrc.js` is preserved as `prettier.local.config.js`; former shared-only Devtools delegates become an empty local config. Later synchronization never overwrites the local file.
|
|
244
|
+
|
|
243
245
|
## Knip
|
|
244
246
|
|
|
245
247
|
`ankh devtools knip sync` bootstraps `knip.config.ts` with:
|
|
@@ -52,20 +52,22 @@ async function runStatus(scope, targetDirectory, devtoolsVersion, context) {
|
|
|
52
52
|
}
|
|
53
53
|
async function runSync(scope, targetDirectory, devtoolsVersion, dryRun, context) {
|
|
54
54
|
const results = [];
|
|
55
|
+
let packageDependenciesChanged = false;
|
|
55
56
|
if (scope === 'all' || scope === 'package') {
|
|
56
57
|
const packageResult = await syncPackageManifest(targetDirectory, devtoolsVersion, { dryRun });
|
|
57
58
|
results.push(packageResult);
|
|
58
|
-
|
|
59
|
-
if (dryRun) {
|
|
60
|
-
results.push(planBunDependencySync(targetDirectory));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const syncDependencies = context.syncDependencies ?? syncBunDependencies;
|
|
64
|
-
results.push(await syncDependencies(targetDirectory));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
59
|
+
packageDependenciesChanged = packageResult.action !== 'unchanged';
|
|
67
60
|
}
|
|
68
61
|
results.push(...(await syncManagedFiles(targetDirectory, getManagedFiles(scope), { dryRun })));
|
|
62
|
+
if (packageDependenciesChanged) {
|
|
63
|
+
if (dryRun) {
|
|
64
|
+
results.push(planBunDependencySync(targetDirectory));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const syncDependencies = context.syncDependencies ?? syncBunDependencies;
|
|
68
|
+
results.push(await syncDependencies(targetDirectory));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
69
71
|
writeSyncOutput(results, context);
|
|
70
72
|
return { exitCode: 0 };
|
|
71
73
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical
|
|
2
|
+
* Canonical runtime/tooling policies for Ankhorage repositories.
|
|
3
3
|
*
|
|
4
|
-
* Import
|
|
5
|
-
* the managed Bun
|
|
4
|
+
* Import these from `@ankhorage/devtools/policy` when another package needs to inspect
|
|
5
|
+
* the managed Bun or Node baseline without defining an independent version authority.
|
|
6
6
|
*/
|
|
7
7
|
export declare const bunRuntimePolicy: {
|
|
8
8
|
readonly packageManager: "bun@1.3.14";
|
|
9
9
|
readonly typesRange: "^1.3.14";
|
|
10
10
|
readonly version: "1.3.14";
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Canonical Node LTS baseline for Node-based Ankhorage tooling and CI execution.
|
|
14
|
+
*
|
|
15
|
+
* Bun remains the repository package manager/primary command runtime where configured;
|
|
16
|
+
* this policy makes Node-based tooling deterministic instead of inheriting the ambient
|
|
17
|
+
* Node version from a CI runner image.
|
|
18
|
+
*/
|
|
19
|
+
export declare const nodeRuntimePolicy: {
|
|
20
|
+
readonly engineRange: "24.x";
|
|
21
|
+
readonly major: 24;
|
|
22
|
+
readonly setupVersion: "24";
|
|
23
|
+
};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical
|
|
2
|
+
* Canonical runtime/tooling policies for Ankhorage repositories.
|
|
3
3
|
*
|
|
4
|
-
* Import
|
|
5
|
-
* the managed Bun
|
|
4
|
+
* Import these from `@ankhorage/devtools/policy` when another package needs to inspect
|
|
5
|
+
* the managed Bun or Node baseline without defining an independent version authority.
|
|
6
6
|
*/
|
|
7
7
|
export const bunRuntimePolicy = {
|
|
8
8
|
packageManager: 'bun@1.3.14',
|
|
9
9
|
typesRange: '^1.3.14',
|
|
10
10
|
version: '1.3.14',
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Canonical Node LTS baseline for Node-based Ankhorage tooling and CI execution.
|
|
14
|
+
*
|
|
15
|
+
* Bun remains the repository package manager/primary command runtime where configured;
|
|
16
|
+
* this policy makes Node-based tooling deterministic instead of inheriting the ambient
|
|
17
|
+
* Node version from a CI runner image.
|
|
18
|
+
*/
|
|
19
|
+
export const nodeRuntimePolicy = {
|
|
20
|
+
engineRange: '24.x',
|
|
21
|
+
major: 24,
|
|
22
|
+
setupVersion: '24',
|
|
23
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export declare const prettierManagedFiles: readonly [{
|
|
2
|
+
readonly relativePath: "prettier.local.config.js";
|
|
3
|
+
readonly render: typeof renderInitialLocalConfig;
|
|
4
|
+
readonly mode: "create-only";
|
|
5
|
+
}, {
|
|
2
6
|
readonly relativePath: ".prettierrc.js";
|
|
3
7
|
readonly render: typeof renderPrettierConfig;
|
|
4
8
|
}];
|
|
5
9
|
declare function renderPrettierConfig(targetDirectory: string): Promise<string>;
|
|
10
|
+
declare function renderInitialLocalConfig(targetDirectory: string): Promise<string>;
|
|
6
11
|
export {};
|
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
const ESM_CONFIG = `
|
|
3
|
+
const ESM_CONFIG = `import sharedConfig from '@ankhorage/devtools/prettier';
|
|
4
|
+
import localConfig from './prettier.local.config.js';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
...sharedConfig,
|
|
8
|
+
...localConfig,
|
|
9
|
+
overrides: [...(sharedConfig.overrides ?? []), ...(localConfig.overrides ?? [])],
|
|
10
|
+
};
|
|
4
11
|
`;
|
|
5
|
-
const COMMONJS_CONFIG = `
|
|
12
|
+
const COMMONJS_CONFIG = `const sharedConfig = require('@ankhorage/devtools/prettier');
|
|
13
|
+
const localConfig = require('./prettier.local.config.js');
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
...sharedConfig,
|
|
17
|
+
...localConfig,
|
|
18
|
+
overrides: [...(sharedConfig.overrides ?? []), ...(localConfig.overrides ?? [])],
|
|
19
|
+
};
|
|
20
|
+
`;
|
|
21
|
+
const EMPTY_ESM_LOCAL_CONFIG = `export default {};
|
|
22
|
+
`;
|
|
23
|
+
const EMPTY_COMMONJS_LOCAL_CONFIG = `module.exports = {};
|
|
24
|
+
`;
|
|
25
|
+
const LEGACY_ESM_CONFIG = `export { default } from '@ankhorage/devtools/prettier';
|
|
26
|
+
`;
|
|
27
|
+
const LEGACY_COMMONJS_CONFIG = `module.exports = require('@ankhorage/devtools/prettier');
|
|
6
28
|
`;
|
|
7
29
|
export const prettierManagedFiles = [
|
|
30
|
+
{
|
|
31
|
+
relativePath: 'prettier.local.config.js',
|
|
32
|
+
render: renderInitialLocalConfig,
|
|
33
|
+
mode: 'create-only',
|
|
34
|
+
},
|
|
8
35
|
{
|
|
9
36
|
relativePath: '.prettierrc.js',
|
|
10
37
|
render: renderPrettierConfig,
|
|
@@ -13,6 +40,19 @@ export const prettierManagedFiles = [
|
|
|
13
40
|
async function renderPrettierConfig(targetDirectory) {
|
|
14
41
|
return (await readPackageType(targetDirectory)) === 'module' ? ESM_CONFIG : COMMONJS_CONFIG;
|
|
15
42
|
}
|
|
43
|
+
async function renderInitialLocalConfig(targetDirectory) {
|
|
44
|
+
const isModule = (await readPackageType(targetDirectory)) === 'module';
|
|
45
|
+
try {
|
|
46
|
+
const existingConfig = await readFile(resolve(targetDirectory, '.prettierrc.js'), 'utf8');
|
|
47
|
+
if (!isSharedOnlyConfig(existingConfig))
|
|
48
|
+
return existingConfig;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (!isNodeError(error) || error.code !== 'ENOENT')
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
return isModule ? EMPTY_ESM_LOCAL_CONFIG : EMPTY_COMMONJS_LOCAL_CONFIG;
|
|
55
|
+
}
|
|
16
56
|
async function readPackageType(targetDirectory) {
|
|
17
57
|
try {
|
|
18
58
|
const contents = await readFile(resolve(targetDirectory, 'package.json'), 'utf8');
|
|
@@ -29,6 +69,9 @@ async function readPackageType(targetDirectory) {
|
|
|
29
69
|
function isRecord(value) {
|
|
30
70
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
31
71
|
}
|
|
72
|
+
function isSharedOnlyConfig(value) {
|
|
73
|
+
return [ESM_CONFIG, COMMONJS_CONFIG, LEGACY_ESM_CONFIG, LEGACY_COMMONJS_CONFIG].includes(value);
|
|
74
|
+
}
|
|
32
75
|
function isNodeError(error) {
|
|
33
76
|
return error instanceof Error && 'code' in error;
|
|
34
77
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { bunRuntimePolicy } from '../../policy/bunRuntimePolicy.js';
|
|
2
|
+
import { bunRuntimePolicy, nodeRuntimePolicy } from '../../policy/bunRuntimePolicy.js';
|
|
3
3
|
const BUN_VERSION_TOKEN = '__ANKH_BUN_VERSION__';
|
|
4
|
+
const NODE_VERSION_TOKEN = '__ANKH_NODE_VERSION__';
|
|
4
5
|
export const workflowManagedFiles = [
|
|
5
6
|
createWorkflowDefinition('.github/workflows/ci.yml', './files/ci.yml'),
|
|
6
7
|
createWorkflowDefinition('.github/workflows/release.yml', './files/release.yml'),
|
|
@@ -11,7 +12,9 @@ function createWorkflowDefinition(relativePath, sourcePath) {
|
|
|
11
12
|
relativePath,
|
|
12
13
|
render: async () => {
|
|
13
14
|
const template = await readFile(sourceUrl, 'utf8');
|
|
14
|
-
return template
|
|
15
|
+
return template
|
|
16
|
+
.replaceAll(BUN_VERSION_TOKEN, bunRuntimePolicy.version)
|
|
17
|
+
.replaceAll(NODE_VERSION_TOKEN, nodeRuntimePolicy.setupVersion);
|
|
15
18
|
},
|
|
16
19
|
};
|
|
17
20
|
}
|
package/package.json
CHANGED