create-gtkx 2.0.0-beta.9 → 2.1.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.
- package/README.md +8 -166
- package/dependency-ranges.json +7 -0
- package/dist/build-allowance.d.ts +43 -2
- package/dist/build-allowance.d.ts.map +1 -1
- package/dist/build-allowance.js +360 -9
- package/dist/build-allowance.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/command.d.ts +3 -2
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +93 -90
- package/dist/command.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +2 -10
- package/dist/manifest.js.map +1 -1
- package/dist/package-managers.d.ts +6 -3
- package/dist/package-managers.d.ts.map +1 -1
- package/dist/package-managers.js +6 -3
- package/dist/package-managers.js.map +1 -1
- package/dist/project-name.d.ts +4 -2
- package/dist/project-name.d.ts.map +1 -1
- package/dist/project-name.js +12 -2
- package/dist/project-name.js.map +1 -1
- package/dist/scaffolder.d.ts.map +1 -1
- package/dist/scaffolder.js +199 -199
- package/dist/scaffolder.js.map +1 -1
- package/dist/templates/.claude/settings.json.ejs +4 -3
- package/dist/templates/.gitignore.ejs +4 -0
- package/dist/templates/.mcp.json.ejs +1 -1
- package/dist/templates/gtkx.config.ts.ejs +2 -2
- package/dist/templates/package.json.ejs +4 -1
- package/dist/templates/src/app.tsx.ejs +1 -1
- package/dist/templates/src/gtkx-env.d.ts.ejs +0 -1
- package/dist/templates/tsconfig.json.ejs +4 -2
- package/dist/templates.d.ts +3 -0
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +10 -6
- package/dist/templates.js.map +1 -1
- package/dist/workspace-mcp.d.ts +33 -0
- package/dist/workspace-mcp.d.ts.map +1 -0
- package/dist/workspace-mcp.js +75 -0
- package/dist/workspace-mcp.js.map +1 -0
- package/package.json +20 -39
- package/src/build-allowance.ts +486 -9
- package/src/cli.ts +1 -1
- package/src/command.ts +114 -110
- package/src/index.ts +1 -0
- package/src/manifest.ts +2 -10
- package/src/package-managers.ts +6 -3
- package/src/project-name.ts +19 -2
- package/src/scaffolder.ts +294 -286
- package/src/templates/.claude/settings.json.ejs +4 -3
- package/src/templates/.gitignore.ejs +4 -0
- package/src/templates/.mcp.json.ejs +1 -1
- package/src/templates/gtkx.config.ts.ejs +2 -2
- package/src/templates/package.json.ejs +4 -1
- package/src/templates/src/app.tsx.ejs +1 -1
- package/src/templates/src/gtkx-env.d.ts.ejs +0 -1
- package/src/templates/tsconfig.json.ejs +4 -2
- package/src/templates.ts +17 -8
- package/src/workspace-mcp.ts +111 -0
- package/dist/install-hints.d.ts +0 -3
- package/dist/install-hints.d.ts.map +0 -1
- package/dist/install-hints.js +0 -35
- package/dist/install-hints.js.map +0 -1
- package/src/install-hints.ts +0 -54
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
"allow": [
|
|
4
4
|
"Bash(npx gtkx codegen:*)",
|
|
5
5
|
"Bash(npx gtkx dev:*)",
|
|
6
|
-
"Bash(npx gtkx build:*)"
|
|
7
|
-
"Bash(npx tsc --noEmit)"<% if (shouldIncludeTesting) { %>,
|
|
8
|
-
"Bash(npx vitest run:*)"<% }
|
|
6
|
+
"Bash(npx gtkx build:*)"<% if (isTypescript) { %>,
|
|
7
|
+
"Bash(npx tsc --noEmit)"<% } %><% if (shouldIncludeTesting) { %>,
|
|
8
|
+
"Bash(npx vitest run:*)"<% } %><% for (const command of scriptCommands) { %>,
|
|
9
|
+
"Bash(<%= command %>:*)"<% } %>
|
|
9
10
|
],
|
|
10
11
|
"deny": [],
|
|
11
12
|
"ask": []
|
|
@@ -5,9 +5,9 @@ export default defineConfig({
|
|
|
5
5
|
applicationIcon: "data/icons",
|
|
6
6
|
deploy: {
|
|
7
7
|
name: <%- sourceStringLiteral(displayName) %>,
|
|
8
|
-
summary: "A
|
|
8
|
+
summary: "A Linux application built with GTKX",
|
|
9
9
|
description: [
|
|
10
|
-
<%- sourceStringLiteral(`${displayName} is
|
|
10
|
+
<%- sourceStringLiteral(`${displayName} is built with GTKX. Replace this paragraph with a description of what your application does.`) %>,
|
|
11
11
|
],
|
|
12
12
|
categories: ["Utility"],
|
|
13
13
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "<%= name %>",
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"private": true,
|
|
5
|
-
"description": "A
|
|
5
|
+
"description": "A Linux application built with GTKX",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
<% if (developerEmail) { -%>
|
|
8
8
|
"author": <%- sourceStringLiteral(`${developerName} <${developerEmail}>`) %>,
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"dev": "gtkx dev",
|
|
18
18
|
"build": "gtkx build",
|
|
19
19
|
"codegen": "gtkx codegen",
|
|
20
|
+
<% if (shouldIncludeTesting) { -%>
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
<% } -%>
|
|
20
23
|
<% if (isTypescript) { -%>
|
|
21
24
|
"typecheck": "gtkx codegen && tsc",
|
|
22
25
|
<% } -%>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"strict": true,
|
|
8
8
|
"skipLibCheck": true,
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
|
+
"allowArbitraryExtensions": true,
|
|
10
11
|
"lib": ["esnext"],
|
|
11
12
|
"types": ["node", "react"],
|
|
12
13
|
"noEmit": true,
|
|
@@ -15,9 +16,10 @@
|
|
|
15
16
|
"@gtkx/jsx/*": ["./node_modules/.gtkx/jsx/*/index.d.ts", "./node_modules/.gtkx/jsx/*.d.ts"]
|
|
16
17
|
}
|
|
17
18
|
},
|
|
19
|
+
"files": ["node_modules/.gtkx/env.d.ts"],
|
|
18
20
|
<% if (shouldIncludeTesting) { -%>
|
|
19
|
-
"include": ["src/**/*", "tests/**/*"]
|
|
21
|
+
"include": ["src/**/*", "tests/**/*", "gtkx.config.ts", "vitest.config.ts"]
|
|
20
22
|
<% } else { -%>
|
|
21
|
-
"include": ["src/**/*"]
|
|
23
|
+
"include": ["src/**/*", "gtkx.config.ts"]
|
|
22
24
|
<% } -%>
|
|
23
25
|
}
|
package/src/templates.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { sortStrings, sourceStringLiteral
|
|
1
|
+
import { sortStrings, sourceStringLiteral } from "@gtkx/utils";
|
|
2
|
+
import type { PackageManager } from "./package-managers.js";
|
|
2
3
|
import ejs from "ejs";
|
|
3
4
|
import { readdirSync } from "node:fs";
|
|
4
5
|
import { join } from "node:path";
|
|
@@ -12,18 +13,26 @@ type TemplateContext = {
|
|
|
12
13
|
importExtension: string;
|
|
13
14
|
developerName: string;
|
|
14
15
|
developerEmail: string | null;
|
|
16
|
+
packageManager: PackageManager;
|
|
17
|
+
scriptCommands: string[];
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
const TEMPLATES_DIR = join(import.meta.dirname, "templates");
|
|
18
21
|
|
|
22
|
+
// Yarn PnP reports relative `parentPath`s for recursive listings: https://github.com/yarnpkg/berry/issues/7315
|
|
23
|
+
const listFiles = (directory: string, prefix: string): string[] =>
|
|
24
|
+
readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
25
|
+
const relative = `${prefix}${entry.name}`;
|
|
26
|
+
|
|
27
|
+
if (entry.isDirectory()) {
|
|
28
|
+
return listFiles(join(directory, entry.name), `${relative}/`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return entry.isFile() ? [relative] : [];
|
|
32
|
+
});
|
|
33
|
+
|
|
19
34
|
const listTemplates = (): string[] =>
|
|
20
|
-
sortStrings(
|
|
21
|
-
readdirSync(TEMPLATES_DIR, { recursive: true, withFileTypes: true })
|
|
22
|
-
.filter((entry) => entry.isFile())
|
|
23
|
-
.map((entry) => join(entry.parentPath, entry.name))
|
|
24
|
-
.map((absolute) => toPosixPath(absolute.slice(TEMPLATES_DIR.length + 1)))
|
|
25
|
-
.map((relative) => relative.replace(/\.ejs$/, "")),
|
|
26
|
-
);
|
|
35
|
+
sortStrings(listFiles(TEMPLATES_DIR, "").map((relative) => relative.replace(/\.ejs$/, "")));
|
|
27
36
|
|
|
28
37
|
const renderFile = async (templateName: string, context: TemplateContext): Promise<string> =>
|
|
29
38
|
ejs.renderFile(join(TEMPLATES_DIR, `${templateName}.ejs`), { ...context, sourceStringLiteral });
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { errorMessage, indentOf } from "@gtkx/utils";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { isClassicYarn, type Workspace } from "./build-allowance.js";
|
|
6
|
+
import type { PackageManager } from "./package-managers.js";
|
|
7
|
+
|
|
8
|
+
type McpServer = { command: string; args: string[] };
|
|
9
|
+
|
|
10
|
+
type McpConfig = { config: Record<string, unknown>; indent: string };
|
|
11
|
+
|
|
12
|
+
type WorkspaceMcpResult =
|
|
13
|
+
| { kind: "added"; path: string; key: string }
|
|
14
|
+
| { kind: "present"; path: string; key: string }
|
|
15
|
+
| { kind: "shared"; path: string; key: string }
|
|
16
|
+
| { kind: "unreadable"; path: string; key: string; server: McpServer; reason: string };
|
|
17
|
+
|
|
18
|
+
const MCP_CONFIG_FILE = ".mcp.json";
|
|
19
|
+
const SERVERS_KEY = "mcpServers";
|
|
20
|
+
const SERVER_NAME = "gtkx";
|
|
21
|
+
const SERVER_COMMAND = ["gtkx", "mcp"];
|
|
22
|
+
const JSON_INDENT = " ";
|
|
23
|
+
|
|
24
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
25
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
|
|
27
|
+
const yarnServer = (workspace: Workspace, name: string): McpServer =>
|
|
28
|
+
isClassicYarn(workspace.root)
|
|
29
|
+
? { command: "yarn", args: ["--silent", "--cwd", workspace.member, ...SERVER_COMMAND] }
|
|
30
|
+
: { command: "yarn", args: ["workspace", name, "exec", ...SERVER_COMMAND] };
|
|
31
|
+
|
|
32
|
+
const WORKSPACE_SERVERS: Record<PackageManager, (workspace: Workspace, name: string) => McpServer> = {
|
|
33
|
+
pnpm: ({ member }) => ({ command: "pnpm", args: ["--dir", member, "exec", ...SERVER_COMMAND] }),
|
|
34
|
+
npm: ({ member }) => ({ command: "npm", args: ["exec", "--no", "--workspace", member, "--", ...SERVER_COMMAND] }),
|
|
35
|
+
yarn: yarnServer,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const readConfig = (path: string): McpConfig => {
|
|
39
|
+
let source: string;
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
source = readFileSync(path, "utf8");
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
45
|
+
return { config: {}, indent: JSON_INDENT };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const config: unknown = JSON.parse(source);
|
|
52
|
+
|
|
53
|
+
if (!isRecord(config) || (Object.hasOwn(config, SERVERS_KEY) && !isRecord(config[SERVERS_KEY]))) {
|
|
54
|
+
throw new Error(`its contents are not an object with an object "${SERVERS_KEY}"`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { config, indent: indentOf(source, JSON_INDENT) };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const isGtkxServer = (key: string, server: unknown): boolean => {
|
|
61
|
+
if (key === SERVER_NAME) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const args = isRecord(server) && Array.isArray(server.args) ? server.args : [];
|
|
66
|
+
|
|
67
|
+
return isDeepStrictEqual(args.slice(-SERVER_COMMAND.length), SERVER_COMMAND);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Adds a server that starts the app's own `gtkx mcp` through the workspace's package manager to the
|
|
72
|
+
* workspace root's `.mcp.json`, where AI clients opened at the repository root look for it. Other servers and
|
|
73
|
+
* the file's indentation stay. When the file already has a GTKX server, such as an earlier app's, no second one
|
|
74
|
+
* is added: the GTKX servers of a session share one socket, and that server drives every running app.
|
|
75
|
+
*/
|
|
76
|
+
const addWorkspaceMcpServer = (workspace: Workspace, name: string): WorkspaceMcpResult => {
|
|
77
|
+
const path = join(workspace.root, MCP_CONFIG_FILE);
|
|
78
|
+
const server = WORKSPACE_SERVERS[workspace.packageManager](workspace, name);
|
|
79
|
+
let document: McpConfig;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
document = readConfig(path);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return { kind: "unreadable", path, key: SERVER_NAME, server, reason: errorMessage(error) };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const { config, indent } = document;
|
|
88
|
+
|
|
89
|
+
const servers = isRecord(config[SERVERS_KEY]) ? config[SERVERS_KEY] : {};
|
|
90
|
+
const keys = Object.keys(servers);
|
|
91
|
+
const present = keys.find((key) => isDeepStrictEqual(servers[key], server));
|
|
92
|
+
|
|
93
|
+
if (present !== undefined) {
|
|
94
|
+
return { kind: "present", path, key: present };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const shared = keys.find((key) => isGtkxServer(key, servers[key]));
|
|
98
|
+
|
|
99
|
+
if (shared !== undefined) {
|
|
100
|
+
return { kind: "shared", path, key: shared };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
writeFileSync(
|
|
104
|
+
path,
|
|
105
|
+
`${JSON.stringify({ ...config, [SERVERS_KEY]: { ...servers, [SERVER_NAME]: server } }, null, indent)}\n`,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return { kind: "added", path, key: SERVER_NAME };
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { addWorkspaceMcpServer };
|
package/dist/install-hints.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install-hints.d.ts","sourceRoot":"","sources":["../src/install-hints.ts"],"names":[],"mappings":"AAkDA,QAAA,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,SAC4B,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/install-hints.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const RELEASE_AGE_PATTERN = /ERR_PNPM_(?:MINIMUM_RELEASE_AGE_VIOLATION|NO_MATURE_MATCHING_VERSION)/;
|
|
2
|
-
const BLOCKED_VERSION_PATTERN = /^[ \t]*(\S+) was published at .+ within the minimumReleaseAge cutoff/gm;
|
|
3
|
-
const RELEASE_AGE_POLICY = "pnpm refused the install under its minimumReleaseAge policy, which by default holds back every package " +
|
|
4
|
-
"published in the last 24 hours so a compromised release has time to be caught and pulled. Nothing is wrong " +
|
|
5
|
-
"with these versions other than their age.";
|
|
6
|
-
const RELEASE_AGE_REMEDY = "Wait for them to clear that window and install again, or allow the versions pnpm named. They belong at the " +
|
|
7
|
-
"top level of pnpm-workspace.yaml, as a sibling of packages: and allowBuilds: rather than nested inside " +
|
|
8
|
-
"either of them:";
|
|
9
|
-
const RELEASE_AGE_REMEDY_WITHOUT_VERSIONS = "Wait for them to clear that window and install again, or list the versions pnpm reported under a top-level " +
|
|
10
|
-
"minimumReleaseAgeExclude key in pnpm-workspace.yaml.";
|
|
11
|
-
const RELEASE_AGE_PARTIAL_LIST = "pnpm reports only the versions the command it stopped on had to resolve, so a later install can name more. " +
|
|
12
|
-
"Add each one to the same list.";
|
|
13
|
-
const RELEASE_AGE_OPT_OUT = 'Listing exact versions keeps the policy on for every other package. Setting "minimumReleaseAge: 0" in the ' +
|
|
14
|
-
"same file turns it off for all of them, so prefer the list above. npm and yarn apply no such policy.";
|
|
15
|
-
const getBlockedVersions = (message) => {
|
|
16
|
-
const matches = Array.from(message.matchAll(BLOCKED_VERSION_PATTERN), (match) => match[1] ?? "");
|
|
17
|
-
return [...new Set(matches.filter(Boolean))];
|
|
18
|
-
};
|
|
19
|
-
const formatExcludeBlock = (versions) => ["minimumReleaseAgeExclude:", ...versions.map((version) => ` - '${version}'`)].join("\n");
|
|
20
|
-
const describeReleaseAge = (message) => {
|
|
21
|
-
const versions = getBlockedVersions(message);
|
|
22
|
-
if (versions.length === 0) {
|
|
23
|
-
return [RELEASE_AGE_POLICY, RELEASE_AGE_REMEDY_WITHOUT_VERSIONS].join("\n\n");
|
|
24
|
-
}
|
|
25
|
-
return [
|
|
26
|
-
RELEASE_AGE_POLICY,
|
|
27
|
-
RELEASE_AGE_REMEDY,
|
|
28
|
-
formatExcludeBlock(versions),
|
|
29
|
-
RELEASE_AGE_PARTIAL_LIST,
|
|
30
|
-
RELEASE_AGE_OPT_OUT,
|
|
31
|
-
].join("\n\n");
|
|
32
|
-
};
|
|
33
|
-
const getInstallHint = (message) => RELEASE_AGE_PATTERN.test(message) ? describeReleaseAge(message) : undefined;
|
|
34
|
-
export { getInstallHint };
|
|
35
|
-
//# sourceMappingURL=install-hints.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install-hints.js","sourceRoot":"","sources":["../src/install-hints.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG,uEAAuE,CAAC;AACpG,MAAM,uBAAuB,GAAG,wEAAwE,CAAC;AAEzG,MAAM,kBAAkB,GACpB,yGAAyG;IACzG,6GAA6G;IAC7G,2CAA2C,CAAC;AAEhD,MAAM,kBAAkB,GACpB,6GAA6G;IAC7G,yGAAyG;IACzG,iBAAiB,CAAC;AAEtB,MAAM,mCAAmC,GACrC,6GAA6G;IAC7G,sDAAsD,CAAC;AAE3D,MAAM,wBAAwB,GAC1B,6GAA6G;IAC7G,gCAAgC,CAAC;AAErC,MAAM,mBAAmB,GACrB,4GAA4G;IAC5G,sGAAsG,CAAC;AAE3G,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAY,EAAE;IACrD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjG,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,QAAkB,EAAU,EAAE,CACtD,CAAC,2BAA2B,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE/F,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAU,EAAE;IACnD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAE7C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,kBAAkB,EAAE,mCAAmC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClF,CAAC;IAED,OAAO;QACH,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB,CAAC,QAAQ,CAAC;QAC5B,wBAAwB;QACxB,mBAAmB;KACtB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,OAAe,EAAsB,EAAE,CAC3D,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["const RELEASE_AGE_PATTERN = /ERR_PNPM_(?:MINIMUM_RELEASE_AGE_VIOLATION|NO_MATURE_MATCHING_VERSION)/;\nconst BLOCKED_VERSION_PATTERN = /^[ \\t]*(\\S+) was published at .+ within the minimumReleaseAge cutoff/gm;\n\nconst RELEASE_AGE_POLICY =\n \"pnpm refused the install under its minimumReleaseAge policy, which by default holds back every package \" +\n \"published in the last 24 hours so a compromised release has time to be caught and pulled. Nothing is wrong \" +\n \"with these versions other than their age.\";\n\nconst RELEASE_AGE_REMEDY =\n \"Wait for them to clear that window and install again, or allow the versions pnpm named. They belong at the \" +\n \"top level of pnpm-workspace.yaml, as a sibling of packages: and allowBuilds: rather than nested inside \" +\n \"either of them:\";\n\nconst RELEASE_AGE_REMEDY_WITHOUT_VERSIONS =\n \"Wait for them to clear that window and install again, or list the versions pnpm reported under a top-level \" +\n \"minimumReleaseAgeExclude key in pnpm-workspace.yaml.\";\n\nconst RELEASE_AGE_PARTIAL_LIST =\n \"pnpm reports only the versions the command it stopped on had to resolve, so a later install can name more. \" +\n \"Add each one to the same list.\";\n\nconst RELEASE_AGE_OPT_OUT =\n 'Listing exact versions keeps the policy on for every other package. Setting \"minimumReleaseAge: 0\" in the ' +\n \"same file turns it off for all of them, so prefer the list above. npm and yarn apply no such policy.\";\n\nconst getBlockedVersions = (message: string): string[] => {\n const matches = Array.from(message.matchAll(BLOCKED_VERSION_PATTERN), (match) => match[1] ?? \"\");\n\n return [...new Set(matches.filter(Boolean))];\n};\n\nconst formatExcludeBlock = (versions: string[]): string =>\n [\"minimumReleaseAgeExclude:\", ...versions.map((version) => ` - '${version}'`)].join(\"\\n\");\n\nconst describeReleaseAge = (message: string): string => {\n const versions = getBlockedVersions(message);\n\n if (versions.length === 0) {\n return [RELEASE_AGE_POLICY, RELEASE_AGE_REMEDY_WITHOUT_VERSIONS].join(\"\\n\\n\");\n }\n\n return [\n RELEASE_AGE_POLICY,\n RELEASE_AGE_REMEDY,\n formatExcludeBlock(versions),\n RELEASE_AGE_PARTIAL_LIST,\n RELEASE_AGE_OPT_OUT,\n ].join(\"\\n\\n\");\n};\n\nconst getInstallHint = (message: string): string | undefined =>\n RELEASE_AGE_PATTERN.test(message) ? describeReleaseAge(message) : undefined;\n\nexport { getInstallHint };\n"]}
|
package/src/install-hints.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const RELEASE_AGE_PATTERN = /ERR_PNPM_(?:MINIMUM_RELEASE_AGE_VIOLATION|NO_MATURE_MATCHING_VERSION)/;
|
|
2
|
-
const BLOCKED_VERSION_PATTERN = /^[ \t]*(\S+) was published at .+ within the minimumReleaseAge cutoff/gm;
|
|
3
|
-
|
|
4
|
-
const RELEASE_AGE_POLICY =
|
|
5
|
-
"pnpm refused the install under its minimumReleaseAge policy, which by default holds back every package " +
|
|
6
|
-
"published in the last 24 hours so a compromised release has time to be caught and pulled. Nothing is wrong " +
|
|
7
|
-
"with these versions other than their age.";
|
|
8
|
-
|
|
9
|
-
const RELEASE_AGE_REMEDY =
|
|
10
|
-
"Wait for them to clear that window and install again, or allow the versions pnpm named. They belong at the " +
|
|
11
|
-
"top level of pnpm-workspace.yaml, as a sibling of packages: and allowBuilds: rather than nested inside " +
|
|
12
|
-
"either of them:";
|
|
13
|
-
|
|
14
|
-
const RELEASE_AGE_REMEDY_WITHOUT_VERSIONS =
|
|
15
|
-
"Wait for them to clear that window and install again, or list the versions pnpm reported under a top-level " +
|
|
16
|
-
"minimumReleaseAgeExclude key in pnpm-workspace.yaml.";
|
|
17
|
-
|
|
18
|
-
const RELEASE_AGE_PARTIAL_LIST =
|
|
19
|
-
"pnpm reports only the versions the command it stopped on had to resolve, so a later install can name more. " +
|
|
20
|
-
"Add each one to the same list.";
|
|
21
|
-
|
|
22
|
-
const RELEASE_AGE_OPT_OUT =
|
|
23
|
-
'Listing exact versions keeps the policy on for every other package. Setting "minimumReleaseAge: 0" in the ' +
|
|
24
|
-
"same file turns it off for all of them, so prefer the list above. npm and yarn apply no such policy.";
|
|
25
|
-
|
|
26
|
-
const getBlockedVersions = (message: string): string[] => {
|
|
27
|
-
const matches = Array.from(message.matchAll(BLOCKED_VERSION_PATTERN), (match) => match[1] ?? "");
|
|
28
|
-
|
|
29
|
-
return [...new Set(matches.filter(Boolean))];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const formatExcludeBlock = (versions: string[]): string =>
|
|
33
|
-
["minimumReleaseAgeExclude:", ...versions.map((version) => ` - '${version}'`)].join("\n");
|
|
34
|
-
|
|
35
|
-
const describeReleaseAge = (message: string): string => {
|
|
36
|
-
const versions = getBlockedVersions(message);
|
|
37
|
-
|
|
38
|
-
if (versions.length === 0) {
|
|
39
|
-
return [RELEASE_AGE_POLICY, RELEASE_AGE_REMEDY_WITHOUT_VERSIONS].join("\n\n");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return [
|
|
43
|
-
RELEASE_AGE_POLICY,
|
|
44
|
-
RELEASE_AGE_REMEDY,
|
|
45
|
-
formatExcludeBlock(versions),
|
|
46
|
-
RELEASE_AGE_PARTIAL_LIST,
|
|
47
|
-
RELEASE_AGE_OPT_OUT,
|
|
48
|
-
].join("\n\n");
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const getInstallHint = (message: string): string | undefined =>
|
|
52
|
-
RELEASE_AGE_PATTERN.test(message) ? describeReleaseAge(message) : undefined;
|
|
53
|
-
|
|
54
|
-
export { getInstallHint };
|