crankscript 0.2.0 → 0.4.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/package.json +5 -2
- package/src/commands/DoctorCommand.js +1 -1
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +2 -2
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +3 -3
- package/src/commands/EnvironmentAwareCommand/components/HealthReport.d.ts +1 -1
- package/src/commands/EnvironmentAwareCommand/components/HealthReport.js +1 -1
- package/src/commands/GenerateTypes/GenerateTypesCommand.d.ts +2 -2
- package/src/commands/GenerateTypes/GenerateTypesCommand.js +5 -3
- package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -1
- package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +2 -1
- package/src/commands/GenerateTypes/components/GenerateTypes.js +24 -3
- package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
- package/src/commands/GenerateTypes/constants.d.ts +1 -0
- package/src/commands/GenerateTypes/constants.js +3 -0
- package/src/commands/GenerateTypes/constants.js.map +1 -0
- package/src/commands/GenerateTypes/fn/getHtmlForVersion.d.ts +1 -0
- package/src/commands/GenerateTypes/fn/getHtmlForVersion.js +21 -0
- package/src/commands/GenerateTypes/fn/getHtmlForVersion.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useFetchHtml.d.ts +12 -0
- package/src/commands/GenerateTypes/hooks/useFetchHtml.js +31 -0
- package/src/commands/GenerateTypes/hooks/useFetchHtml.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.d.ts +10 -0
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +34 -0
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +12 -0
- package/src/commands/GenerateTypes/hooks/useGetVersion.js +48 -0
- package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -0
- package/src/components/CheckList/CheckList.d.ts +8 -0
- package/src/components/CheckList/CheckList.js +35 -0
- package/src/components/CheckList/CheckList.js.map +1 -0
- package/src/components/CheckList/Item.d.ts +7 -0
- package/src/components/CheckList/Item.js +102 -0
- package/src/components/CheckList/Item.js.map +1 -0
- package/src/components/CheckList/index.d.ts +1 -0
- package/src/components/CheckList/index.js +3 -0
- package/src/components/CheckList/index.js.map +1 -0
- package/src/environment/configuration/ConfigurationSchema.d.ts +1 -1
- package/src/environment/configuration/ConfigurationSchema.js +4 -1
- package/src/environment/configuration/ConfigurationSchema.js.map +1 -1
- package/src/environment/createEnvironment.js +1 -1
- package/src/environment/createEnvironment.js.map +1 -1
- package/src/hooks/useQuitOnCtrlC.d.ts +1 -0
- package/src/hooks/useQuitOnCtrlC.js +10 -0
- package/src/hooks/useQuitOnCtrlC.js.map +1 -0
- package/src/index.js +3 -3
- package/src/types.d.ts +12 -2
- package/src/types.js +1 -0
- package/src/types.js.map +1 -1
package/package.json
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "crankscript",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.0",
|
4
4
|
"scripts": {
|
5
|
-
"dev": "tsx src/index.ts"
|
5
|
+
"dev": "tsx src/index.ts",
|
6
|
+
"post-build": "tsc-alias --project tsconfig.json"
|
6
7
|
},
|
7
8
|
"bin": {
|
8
9
|
"crankscript": "./src/index.js"
|
@@ -11,9 +12,11 @@
|
|
11
12
|
"dependencies": {
|
12
13
|
"@inkjs/ui": "^2.0.0",
|
13
14
|
"@swc/helpers": "~0.5.11",
|
15
|
+
"cheerio": "^1.0.0",
|
14
16
|
"clipanion": "^4.0.0-rc.4",
|
15
17
|
"ink": "^5.0.1",
|
16
18
|
"react": "^18.3.1",
|
19
|
+
"ts-morph": "^23.0.0",
|
17
20
|
"typanion": "^3.14.0",
|
18
21
|
"zod": "^3.23.8"
|
19
22
|
},
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Command } from 'clipanion';
|
2
2
|
import { Text } from 'ink';
|
3
3
|
import React from 'react';
|
4
|
-
import { createEnvironment } from '
|
4
|
+
import { createEnvironment } from '../environment/createEnvironment.js';
|
5
5
|
import { HealthReport } from './EnvironmentAwareCommand/components/HealthReport.js';
|
6
6
|
import { RenderableCommand } from './RenderableCommand.js';
|
7
7
|
export class DoctorCommand extends RenderableCommand {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { JSX } from 'react';
|
2
|
-
import { RenderableCommand } from '
|
3
|
-
import { Environment } from '
|
2
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
3
|
+
import { Environment } from '../../environment/dto/Environment.js';
|
4
4
|
export declare abstract class EnvironmentAwareCommand extends RenderableCommand {
|
5
5
|
private environment;
|
6
6
|
protected abstract renderWithEnvironment(environment: Environment): JSX.Element;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { HealthReport } from '
|
3
|
-
import { RenderableCommand } from '
|
4
|
-
import { createEnvironment } from '
|
2
|
+
import { HealthReport } from '../../commands/EnvironmentAwareCommand/components/HealthReport.js';
|
3
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
4
|
+
import { createEnvironment } from '../../environment/createEnvironment.js';
|
5
5
|
export class EnvironmentAwareCommand extends RenderableCommand {
|
6
6
|
render() {
|
7
7
|
if (!this.environment) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { StatusMessage } from '@inkjs/ui';
|
2
2
|
import { Text } from 'ink';
|
3
3
|
import React from 'react';
|
4
|
-
import { HealthCheckStatus } from '
|
4
|
+
import { HealthCheckStatus } from '../../../types.js';
|
5
5
|
const SuccessMessages = {
|
6
6
|
configurationFilePresent: {
|
7
7
|
[HealthCheckStatus.Unknown]: 'Configuration file status unknown',
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { EnvironmentAwareCommand } from '
|
3
|
-
import { Environment } from '
|
2
|
+
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
3
|
+
import { Environment } from '../../environment/dto/Environment.js';
|
4
4
|
export declare class GenerateTypesCommand extends EnvironmentAwareCommand {
|
5
5
|
static paths: string[][];
|
6
6
|
static usage: import("clipanion").Usage;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Command, Option } from 'clipanion';
|
2
2
|
import React from 'react';
|
3
3
|
import * as t from 'typanion';
|
4
|
-
import { EnvironmentAwareCommand } from '
|
5
|
-
import { PlaydateSdkVersionIdentifier } from '
|
4
|
+
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
5
|
+
import { PlaydateSdkVersionIdentifier } from '../../types.js';
|
6
6
|
import { GenerateTypes } from './components/GenerateTypes.js';
|
7
7
|
export class GenerateTypesCommand extends EnvironmentAwareCommand {
|
8
8
|
renderWithEnvironment(environment) {
|
@@ -12,10 +12,12 @@ export class GenerateTypesCommand extends EnvironmentAwareCommand {
|
|
12
12
|
}
|
13
13
|
constructor(...args){
|
14
14
|
super(...args);
|
15
|
-
this.version = Option.String('-
|
15
|
+
this.version = Option.String('-s,--sdk-version', PlaydateSdkVersionIdentifier.FromConfig, {
|
16
|
+
tolerateBoolean: false,
|
16
17
|
description: 'The version',
|
17
18
|
validator: t.isOneOf([
|
18
19
|
t.isLiteral(PlaydateSdkVersionIdentifier.FromConfig),
|
20
|
+
t.isLiteral(PlaydateSdkVersionIdentifier.Latest),
|
19
21
|
t.matchesRegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
20
22
|
])
|
21
23
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/GenerateTypesCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { AnyStrictValidator } from 'typanion';\nimport { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkVersionIdentifier } from '@/cli/types.js';\nimport { GenerateTypes } from './components/GenerateTypes.js';\n\nexport class GenerateTypesCommand extends EnvironmentAwareCommand {\n static override paths = [['generate-types']];\n static override usage = Command.Usage({\n description: 'Generate types from the Playdate SDK documentation',\n });\n\n version = Option.String(\n '-
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/GenerateTypesCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { AnyStrictValidator } from 'typanion';\nimport { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkVersionIdentifier } from '@/cli/types.js';\nimport { GenerateTypes } from './components/GenerateTypes.js';\n\nexport class GenerateTypesCommand extends EnvironmentAwareCommand {\n static override paths = [['generate-types']];\n static override usage = Command.Usage({\n description: 'Generate types from the Playdate SDK documentation',\n });\n\n version = Option.String(\n '-s,--sdk-version',\n PlaydateSdkVersionIdentifier.FromConfig,\n {\n tolerateBoolean: false,\n description: 'The version',\n validator: t.isOneOf([\n t.isLiteral(PlaydateSdkVersionIdentifier.FromConfig),\n t.isLiteral(PlaydateSdkVersionIdentifier.Latest),\n t.matchesRegExp(\n /^[0-9]+\\.[0-9]+\\.[0-9]+$/\n ) as AnyStrictValidator,\n ]),\n }\n );\n\n override renderWithEnvironment(environment: Environment) {\n return (\n <GenerateTypes\n version={\n this.version === PlaydateSdkVersionIdentifier.FromConfig\n ? environment.configuration.version\n : this.version\n }\n />\n );\n }\n}\n"],"names":["Command","Option","React","t","EnvironmentAwareCommand","PlaydateSdkVersionIdentifier","GenerateTypes","GenerateTypesCommand","renderWithEnvironment","environment","version","FromConfig","configuration","String","tolerateBoolean","description","validator","isOneOf","isLiteral","Latest","matchesRegExp","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAE9B,SAASC,uBAAuB,QAAQ,kDAAkD;AAE1F,SAASC,4BAA4B,QAAQ,iBAAiB;AAC9D,SAASC,aAAa,QAAQ,gCAAgC;AAE9D,OAAO,MAAMC,6BAA6BH;IAsB7BI,sBAAsBC,WAAwB,EAAE;QACrD,qBACI,oBAACH;YACGI,SACI,IAAI,CAACA,OAAO,KAAKL,6BAA6BM,UAAU,GAClDF,YAAYG,aAAa,CAACF,OAAO,GACjC,IAAI,CAACA,OAAO;;IAIlC;;;aA1BAA,UAAUT,OAAOY,MAAM,CACnB,oBACAR,6BAA6BM,UAAU,EACvC;YACIG,iBAAiB;YACjBC,aAAa;YACbC,WAAWb,EAAEc,OAAO,CAAC;gBACjBd,EAAEe,SAAS,CAACb,6BAA6BM,UAAU;gBACnDR,EAAEe,SAAS,CAACb,6BAA6Bc,MAAM;gBAC/ChB,EAAEiB,aAAa,CACX;aAEP;QACL;;AAcR;AAjCab,qBACOc,QAAQ;IAAC;QAAC;KAAiB;CAAC;AADnCd,qBAEOe,QAAQtB,QAAQuB,KAAK,CAAC;IAClCR,aAAa;AACjB"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { ConfigurationType } from '../../../environment/configuration/ConfigurationSchema.js';
|
2
3
|
interface Props {
|
3
|
-
version:
|
4
|
+
version: ConfigurationType['version'];
|
4
5
|
}
|
5
6
|
export declare const GenerateTypes: ({ version }: Props) => React.JSX.Element;
|
6
7
|
export {};
|
@@ -1,7 +1,28 @@
|
|
1
|
-
import {
|
2
|
-
import
|
1
|
+
import React, { useMemo } from 'react';
|
2
|
+
import { useFetchHtml } from '../../../commands/GenerateTypes/hooks/useFetchHtml.js';
|
3
|
+
import { useGenerateTypeFile } from '../../../commands/GenerateTypes/hooks/useGenerateTypeFile.js';
|
4
|
+
import { useGetVersion } from '../../../commands/GenerateTypes/hooks/useGetVersion.js';
|
5
|
+
import { CheckList } from '../../../components/CheckList/index.js';
|
6
|
+
import { useQuitOnCtrlC } from '../../../hooks/useQuitOnCtrlC.js';
|
3
7
|
export const GenerateTypes = ({ version })=>{
|
4
|
-
|
8
|
+
useQuitOnCtrlC();
|
9
|
+
const { fetchedVersion, getVersion } = useGetVersion(version);
|
10
|
+
const { html, fetchHtml } = useFetchHtml(fetchedVersion);
|
11
|
+
const { generateTypeFile } = useGenerateTypeFile(process.cwd(), html);
|
12
|
+
const items = useMemo(()=>{
|
13
|
+
return [
|
14
|
+
getVersion,
|
15
|
+
fetchHtml,
|
16
|
+
generateTypeFile
|
17
|
+
];
|
18
|
+
}, [
|
19
|
+
fetchedVersion,
|
20
|
+
html
|
21
|
+
]);
|
22
|
+
return /*#__PURE__*/ React.createElement(CheckList, {
|
23
|
+
items: items,
|
24
|
+
onFinish: process.exit
|
25
|
+
});
|
5
26
|
};
|
6
27
|
|
7
28
|
//# sourceMappingURL=GenerateTypes.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import {
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useFetchHtml } from '@/cli/commands/GenerateTypes/hooks/useFetchHtml.js';\nimport { useGenerateTypeFile } from '@/cli/commands/GenerateTypes/hooks/useGenerateTypeFile.js';\nimport { useGetVersion } from '@/cli/commands/GenerateTypes/hooks/useGetVersion.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { ConfigurationType } from '@/cli/environment/configuration/ConfigurationSchema.js';\nimport { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.js';\nimport { CheckListItem } from '@/cli/types.js';\n\ninterface Props {\n version: ConfigurationType['version'];\n}\n\nexport const GenerateTypes = ({ version }: Props) => {\n useQuitOnCtrlC();\n\n const { fetchedVersion, getVersion } = useGetVersion(version);\n const { html, fetchHtml } = useFetchHtml(fetchedVersion);\n const { generateTypeFile } = useGenerateTypeFile(process.cwd(), html);\n\n const items = useMemo(() => {\n return [\n getVersion,\n fetchHtml,\n generateTypeFile,\n ] as CheckListItem<unknown>[];\n }, [fetchedVersion, html]);\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["React","useMemo","useFetchHtml","useGenerateTypeFile","useGetVersion","CheckList","useQuitOnCtrlC","GenerateTypes","version","fetchedVersion","getVersion","html","fetchHtml","generateTypeFile","process","cwd","items","onFinish","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,YAAY,QAAQ,qDAAqD;AAClF,SAASC,mBAAmB,QAAQ,4DAA4D;AAChG,SAASC,aAAa,QAAQ,sDAAsD;AACpF,SAASC,SAAS,QAAQ,sCAAsC;AAEhE,SAASC,cAAc,QAAQ,gCAAgC;AAO/D,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,OAAO,EAAS;IAC5CF;IAEA,MAAM,EAAEG,cAAc,EAAEC,UAAU,EAAE,GAAGN,cAAcI;IACrD,MAAM,EAAEG,IAAI,EAAEC,SAAS,EAAE,GAAGV,aAAaO;IACzC,MAAM,EAAEI,gBAAgB,EAAE,GAAGV,oBAAoBW,QAAQC,GAAG,IAAIJ;IAEhE,MAAMK,QAAQf,QAAQ;QAClB,OAAO;YACHS;YACAE;YACAC;SACH;IACL,GAAG;QAACJ;QAAgBE;KAAK;IAEzB,qBAAO,oBAACN;QAAUW,OAAOA;QAAOC,UAAUH,QAAQI,IAAI;;AAC1D,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const PlaydateSdkUrl = "https://sdk.play.date/";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/constants.ts"],"sourcesContent":["export const PlaydateSdkUrl = 'https://sdk.play.date/';\n"],"names":["PlaydateSdkUrl"],"rangeMappings":"","mappings":"AAAA,OAAO,MAAMA,iBAAiB,yBAAyB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getHtmlForVersion: (version: string) => Promise<string>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
2
|
+
import { mkdirSync } from 'node:fs';
|
3
|
+
import { tmpdir } from 'node:os';
|
4
|
+
import { join } from 'node:path';
|
5
|
+
export const getHtmlForVersion = async (version)=>{
|
6
|
+
const cacheDir = join(tmpdir(), 'crankscript', 'cache');
|
7
|
+
const path = join(cacheDir, `${version}.html`);
|
8
|
+
if (!existsSync(cacheDir)) {
|
9
|
+
mkdirSync(cacheDir, {
|
10
|
+
recursive: true
|
11
|
+
});
|
12
|
+
}
|
13
|
+
if (existsSync(path)) {
|
14
|
+
return readFileSync(path, 'utf8');
|
15
|
+
}
|
16
|
+
const html = await fetch(`https://sdk.play.date/${version}/`).then((res)=>res.text());
|
17
|
+
writeFileSync(path, html, 'utf8');
|
18
|
+
return html;
|
19
|
+
};
|
20
|
+
|
21
|
+
//# sourceMappingURL=getHtmlForVersion.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getHtmlForVersion.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { mkdirSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nexport const getHtmlForVersion = async (version: string) => {\n const cacheDir = join(tmpdir(), 'crankscript', 'cache');\n const path = join(cacheDir, `${version}.html`);\n\n if (!existsSync(cacheDir)) {\n mkdirSync(cacheDir, { recursive: true });\n }\n\n if (existsSync(path)) {\n return readFileSync(path, 'utf8');\n }\n\n const html = await fetch(`https://sdk.play.date/${version}/`).then((res) =>\n res.text()\n );\n\n writeFileSync(path, html, 'utf8');\n\n return html;\n};\n"],"names":["existsSync","readFileSync","writeFileSync","mkdirSync","tmpdir","join","getHtmlForVersion","version","cacheDir","path","recursive","html","fetch","then","res","text"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,EAAEC,aAAa,QAAQ,UAAU;AAClE,SAASC,SAAS,QAAQ,UAAU;AACpC,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,IAAI,QAAQ,YAAY;AAEjC,OAAO,MAAMC,oBAAoB,OAAOC;IACpC,MAAMC,WAAWH,KAAKD,UAAU,eAAe;IAC/C,MAAMK,OAAOJ,KAAKG,UAAU,CAAC,EAAED,QAAQ,KAAK,CAAC;IAE7C,IAAI,CAACP,WAAWQ,WAAW;QACvBL,UAAUK,UAAU;YAAEE,WAAW;QAAK;IAC1C;IAEA,IAAIV,WAAWS,OAAO;QAClB,OAAOR,aAAaQ,MAAM;IAC9B;IAEA,MAAME,OAAO,MAAMC,MAAM,CAAC,sBAAsB,EAAEL,QAAQ,CAAC,CAAC,EAAEM,IAAI,CAAC,CAACC,MAChEA,IAAIC,IAAI;IAGZb,cAAcO,MAAME,MAAM;IAE1B,OAAOA;AACX,EAAE"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export declare const useFetchHtml: (version: string | null) => {
|
2
|
+
html: string | null;
|
3
|
+
fetchHtml: {
|
4
|
+
waitingDescription: string;
|
5
|
+
errorDescription: string;
|
6
|
+
finishedDescription: () => string;
|
7
|
+
runningDescription: string;
|
8
|
+
runner: () => Promise<string>;
|
9
|
+
onFinish: (result: string) => void;
|
10
|
+
ready: boolean;
|
11
|
+
};
|
12
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { useMemo, useState } from 'react';
|
2
|
+
import { getHtmlForVersion } from '../../../commands/GenerateTypes/fn/getHtmlForVersion.js';
|
3
|
+
export const useFetchHtml = (version)=>{
|
4
|
+
const [html, setHtml] = useState(null);
|
5
|
+
const fetchHtml = useMemo(()=>{
|
6
|
+
return {
|
7
|
+
waitingDescription: 'Waiting to fetch HTML contents',
|
8
|
+
errorDescription: 'Failed to fetch HTML contents',
|
9
|
+
finishedDescription: ()=>'HTML contents fetched',
|
10
|
+
runningDescription: 'Fetching HTML contents...',
|
11
|
+
runner: async ()=>{
|
12
|
+
if (!version) {
|
13
|
+
throw new Error('Version is not set');
|
14
|
+
}
|
15
|
+
return getHtmlForVersion(version);
|
16
|
+
},
|
17
|
+
onFinish: (result)=>{
|
18
|
+
setHtml(result);
|
19
|
+
},
|
20
|
+
ready: version !== null
|
21
|
+
};
|
22
|
+
}, [
|
23
|
+
version
|
24
|
+
]);
|
25
|
+
return {
|
26
|
+
html,
|
27
|
+
fetchHtml
|
28
|
+
};
|
29
|
+
};
|
30
|
+
|
31
|
+
//# sourceMappingURL=useFetchHtml.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useFetchHtml.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getHtmlForVersion } from '@/cli/commands/GenerateTypes/fn/getHtmlForVersion.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useFetchHtml = (version: string | null) => {\n const [html, setHtml] = useState<string | null>(null);\n\n const fetchHtml = useMemo(() => {\n return {\n waitingDescription: 'Waiting to fetch HTML contents',\n errorDescription: 'Failed to fetch HTML contents',\n finishedDescription: () => 'HTML contents fetched',\n runningDescription: 'Fetching HTML contents...',\n runner: async () => {\n if (!version) {\n throw new Error('Version is not set');\n }\n\n return getHtmlForVersion(version);\n },\n onFinish: (result) => {\n setHtml(result);\n },\n ready: version !== null,\n } satisfies CheckListItem<string>;\n }, [version]);\n\n return {\n html,\n fetchHtml,\n };\n};\n"],"names":["useMemo","useState","getHtmlForVersion","useFetchHtml","version","html","setHtml","fetchHtml","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","onFinish","result","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AAGzF,OAAO,MAAMC,eAAe,CAACC;IACzB,MAAM,CAACC,MAAMC,QAAQ,GAAGL,SAAwB;IAEhD,MAAMM,YAAYP,QAAQ;QACtB,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACR,SAAS;oBACV,MAAM,IAAIS,MAAM;gBACpB;gBAEA,OAAOX,kBAAkBE;YAC7B;YACAU,UAAU,CAACC;gBACPT,QAAQS;YACZ;YACAC,OAAOZ,YAAY;QACvB;IACJ,GAAG;QAACA;KAAQ;IAEZ,OAAO;QACHC;QACAE;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare const useGenerateTypeFile: (path: string, html: string | null) => {
|
2
|
+
generateTypeFile: {
|
3
|
+
waitingDescription: string;
|
4
|
+
errorDescription: string;
|
5
|
+
finishedDescription: () => string;
|
6
|
+
runningDescription: string;
|
7
|
+
runner: () => Promise<void>;
|
8
|
+
ready: boolean;
|
9
|
+
};
|
10
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { join } from 'node:path';
|
2
|
+
import { load } from 'cheerio';
|
3
|
+
import { useMemo } from 'react';
|
4
|
+
import { Project } from 'ts-morph';
|
5
|
+
export const useGenerateTypeFile = (path, html)=>{
|
6
|
+
const generateTypeFile = useMemo(()=>{
|
7
|
+
return {
|
8
|
+
waitingDescription: 'Waiting to generate the type file...',
|
9
|
+
errorDescription: 'Failed to generate the type file',
|
10
|
+
finishedDescription: ()=>'Type file generated',
|
11
|
+
runningDescription: 'Generating the type file...',
|
12
|
+
runner: async ()=>{
|
13
|
+
if (!html) {
|
14
|
+
throw new Error('HTML is not set');
|
15
|
+
}
|
16
|
+
const project = new Project();
|
17
|
+
const typeFile = project.createSourceFile(join(path, 'playdate.d.ts'), '', {
|
18
|
+
overwrite: true
|
19
|
+
});
|
20
|
+
typeFile.addStatements('/// <reference types="lua-types/5.4" />');
|
21
|
+
const $ = load(html);
|
22
|
+
typeFile.saveSync();
|
23
|
+
},
|
24
|
+
ready: html !== null
|
25
|
+
};
|
26
|
+
}, [
|
27
|
+
html
|
28
|
+
]);
|
29
|
+
return {
|
30
|
+
generateTypeFile
|
31
|
+
};
|
32
|
+
};
|
33
|
+
|
34
|
+
//# sourceMappingURL=useGenerateTypeFile.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { load } from 'cheerio';\nimport { useMemo } from 'react';\nimport { Project } from 'ts-morph';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (path: string, html: string | null) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(\n join(path, 'playdate.d.ts'),\n '',\n {\n overwrite: true,\n }\n );\n\n typeFile.addStatements(\n '/// <reference types=\"lua-types/5.4\" />'\n );\n\n const $ = load(html);\n\n typeFile.saveSync();\n },\n ready: html !== null,\n } satisfies CheckListItem<void>;\n }, [html]);\n\n return {\n generateTypeFile,\n };\n};\n"],"names":["join","load","useMemo","Project","useGenerateTypeFile","path","html","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","$","saveSync","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,OAAO,QAAQ,WAAW;AAGnC,OAAO,MAAMC,sBAAsB,CAACC,MAAcC;IAC9C,MAAMC,mBAAmBL,QAAQ;QAC7B,OAAO;YACHM,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACN,MAAM;oBACP,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAIX;gBACpB,MAAMY,WAAWD,QAAQE,gBAAgB,CACrChB,KAAKK,MAAM,kBACX,IACA;oBACIY,WAAW;gBACf;gBAGJF,SAASG,aAAa,CAClB;gBAGJ,MAAMC,IAAIlB,KAAKK;gBAEfS,SAASK,QAAQ;YACrB;YACAC,OAAOf,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHC;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ConfigurationType } from '../../../environment/configuration/ConfigurationSchema.js';
|
2
|
+
export declare const useGetVersion: (version: ConfigurationType["version"]) => {
|
3
|
+
fetchedVersion: string | null;
|
4
|
+
getVersion: {
|
5
|
+
waitingDescription: string;
|
6
|
+
runningDescription: string;
|
7
|
+
errorDescription: string;
|
8
|
+
finishedDescription: (result: string) => string;
|
9
|
+
runner: () => Promise<string>;
|
10
|
+
onFinish: (result: string) => void;
|
11
|
+
};
|
12
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
2
|
+
import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
|
3
|
+
import { PlaydateSdkVersionIdentifier } from '../../../types.js';
|
4
|
+
export const useGetVersion = (version)=>{
|
5
|
+
const [result, setResult] = useState(null);
|
6
|
+
const fetchLastVersion = useCallback(async ()=>{
|
7
|
+
const response = await fetch(PlaydateSdkUrl);
|
8
|
+
const url = response.url;
|
9
|
+
const regex = /https:\/\/sdk.play.date\/([0-9]+\.[0-9]+\.[0-9]+)\//;
|
10
|
+
const match = url.match(regex);
|
11
|
+
if (!match || match.length < 2) {
|
12
|
+
throw new Error('Could not find version in URL');
|
13
|
+
}
|
14
|
+
return match[1];
|
15
|
+
}, []);
|
16
|
+
const validateVersion = useCallback(async (version)=>{
|
17
|
+
const response = await fetch(`https://sdk.play.date/${version}/`);
|
18
|
+
if (!response.ok) {
|
19
|
+
throw new Error(`Failed to fetch version ${version}`);
|
20
|
+
}
|
21
|
+
return true;
|
22
|
+
}, []);
|
23
|
+
const getVersion = useMemo(()=>{
|
24
|
+
return {
|
25
|
+
waitingDescription: `Waiting to fetch version`,
|
26
|
+
runningDescription: 'Fetching version...',
|
27
|
+
errorDescription: 'Failed to fetch version',
|
28
|
+
finishedDescription: (result)=>`Fetched version ${result}`,
|
29
|
+
runner: async ()=>{
|
30
|
+
let versionLiteral = version;
|
31
|
+
if (version === PlaydateSdkVersionIdentifier.Latest) {
|
32
|
+
versionLiteral = await fetchLastVersion();
|
33
|
+
}
|
34
|
+
await validateVersion(versionLiteral);
|
35
|
+
return versionLiteral;
|
36
|
+
},
|
37
|
+
onFinish: (result)=>{
|
38
|
+
setResult(result);
|
39
|
+
}
|
40
|
+
};
|
41
|
+
}, []);
|
42
|
+
return {
|
43
|
+
fetchedVersion: result,
|
44
|
+
getVersion
|
45
|
+
};
|
46
|
+
};
|
47
|
+
|
48
|
+
//# sourceMappingURL=useGetVersion.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { ConfigurationType } from '@/cli/environment/configuration/ConfigurationSchema.js';\nimport { CheckListItem, PlaydateSdkVersionIdentifier } from '@/cli/types.js';\n\nexport const useGetVersion = (version: ConfigurationType['version']) => {\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: (result) => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n return versionLiteral;\n },\n onFinish: (result) => {\n setResult(result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","PlaydateSdkVersionIdentifier","useGetVersion","version","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACvD,SAASC,cAAc,QAAQ,4CAA4C;AAE3E,SAAwBC,4BAA4B,QAAQ,iBAAiB;AAE7E,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,MAAM,CAACC,QAAQC,UAAU,GAAGN,SAAwB;IACpD,MAAMO,mBAAmBT,YAAY;QACjC,MAAMU,WAAW,MAAMC,MAAMR;QAC7B,MAAMS,MAAMF,SAASE,GAAG;QAExB,MAAMC,QAAQ;QACd,MAAMC,QAAQF,IAAIE,KAAK,CAACD;QAExB,IAAI,CAACC,SAASA,MAAMC,MAAM,GAAG,GAAG;YAC5B,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOF,KAAK,CAAC,EAAE;IACnB,GAAG,EAAE;IACL,MAAMG,kBAAkBjB,YAAY,OAAOM;QACvC,MAAMI,WAAW,MAAMC,MAAM,CAAC,sBAAsB,EAAEL,QAAQ,CAAC,CAAC;QAEhE,IAAI,CAACI,SAASQ,EAAE,EAAE;YACd,MAAM,IAAIF,MAAM,CAAC,wBAAwB,EAAEV,QAAQ,CAAC;QACxD;QAEA,OAAO;IACX,GAAG,EAAE;IAEL,MAAMa,aAAalB,QAAQ;QACvB,OAAO;YACHmB,oBAAoB,CAAC,wBAAwB,CAAC;YAC9CC,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,CAAChB,SAAW,CAAC,gBAAgB,EAAEA,OAAO,CAAC;YAC5DiB,QAAQ;gBACJ,IAAIC,iBAAiBnB;gBAErB,IAAIA,YAAYF,6BAA6BsB,MAAM,EAAE;oBACjDD,iBAAiB,MAAMhB;gBAC3B;gBAEA,MAAMQ,gBAAgBQ;gBAEtB,OAAOA;YACX;YACAE,UAAU,CAACpB;gBACPC,UAAUD;YACd;QACJ;IACJ,GAAG,EAAE;IAEL,OAAO;QACHqB,gBAAgBrB;QAChBY;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
2
|
+
import React, { useEffect, useState } from 'react';
|
3
|
+
import { Item } from './Item.js';
|
4
|
+
export const CheckList = ({ items, onFinish })=>{
|
5
|
+
const [currentIndex, setCurrentIndex] = useState(null);
|
6
|
+
useEffect(()=>{
|
7
|
+
if (currentIndex === null && items.length > 0) {
|
8
|
+
setCurrentIndex(0);
|
9
|
+
}
|
10
|
+
}, [
|
11
|
+
currentIndex,
|
12
|
+
items
|
13
|
+
]);
|
14
|
+
const handleFinish = (index)=>{
|
15
|
+
if (index + 1 < items.length) {
|
16
|
+
setCurrentIndex(index + 1);
|
17
|
+
} else {
|
18
|
+
setCurrentIndex(null);
|
19
|
+
onFinish == null ? void 0 : onFinish();
|
20
|
+
}
|
21
|
+
};
|
22
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, items.map((item, index)=>/*#__PURE__*/ React.createElement(Item, {
|
23
|
+
key: index,
|
24
|
+
item: _extends({}, item, {
|
25
|
+
onFinish: (result)=>{
|
26
|
+
var _item_onFinish;
|
27
|
+
item == null ? void 0 : (_item_onFinish = item.onFinish) == null ? void 0 : _item_onFinish.call(item, result);
|
28
|
+
handleFinish(index);
|
29
|
+
}
|
30
|
+
}),
|
31
|
+
start: index === currentIndex
|
32
|
+
})));
|
33
|
+
};
|
34
|
+
|
35
|
+
//# sourceMappingURL=CheckList.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\ninterface Props {\n items: CheckListItem<unknown>[];\n onFinish?: () => void;\n}\n\nexport const CheckList = ({ items, onFinish }: Props) => {\n const [currentIndex, setCurrentIndex] = useState<number | null>(null);\n\n useEffect(() => {\n if (currentIndex === null && items.length > 0) {\n setCurrentIndex(0);\n }\n }, [currentIndex, items]);\n\n const handleFinish = (index: number) => {\n if (index + 1 < items.length) {\n setCurrentIndex(index + 1);\n } else {\n setCurrentIndex(null);\n onFinish?.();\n }\n };\n\n return (\n <>\n {items.map((item, index) => (\n <Item\n key={index}\n item={{\n ...item,\n onFinish: (result: unknown) => {\n item?.onFinish?.(result);\n handleFinish(index);\n },\n }}\n start={index === currentIndex}\n />\n ))}\n </>\n );\n};\n"],"names":["React","useEffect","useState","Item","CheckList","items","onFinish","currentIndex","setCurrentIndex","length","handleFinish","index","map","item","key","result","start"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,IAAI,QAAQ,YAAY;AAOjC,OAAO,MAAMC,YAAY,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAS;IAChD,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,SAAwB;IAEhED,UAAU;QACN,IAAIM,iBAAiB,QAAQF,MAAMI,MAAM,GAAG,GAAG;YAC3CD,gBAAgB;QACpB;IACJ,GAAG;QAACD;QAAcF;KAAM;IAExB,MAAMK,eAAe,CAACC;QAClB,IAAIA,QAAQ,IAAIN,MAAMI,MAAM,EAAE;YAC1BD,gBAAgBG,QAAQ;QAC5B,OAAO;YACHH,gBAAgB;YAChBF,4BAAAA;QACJ;IACJ;IAEA,qBACI,0CACKD,MAAMO,GAAG,CAAC,CAACC,MAAMF,sBACd,oBAACR;YACGW,KAAKH;YACLE,MAAM,aACCA;gBACHP,UAAU,CAACS;wBACPF;oBAAAA,yBAAAA,iBAAAA,KAAMP,QAAQ,qBAAdO,oBAAAA,MAAiBE;oBACjBL,aAAaC;gBACjB;;YAEJK,OAAOL,UAAUJ;;AAKrC,EAAE"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { CheckListItem } from '../../types.js';
|
3
|
+
export interface ItemProps<TResult> {
|
4
|
+
item: CheckListItem<TResult>;
|
5
|
+
start: boolean;
|
6
|
+
}
|
7
|
+
export declare const Item: <TResult>({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, runner, onFinish, ready, }, start, }: ItemProps<TResult>) => React.JSX.Element;
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { StatusMessage, Spinner, extendTheme, defaultTheme, ThemeProvider } from '@inkjs/ui';
|
2
|
+
import { Text } from 'ink';
|
3
|
+
import React, { useEffect, useRef, useState } from 'react';
|
4
|
+
// todo: possibly extract this
|
5
|
+
const SpinnerTheme = extendTheme(defaultTheme, {
|
6
|
+
components: {
|
7
|
+
Spinner: {
|
8
|
+
styles: {
|
9
|
+
frame: ()=>({
|
10
|
+
color: 'yellowBright'
|
11
|
+
}),
|
12
|
+
label: ()=>({
|
13
|
+
color: 'yellowBright'
|
14
|
+
})
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
});
|
19
|
+
export const Item = ({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, runner, onFinish, ready }, start })=>{
|
20
|
+
const executed = useRef(false);
|
21
|
+
const interval = useRef(null);
|
22
|
+
const [dotCount, setDotCount] = useState(0);
|
23
|
+
const [result, setResult] = useState(null);
|
24
|
+
const [failedReason, setfailedReason] = useState(null);
|
25
|
+
const hasResult = !failedReason && result !== null;
|
26
|
+
const isRunning = !failedReason && !hasResult && start && ready !== false;
|
27
|
+
const isWaiting = !failedReason && !hasResult && (!start || !ready);
|
28
|
+
const couldStartButNotReady = !failedReason && !hasResult && start && ready === false;
|
29
|
+
useEffect(()=>{
|
30
|
+
if (failedReason) {
|
31
|
+
process.exit();
|
32
|
+
}
|
33
|
+
}, [
|
34
|
+
failedReason
|
35
|
+
]);
|
36
|
+
useEffect(()=>{
|
37
|
+
if (couldStartButNotReady) {
|
38
|
+
interval.current = setInterval(()=>{
|
39
|
+
setDotCount((count)=>(count + 1) % 4);
|
40
|
+
}, 250);
|
41
|
+
} else {
|
42
|
+
if (interval.current) {
|
43
|
+
clearInterval(interval.current);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return ()=>{
|
47
|
+
if (interval.current) {
|
48
|
+
clearInterval(interval.current);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
}, [
|
52
|
+
couldStartButNotReady
|
53
|
+
]);
|
54
|
+
useEffect(()=>{
|
55
|
+
if (!start || executed.current || ready === false) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
runner().then((result)=>{
|
59
|
+
executed.current = true;
|
60
|
+
if (result === false) {
|
61
|
+
setfailedReason(errorDescription);
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
setResult(result);
|
65
|
+
onFinish == null ? void 0 : onFinish(result);
|
66
|
+
}).catch((reason)=>{
|
67
|
+
setfailedReason(reason.message);
|
68
|
+
});
|
69
|
+
}, [
|
70
|
+
errorDescription,
|
71
|
+
onFinish,
|
72
|
+
runner,
|
73
|
+
start
|
74
|
+
]);
|
75
|
+
let message = waitingDescription;
|
76
|
+
let variant = 'info';
|
77
|
+
if (failedReason) {
|
78
|
+
message = ` ${failedReason}`;
|
79
|
+
variant = 'error';
|
80
|
+
} else if (isRunning) {
|
81
|
+
message = runningDescription;
|
82
|
+
variant = 'warning';
|
83
|
+
} else if (hasResult) {
|
84
|
+
message = finishedDescription(result);
|
85
|
+
variant = 'success';
|
86
|
+
}
|
87
|
+
if (isRunning) {
|
88
|
+
return /*#__PURE__*/ React.createElement(ThemeProvider, {
|
89
|
+
theme: SpinnerTheme
|
90
|
+
}, /*#__PURE__*/ React.createElement(Spinner, {
|
91
|
+
label: ` ${message}`
|
92
|
+
}));
|
93
|
+
}
|
94
|
+
return /*#__PURE__*/ React.createElement(StatusMessage, {
|
95
|
+
variant: variant
|
96
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
97
|
+
bold: !isWaiting,
|
98
|
+
color: isRunning ? 'yellow' : isWaiting ? 'gray' : failedReason ? 'red' : 'green'
|
99
|
+
}, message, ' ', couldStartButNotReady && `— not ready yet${'.'.repeat(dotCount)}`));
|
100
|
+
};
|
101
|
+
|
102
|
+
//# sourceMappingURL=Item.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import {\n StatusMessage,\n StatusMessageProps,\n Spinner,\n extendTheme,\n defaultTheme,\n ThemeProvider,\n} from '@inkjs/ui';\nimport { Text, TextProps } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport interface ItemProps<TResult> {\n item: CheckListItem<TResult>;\n start: boolean;\n}\n\n// todo: possibly extract this\nconst SpinnerTheme = extendTheme(defaultTheme, {\n components: {\n Spinner: {\n styles: {\n frame: (): TextProps => ({\n color: 'yellowBright',\n }),\n label: (): TextProps => ({\n color: 'yellowBright',\n }),\n },\n },\n },\n});\n\nexport const Item = <TResult,>({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n runner,\n onFinish,\n ready,\n },\n start,\n}: ItemProps<TResult>) => {\n const executed = useRef(false);\n const interval = useRef<NodeJS.Timeout | null>(null);\n const [dotCount, setDotCount] = useState(0);\n const [result, setResult] = useState<TResult | null>(null);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const hasResult = !failedReason && result !== null;\n const isRunning = !failedReason && !hasResult && start && ready !== false;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason) {\n process.exit();\n }\n }, [failedReason]);\n\n useEffect(() => {\n if (couldStartButNotReady) {\n interval.current = setInterval(() => {\n setDotCount((count) => (count + 1) % 4);\n }, 250);\n } else {\n if (interval.current) {\n clearInterval(interval.current);\n }\n }\n\n return () => {\n if (interval.current) {\n clearInterval(interval.current);\n }\n };\n }, [couldStartButNotReady]);\n\n useEffect(() => {\n if (!start || executed.current || ready === false) {\n return;\n }\n\n runner()\n .then((result) => {\n executed.current = true;\n\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResult(result);\n onFinish?.(result);\n })\n .catch((reason) => {\n setfailedReason(reason.message);\n });\n }, [errorDescription, onFinish, runner, start]);\n\n let message = waitingDescription;\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (failedReason) {\n message = ` ${failedReason}`;\n variant = 'error';\n } else if (isRunning) {\n message = runningDescription;\n variant = 'warning';\n } else if (hasResult) {\n message = finishedDescription(result);\n variant = 'success';\n }\n\n if (isRunning) {\n return (\n <ThemeProvider theme={SpinnerTheme}>\n <Spinner label={` ${message}`} />\n </ThemeProvider>\n );\n }\n\n return (\n <StatusMessage variant={variant}>\n <Text\n bold={!isWaiting}\n color={\n isRunning\n ? 'yellow'\n : isWaiting\n ? 'gray'\n : failedReason\n ? 'red'\n : 'green'\n }\n >\n {message}{' '}\n {couldStartButNotReady &&\n `— not ready yet${'.'.repeat(dotCount)}`}\n </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Spinner","extendTheme","defaultTheme","ThemeProvider","Text","React","useEffect","useRef","useState","SpinnerTheme","components","styles","frame","color","label","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","runner","onFinish","ready","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","message","variant","theme","bold","repeat"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SACIA,aAAa,EAEbC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,aAAa,QACV,YAAY;AACnB,SAASC,IAAI,QAAmB,MAAM;AACtC,OAAOC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAQ3D,8BAA8B;AAC9B,MAAMC,eAAeR,YAAYC,cAAc;IAC3CQ,YAAY;QACRV,SAAS;YACLW,QAAQ;gBACJC,OAAO,IAAkB,CAAA;wBACrBC,OAAO;oBACX,CAAA;gBACAC,OAAO,IAAkB,CAAA;wBACrBD,OAAO;oBACX,CAAA;YACJ;QACJ;IACJ;AACJ;AAEA,OAAO,MAAME,OAAO,CAAW,EAC3BC,MAAM,EACFC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACR,EACDC,KAAK,EACY;IACjB,MAAMC,WAAWlB,OAAO;IACxB,MAAMmB,WAAWnB,OAA8B;IAC/C,MAAM,CAACoB,UAAUC,YAAY,GAAGpB,SAAS;IACzC,MAAM,CAACqB,QAAQC,UAAU,GAAGtB,SAAyB;IACrD,MAAM,CAACuB,cAAcC,gBAAgB,GAAGxB,SAAwB;IAChE,MAAMyB,YAAY,CAACF,gBAAgBF,WAAW;IAC9C,MAAMK,YAAY,CAACH,gBAAgB,CAACE,aAAaT,SAASD,UAAU;IACpE,MAAMY,YAAY,CAACJ,gBAAgB,CAACE,aAAc,CAAA,CAACT,SAAS,CAACD,KAAI;IACjE,MAAMa,wBACF,CAACL,gBAAgB,CAACE,aAAaT,SAASD,UAAU;IAEtDjB,UAAU;QACN,IAAIyB,cAAc;YACdM,QAAQC,IAAI;QAChB;IACJ,GAAG;QAACP;KAAa;IAEjBzB,UAAU;QACN,IAAI8B,uBAAuB;YACvBV,SAASa,OAAO,GAAGC,YAAY;gBAC3BZ,YAAY,CAACa,QAAU,AAACA,CAAAA,QAAQ,CAAA,IAAK;YACzC,GAAG;QACP,OAAO;YACH,IAAIf,SAASa,OAAO,EAAE;gBAClBG,cAAchB,SAASa,OAAO;YAClC;QACJ;QAEA,OAAO;YACH,IAAIb,SAASa,OAAO,EAAE;gBAClBG,cAAchB,SAASa,OAAO;YAClC;QACJ;IACJ,GAAG;QAACH;KAAsB;IAE1B9B,UAAU;QACN,IAAI,CAACkB,SAASC,SAASc,OAAO,IAAIhB,UAAU,OAAO;YAC/C;QACJ;QAEAF,SACKsB,IAAI,CAAC,CAACd;YACHJ,SAASc,OAAO,GAAG;YAEnB,IAAIV,WAAW,OAAO;gBAClBG,gBAAgBb;gBAEhB;YACJ;YAEAW,UAAUD;YACVP,4BAAAA,SAAWO;QACf,GACCe,KAAK,CAAC,CAACC;YACJb,gBAAgBa,OAAOC,OAAO;QAClC;IACR,GAAG;QAAC3B;QAAkBG;QAAUD;QAAQG;KAAM;IAE9C,IAAIsB,UAAU5B;IACd,IAAI6B,UAAyC;IAE7C,IAAIhB,cAAc;QACde,UAAU,CAAC,CAAC,EAAEf,aAAa,CAAC;QAC5BgB,UAAU;IACd,OAAO,IAAIb,WAAW;QAClBY,UAAU7B;QACV8B,UAAU;IACd,OAAO,IAAId,WAAW;QAClBa,UAAU1B,oBAAoBS;QAC9BkB,UAAU;IACd;IAEA,IAAIb,WAAW;QACX,qBACI,oBAAC/B;YAAc6C,OAAOvC;yBAClB,oBAACT;YAAQc,OAAO,CAAC,CAAC,EAAEgC,QAAQ,CAAC;;IAGzC;IAEA,qBACI,oBAAC/C;QAAcgD,SAASA;qBACpB,oBAAC3C;QACG6C,MAAM,CAACd;QACPtB,OACIqB,YACM,WACAC,YACA,SACAJ,eACA,QACA;OAGTe,SAAS,KACTV,yBACG,CAAC,eAAe,EAAE,IAAIc,MAAM,CAACvB,UAAU,CAAC;AAI5D,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './CheckList.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/index.ts"],"sourcesContent":["export * from './CheckList.js';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,iBAAiB"}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
export const ConfigurationSchema = z.object({
|
3
|
-
version: z.
|
3
|
+
version: z.union([
|
4
|
+
z.string().regex(/^\d+\.\d+\.\d+$/),
|
5
|
+
z.literal('latest')
|
6
|
+
])
|
4
7
|
});
|
5
8
|
|
6
9
|
//# sourceMappingURL=ConfigurationSchema.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/environment/configuration/ConfigurationSchema.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const ConfigurationSchema = z.object({\n version: z.string().regex(/^\\d+\\.\\d+\\.\\d+$/),\n});\n\nexport type ConfigurationType = z.infer<typeof ConfigurationSchema>;\n"],"names":["z","ConfigurationSchema","object","version","string","regex"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/environment/configuration/ConfigurationSchema.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const ConfigurationSchema = z.object({\n version: z.union([\n z.string().regex(/^\\d+\\.\\d+\\.\\d+$/),\n z.literal('latest'),\n ]),\n});\n\nexport type ConfigurationType = z.infer<typeof ConfigurationSchema>;\n"],"names":["z","ConfigurationSchema","object","version","union","string","regex","literal"],"rangeMappings":";;;;;;","mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,sBAAsBD,EAAEE,MAAM,CAAC;IACxCC,SAASH,EAAEI,KAAK,CAAC;QACbJ,EAAEK,MAAM,GAAGC,KAAK,CAAC;QACjBN,EAAEO,OAAO,CAAC;KACb;AACL,GAAG"}
|
@@ -17,7 +17,7 @@ import { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';
|
|
17
17
|
isHealthy: false,
|
18
18
|
health: {
|
19
19
|
configurationFilePresent: error instanceof ConfigurationFileNotFoundError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.Healthy,
|
20
|
-
configurationFileValid: error instanceof ConfigurationFileValidationError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.
|
20
|
+
configurationFileValid: error instanceof ConfigurationFileValidationError && !(error instanceof ConfigurationFileNotFoundError) ? HealthCheckStatus.Unhealthy : error instanceof ConfigurationFileValidationError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.Unknown,
|
21
21
|
sdkPathKnown: HealthCheckStatus.Unknown
|
22
22
|
}
|
23
23
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/cli/src/environment/createEnvironment.ts"],"sourcesContent":["import { EnvironmentHealthResult, HealthCheckStatus } from '../types.js';\nimport { Configuration } from './configuration/dto/Configuration.js';\nimport { ConfigurationFileNotFoundError } from './configuration/error/ConfigurationFileNotFoundError.js';\nimport { ConfigurationFileValidationError } from './configuration/error/ConfigurationFileValidationError.js';\nimport { getConfiguration } from './configuration/getConfiguration.js';\nimport { Environment } from './dto/Environment.js';\nimport { PlaydateSdkPath } from './path/dto/PlaydateSdkPath.js';\nimport { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';\n\n/**\n * Will create a configuration object from the environment.\n */\nexport const createEnvironment = (input?: {\n /**\n * The environment to create the configuration from.\n *\n * Defaults to `process.env`.\n */\n environment: Record<string, unknown>;\n}): EnvironmentHealthResult => {\n const { environment = process.env } = input ?? {};\n let configuration: Configuration;\n let sdkPath: PlaydateSdkPath;\n\n try {\n configuration = getConfiguration();\n } catch (error) {\n return {\n isHealthy: false,\n health: {\n configurationFilePresent:\n error instanceof ConfigurationFileNotFoundError\n ? HealthCheckStatus.Unhealthy\n : HealthCheckStatus.Healthy,\n configurationFileValid:\n error instanceof ConfigurationFileValidationError\n ? HealthCheckStatus.Unhealthy\n : HealthCheckStatus.
|
1
|
+
{"version":3,"sources":["../../../../../libs/cli/src/environment/createEnvironment.ts"],"sourcesContent":["import { EnvironmentHealthResult, HealthCheckStatus } from '../types.js';\nimport { Configuration } from './configuration/dto/Configuration.js';\nimport { ConfigurationFileNotFoundError } from './configuration/error/ConfigurationFileNotFoundError.js';\nimport { ConfigurationFileValidationError } from './configuration/error/ConfigurationFileValidationError.js';\nimport { getConfiguration } from './configuration/getConfiguration.js';\nimport { Environment } from './dto/Environment.js';\nimport { PlaydateSdkPath } from './path/dto/PlaydateSdkPath.js';\nimport { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';\n\n/**\n * Will create a configuration object from the environment.\n */\nexport const createEnvironment = (input?: {\n /**\n * The environment to create the configuration from.\n *\n * Defaults to `process.env`.\n */\n environment: Record<string, unknown>;\n}): EnvironmentHealthResult => {\n const { environment = process.env } = input ?? {};\n let configuration: Configuration;\n let sdkPath: PlaydateSdkPath;\n\n try {\n configuration = getConfiguration();\n } catch (error) {\n return {\n isHealthy: false,\n health: {\n configurationFilePresent:\n error instanceof ConfigurationFileNotFoundError\n ? HealthCheckStatus.Unhealthy\n : HealthCheckStatus.Healthy,\n configurationFileValid:\n error instanceof ConfigurationFileValidationError &&\n !(error instanceof ConfigurationFileNotFoundError)\n ? HealthCheckStatus.Unhealthy\n : error instanceof ConfigurationFileValidationError\n ? HealthCheckStatus.Unhealthy\n : HealthCheckStatus.Unknown,\n sdkPathKnown: HealthCheckStatus.Unknown,\n },\n };\n }\n\n try {\n sdkPath = getPlaydateSdkPath({ environment });\n } catch (error) {\n return {\n isHealthy: false,\n health: {\n configurationFilePresent: HealthCheckStatus.Healthy,\n configurationFileValid: HealthCheckStatus.Healthy,\n sdkPathKnown: HealthCheckStatus.Unhealthy,\n },\n };\n }\n\n return {\n isHealthy: true,\n environment: new Environment({\n configuration,\n sdkPath,\n }),\n health: {\n configurationFilePresent: HealthCheckStatus.Healthy,\n configurationFileValid: HealthCheckStatus.Healthy,\n sdkPathKnown: HealthCheckStatus.Healthy,\n },\n };\n};\n"],"names":["HealthCheckStatus","ConfigurationFileNotFoundError","ConfigurationFileValidationError","getConfiguration","Environment","getPlaydateSdkPath","createEnvironment","input","environment","process","env","configuration","sdkPath","error","isHealthy","health","configurationFilePresent","Unhealthy","Healthy","configurationFileValid","Unknown","sdkPathKnown"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAkCA,iBAAiB,QAAQ,cAAc;AAEzE,SAASC,8BAA8B,QAAQ,0DAA0D;AACzG,SAASC,gCAAgC,QAAQ,4DAA4D;AAC7G,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE;;CAEC,GACD,OAAO,MAAMC,oBAAoB,CAACC;IAQ9B,MAAM,EAAEC,cAAcC,QAAQC,GAAG,EAAE,GAAGH,gBAAAA,QAAS,CAAC;IAChD,IAAII;IACJ,IAAIC;IAEJ,IAAI;QACAD,gBAAgBR;IACpB,EAAE,OAAOU,OAAO;QACZ,OAAO;YACHC,WAAW;YACXC,QAAQ;gBACJC,0BACIH,iBAAiBZ,iCACXD,kBAAkBiB,SAAS,GAC3BjB,kBAAkBkB,OAAO;gBACnCC,wBACIN,iBAAiBX,oCACjB,CAAEW,CAAAA,iBAAiBZ,8BAA6B,IAC1CD,kBAAkBiB,SAAS,GAC3BJ,iBAAiBX,mCACjBF,kBAAkBiB,SAAS,GAC3BjB,kBAAkBoB,OAAO;gBACnCC,cAAcrB,kBAAkBoB,OAAO;YAC3C;QACJ;IACJ;IAEA,IAAI;QACAR,UAAUP,mBAAmB;YAAEG;QAAY;IAC/C,EAAE,OAAOK,OAAO;QACZ,OAAO;YACHC,WAAW;YACXC,QAAQ;gBACJC,0BAA0BhB,kBAAkBkB,OAAO;gBACnDC,wBAAwBnB,kBAAkBkB,OAAO;gBACjDG,cAAcrB,kBAAkBiB,SAAS;YAC7C;QACJ;IACJ;IAEA,OAAO;QACHH,WAAW;QACXN,aAAa,IAAIJ,YAAY;YACzBO;YACAC;QACJ;QACAG,QAAQ;YACJC,0BAA0BhB,kBAAkBkB,OAAO;YACnDC,wBAAwBnB,kBAAkBkB,OAAO;YACjDG,cAAcrB,kBAAkBkB,OAAO;QAC3C;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useQuitOnCtrlC: () => void;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/cli/src/hooks/useQuitOnCtrlC.ts"],"sourcesContent":["import { useInput } from 'ink';\n\nexport const useQuitOnCtrlC = () => {\n useInput((input, key) => {\n if (key.ctrl && input === 'c') {\n process.exit();\n }\n });\n};\n"],"names":["useInput","useQuitOnCtrlC","input","key","ctrl","process","exit"],"rangeMappings":";;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,MAAM;AAE/B,OAAO,MAAMC,iBAAiB;IAC1BD,SAAS,CAACE,OAAOC;QACb,IAAIA,IAAIC,IAAI,IAAIF,UAAU,KAAK;YAC3BG,QAAQC,IAAI;QAChB;IACJ;AACJ,EAAE"}
|
package/src/index.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
import { readFileSync } from 'fs';
|
3
3
|
import { join } from 'node:path';
|
4
4
|
import { Cli } from 'clipanion';
|
5
|
-
import { DoctorCommand } from '
|
6
|
-
import { GenerateTypesCommand } from '
|
7
|
-
import { RootFolder } from '
|
5
|
+
import { DoctorCommand } from './commands/DoctorCommand.js';
|
6
|
+
import { GenerateTypesCommand } from './commands/GenerateTypes/GenerateTypesCommand.js';
|
7
|
+
import { RootFolder } from './utils/dirname.js';
|
8
8
|
const packageJsonContents = readFileSync(join(RootFolder, 'package.json'), 'utf-8');
|
9
9
|
const packageJson = JSON.parse(packageJsonContents);
|
10
10
|
const args = process.argv.slice(2);
|
package/src/types.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { Environment } from '
|
1
|
+
import { Environment } from './environment/dto/Environment.js';
|
2
2
|
export declare enum PlaydateSdkVersionIdentifier {
|
3
|
-
FromConfig = "FromConfig"
|
3
|
+
FromConfig = "FromConfig",
|
4
|
+
Latest = "latest"
|
4
5
|
}
|
5
6
|
export type EnvironmentHealthResult = {
|
6
7
|
isHealthy: true;
|
@@ -24,3 +25,12 @@ export declare enum ConfigurationFileValidationErrorType {
|
|
24
25
|
InvalidJson = "InvalidJson",
|
25
26
|
InvalidSchema = "InvalidSchema"
|
26
27
|
}
|
28
|
+
export type CheckListItem<TResult> = {
|
29
|
+
runningDescription: string;
|
30
|
+
waitingDescription: string;
|
31
|
+
errorDescription: string;
|
32
|
+
finishedDescription: (result: TResult) => string;
|
33
|
+
runner: () => Promise<TResult> | Promise<false>;
|
34
|
+
onFinish?: (result: TResult) => void;
|
35
|
+
ready?: boolean;
|
36
|
+
};
|
package/src/types.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export var PlaydateSdkVersionIdentifier;
|
2
2
|
(function(PlaydateSdkVersionIdentifier) {
|
3
3
|
PlaydateSdkVersionIdentifier["FromConfig"] = "FromConfig";
|
4
|
+
PlaydateSdkVersionIdentifier["Latest"] = "latest";
|
4
5
|
})(PlaydateSdkVersionIdentifier || (PlaydateSdkVersionIdentifier = {}));
|
5
6
|
export var HealthCheckStatus;
|
6
7
|
(function(HealthCheckStatus) {
|
package/src/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n FromConfig = 'FromConfig',\n}\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatus {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport interface EnvironmentHealth {\n configurationFilePresent: HealthCheckStatus;\n configurationFileValid: HealthCheckStatus;\n sdkPathKnown: HealthCheckStatus;\n}\n\nexport enum ConfigurationFileValidationErrorType {\n InvalidJson = 'InvalidJson',\n InvalidSchema = 'InvalidSchema',\n}\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatus","ConfigurationFileValidationErrorType"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n FromConfig = 'FromConfig',\n Latest = 'latest',\n}\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatus {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport interface EnvironmentHealth {\n configurationFilePresent: HealthCheckStatus;\n configurationFileValid: HealthCheckStatus;\n sdkPathKnown: HealthCheckStatus;\n}\n\nexport enum ConfigurationFileValidationErrorType {\n InvalidJson = 'InvalidJson',\n InvalidSchema = 'InvalidSchema',\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatus","ConfigurationFileValidationErrorType"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":";UAEYA;;;GAAAA,iCAAAA;;UAgBAC;;;;GAAAA,sBAAAA;;UAYAC;;;GAAAA,yCAAAA"}
|