@steambrew/ttc 2.8.7 → 3.0.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/.prettierrc +9 -9
- package/bun.lock +680 -0
- package/dist/index.js +310 -460
- package/package.json +55 -54
- package/rollup.config.js +22 -22
- package/src/check-health.ts +53 -54
- package/src/index.ts +53 -61
- package/src/logger.ts +49 -46
- package/src/plugin-api.ts +77 -263
- package/src/query-parser.ts +83 -89
- package/src/static-embed.ts +274 -281
- package/src/transpiler.ts +303 -334
- package/src/version-control.ts +53 -31
- package/tsconfig.json +23 -23
- package/pnpm-workspace.yaml +0 -2
package/src/version-control.ts
CHANGED
|
@@ -1,31 +1,53 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { readFile } from 'fs/promises';
|
|
4
|
-
import { dirname } from 'path';
|
|
5
|
-
import { Logger } from './logger';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { readFile, access } from 'fs/promises';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
import { Logger } from './logger';
|
|
6
|
+
|
|
7
|
+
async function fileExists(filePath: string): Promise<boolean> {
|
|
8
|
+
return access(filePath).then(() => true).catch(() => false);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function detectPackageManager(): Promise<string> {
|
|
12
|
+
const userAgent = process.env.npm_config_user_agent ?? '';
|
|
13
|
+
if (userAgent.startsWith('bun')) return 'bun';
|
|
14
|
+
if (userAgent.startsWith('pnpm')) return 'pnpm';
|
|
15
|
+
if (userAgent.startsWith('yarn')) return 'yarn';
|
|
16
|
+
|
|
17
|
+
const cwd = process.cwd();
|
|
18
|
+
if (await fileExists(path.join(cwd, 'bun.lock')) || await fileExists(path.join(cwd, 'bun.lockb'))) return 'bun';
|
|
19
|
+
if (await fileExists(path.join(cwd, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
20
|
+
if (await fileExists(path.join(cwd, 'yarn.lock'))) return 'yarn';
|
|
21
|
+
|
|
22
|
+
return 'npm';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function installCommand(pm: string, pkg: string): string {
|
|
26
|
+
switch (pm) {
|
|
27
|
+
case 'bun': return `bun add -d ${pkg}`;
|
|
28
|
+
case 'pnpm': return `pnpm add -D ${pkg}`;
|
|
29
|
+
case 'yarn': return `yarn add -D ${pkg}`;
|
|
30
|
+
default: return `npm i -D ${pkg}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const CheckForUpdates = async (): Promise<boolean> => {
|
|
35
|
+
try {
|
|
36
|
+
const packageJsonPath = path.resolve(dirname(fileURLToPath(import.meta.url)), '../package.json');
|
|
37
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8'));
|
|
38
|
+
|
|
39
|
+
const response = await fetch('https://registry.npmjs.org/@steambrew/ttc');
|
|
40
|
+
const json = await response.json();
|
|
41
|
+
const latest = json?.['dist-tags']?.latest;
|
|
42
|
+
|
|
43
|
+
if (latest && latest !== packageJson.version) {
|
|
44
|
+
const pm = await detectPackageManager();
|
|
45
|
+
Logger.update(packageJson.version, latest, installCommand(pm, `@steambrew/ttc@${latest}`));
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
// network or parse failure — silently skip
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return false;
|
|
53
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "dist",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"target": "ES2020",
|
|
6
|
-
"jsx": "react",
|
|
7
|
-
"jsxFactory": "window.SP_REACT.createElement",
|
|
8
|
-
"declaration": false,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"noUnusedLocals": true,
|
|
11
|
-
"noUnusedParameters": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"noImplicitReturns": true,
|
|
14
|
-
"noImplicitThis": true,
|
|
15
|
-
"noImplicitAny": true,
|
|
16
|
-
"strict": true,
|
|
17
|
-
"ignoreDeprecations": "5.0",
|
|
18
|
-
"allowSyntheticDefaultImports": true,
|
|
19
|
-
"skipLibCheck": true
|
|
20
|
-
},
|
|
21
|
-
"include": ["./src/**/*"],
|
|
22
|
-
"exclude": ["node_modules"]
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"jsxFactory": "window.SP_REACT.createElement",
|
|
8
|
+
"declaration": false,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"noUnusedParameters": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"noImplicitReturns": true,
|
|
14
|
+
"noImplicitThis": true,
|
|
15
|
+
"noImplicitAny": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"ignoreDeprecations": "5.0",
|
|
18
|
+
"allowSyntheticDefaultImports": true,
|
|
19
|
+
"skipLibCheck": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["./src/**/*"],
|
|
22
|
+
"exclude": ["node_modules"]
|
|
23
|
+
}
|
package/pnpm-workspace.yaml
DELETED