@ankhorage/devtools 1.15.1 → 1.15.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.
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/devtools
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Shared tooling, repository automation, runtime policies, and agent standards for Ankhorage TypeScript projects
|
|
9
9
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/*** Defines the Prettier files and ignore policy managed for consuming repositories. */
|
|
1
2
|
export declare const prettierManagedFiles: readonly [{
|
|
2
3
|
readonly relativePath: "prettier.local.config.js";
|
|
3
4
|
readonly render: typeof renderInitialLocalConfig;
|
|
@@ -5,7 +6,14 @@ export declare const prettierManagedFiles: readonly [{
|
|
|
5
6
|
}, {
|
|
6
7
|
readonly relativePath: ".prettierrc.js";
|
|
7
8
|
readonly render: typeof renderPrettierConfig;
|
|
9
|
+
}, {
|
|
10
|
+
readonly relativePath: ".prettierignore";
|
|
11
|
+
readonly render: typeof renderPrettierIgnore;
|
|
8
12
|
}];
|
|
13
|
+
/*** Renders the shared Prettier wrapper for the target package module type. */
|
|
9
14
|
declare function renderPrettierConfig(targetDirectory: string): Promise<string>;
|
|
15
|
+
/*** Preserves an existing repository Prettier config as its initial local extension. */
|
|
10
16
|
declare function renderInitialLocalConfig(targetDirectory: string): Promise<string>;
|
|
17
|
+
/*** Preserves repository-owned ignore entries while appending required generated-artifact ignores. */
|
|
18
|
+
declare function renderPrettierIgnore(targetDirectory: string): Promise<string>;
|
|
11
19
|
export {};
|
|
@@ -26,6 +26,8 @@ const LEGACY_ESM_CONFIG = `export { default } from '@ankhorage/devtools/prettier
|
|
|
26
26
|
`;
|
|
27
27
|
const LEGACY_COMMONJS_CONFIG = `module.exports = require('@ankhorage/devtools/prettier');
|
|
28
28
|
`;
|
|
29
|
+
const REQUIRED_PRETTIER_IGNORE_ENTRIES = ['node_modules', 'dist', 'README.md', 'paradox/'];
|
|
30
|
+
/*** Defines the Prettier files and ignore policy managed for consuming repositories. */
|
|
29
31
|
export const prettierManagedFiles = [
|
|
30
32
|
{
|
|
31
33
|
relativePath: 'prettier.local.config.js',
|
|
@@ -36,10 +38,16 @@ export const prettierManagedFiles = [
|
|
|
36
38
|
relativePath: '.prettierrc.js',
|
|
37
39
|
render: renderPrettierConfig,
|
|
38
40
|
},
|
|
41
|
+
{
|
|
42
|
+
relativePath: '.prettierignore',
|
|
43
|
+
render: renderPrettierIgnore,
|
|
44
|
+
},
|
|
39
45
|
];
|
|
46
|
+
/*** Renders the shared Prettier wrapper for the target package module type. */
|
|
40
47
|
async function renderPrettierConfig(targetDirectory) {
|
|
41
48
|
return (await readPackageType(targetDirectory)) === 'module' ? ESM_CONFIG : COMMONJS_CONFIG;
|
|
42
49
|
}
|
|
50
|
+
/*** Preserves an existing repository Prettier config as its initial local extension. */
|
|
43
51
|
async function renderInitialLocalConfig(targetDirectory) {
|
|
44
52
|
const isModule = (await readPackageType(targetDirectory)) === 'module';
|
|
45
53
|
try {
|
|
@@ -53,6 +61,25 @@ async function renderInitialLocalConfig(targetDirectory) {
|
|
|
53
61
|
}
|
|
54
62
|
return isModule ? EMPTY_ESM_LOCAL_CONFIG : EMPTY_COMMONJS_LOCAL_CONFIG;
|
|
55
63
|
}
|
|
64
|
+
/*** Preserves repository-owned ignore entries while appending required generated-artifact ignores. */
|
|
65
|
+
async function renderPrettierIgnore(targetDirectory) {
|
|
66
|
+
const existing = await readFile(resolve(targetDirectory, '.prettierignore'), 'utf8').catch((error) => {
|
|
67
|
+
if (isNodeError(error) && error.code === 'ENOENT')
|
|
68
|
+
return '';
|
|
69
|
+
throw error;
|
|
70
|
+
});
|
|
71
|
+
const existingEntries = new Set(existing
|
|
72
|
+
.split(/\r?\n/u)
|
|
73
|
+
.map((line) => line.trim())
|
|
74
|
+
.filter((line) => line !== '' && !line.startsWith('#')));
|
|
75
|
+
const missingEntries = REQUIRED_PRETTIER_IGNORE_ENTRIES.filter((entry) => !existingEntries.has(entry));
|
|
76
|
+
if (missingEntries.length === 0) {
|
|
77
|
+
return existing.endsWith('\n') ? existing : `${existing}\n`;
|
|
78
|
+
}
|
|
79
|
+
const prefix = existing === '' ? '' : existing.endsWith('\n') ? existing : `${existing}\n`;
|
|
80
|
+
return `${prefix}${missingEntries.join('\n')}\n`;
|
|
81
|
+
}
|
|
82
|
+
/*** Reads whether the target package uses ESM or CommonJS package semantics. */
|
|
56
83
|
async function readPackageType(targetDirectory) {
|
|
57
84
|
try {
|
|
58
85
|
const contents = await readFile(resolve(targetDirectory, 'package.json'), 'utf8');
|
|
@@ -66,12 +93,15 @@ async function readPackageType(targetDirectory) {
|
|
|
66
93
|
throw error;
|
|
67
94
|
}
|
|
68
95
|
}
|
|
96
|
+
/*** Narrows an unknown JSON value to a non-array record. */
|
|
69
97
|
function isRecord(value) {
|
|
70
98
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
71
99
|
}
|
|
100
|
+
/*** Identifies Prettier wrappers that contain no repository-owned configuration. */
|
|
72
101
|
function isSharedOnlyConfig(value) {
|
|
73
102
|
return [ESM_CONFIG, COMMONJS_CONFIG, LEGACY_ESM_CONFIG, LEGACY_COMMONJS_CONFIG].includes(value);
|
|
74
103
|
}
|
|
104
|
+
/*** Narrows an unknown error to a Node error carrying an error code. */
|
|
75
105
|
function isNodeError(error) {
|
|
76
106
|
return error instanceof Error && 'code' in error;
|
|
77
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/devtools",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"description": "Shared tooling, repository automation, runtime policies, and agent standards for Ankhorage TypeScript projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/devtools#readme",
|
|
@@ -49,14 +49,15 @@
|
|
|
49
49
|
"renovateSyncProtocol": 1
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
|
-
"
|
|
52
|
+
"ankhorage",
|
|
53
|
+
"developer-tools",
|
|
53
54
|
"eslint",
|
|
54
|
-
"prettier",
|
|
55
|
-
"knip",
|
|
56
55
|
"github-actions",
|
|
57
|
-
"
|
|
56
|
+
"knip",
|
|
57
|
+
"prettier",
|
|
58
58
|
"repository-sync",
|
|
59
|
-
"
|
|
59
|
+
"typescript",
|
|
60
|
+
"vscode"
|
|
60
61
|
],
|
|
61
62
|
"bin": {
|
|
62
63
|
"ankhorage-changeset": "./dist/cli/bin/changeset.js",
|