crankscript 0.1.2 → 0.2.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 +8 -2
- package/src/commands/DoctorCommand.d.ts +7 -0
- package/src/commands/DoctorCommand.js +26 -0
- package/src/commands/DoctorCommand.js.map +1 -0
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +9 -0
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +25 -0
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js.map +1 -0
- package/src/commands/EnvironmentAwareCommand/components/HealthReport.d.ts +7 -0
- package/src/commands/EnvironmentAwareCommand/components/HealthReport.js +47 -0
- package/src/commands/EnvironmentAwareCommand/components/HealthReport.js.map +1 -0
- package/src/commands/EnvironmentAwareCommand/index.d.ts +1 -0
- package/src/commands/EnvironmentAwareCommand/index.js +3 -0
- package/src/commands/EnvironmentAwareCommand/index.js.map +1 -0
- package/src/commands/GenerateTypes/GenerateTypesCommand.d.ts +9 -0
- package/src/commands/GenerateTypes/GenerateTypesCommand.js +33 -0
- package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -0
- package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +6 -0
- package/src/commands/GenerateTypes/components/GenerateTypes.js +7 -0
- package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -0
- package/src/commands/GenerateTypes/index.d.ts +1 -0
- package/src/commands/GenerateTypes/index.js +3 -0
- package/src/commands/GenerateTypes/index.js.map +1 -0
- package/src/commands/RenderableCommand.d.ts +7 -0
- package/src/commands/RenderableCommand.js +12 -0
- package/src/commands/RenderableCommand.js.map +1 -0
- package/src/constants.d.ts +1 -0
- package/src/constants.js +3 -0
- package/src/constants.js.map +1 -0
- package/src/environment/configuration/ConfigurationSchema.d.ts +9 -0
- package/src/environment/configuration/ConfigurationSchema.js +6 -0
- package/src/environment/configuration/ConfigurationSchema.js.map +1 -0
- package/src/environment/configuration/dto/Configuration.d.ts +4 -0
- package/src/environment/configuration/dto/Configuration.js +7 -0
- package/src/environment/configuration/dto/Configuration.js.map +1 -0
- package/src/environment/configuration/error/ConfigurationFileNotFoundError.d.ts +4 -0
- package/src/environment/configuration/error/ConfigurationFileNotFoundError.js +8 -0
- package/src/environment/configuration/error/ConfigurationFileNotFoundError.js.map +1 -0
- package/src/environment/configuration/error/ConfigurationFileValidationError.d.ts +5 -0
- package/src/environment/configuration/error/ConfigurationFileValidationError.js +8 -0
- package/src/environment/configuration/error/ConfigurationFileValidationError.js.map +1 -0
- package/src/environment/configuration/getConfiguration.d.ts +4 -0
- package/src/environment/configuration/getConfiguration.js +31 -0
- package/src/environment/configuration/getConfiguration.js.map +1 -0
- package/src/environment/createEnvironment.d.ts +12 -0
- package/src/environment/createEnvironment.js +53 -0
- package/src/environment/createEnvironment.js.map +1 -0
- package/src/environment/dto/Environment.d.ts +10 -0
- package/src/environment/dto/Environment.js +8 -0
- package/src/environment/dto/Environment.js.map +1 -0
- package/src/environment/error/EnvironmentError.d.ts +2 -0
- package/src/environment/error/EnvironmentError.js +4 -0
- package/src/environment/error/EnvironmentError.js.map +1 -0
- package/src/environment/path/dto/PlaydateSdkPath.d.ts +5 -0
- package/src/environment/path/dto/PlaydateSdkPath.js +10 -0
- package/src/environment/path/dto/PlaydateSdkPath.js.map +1 -0
- package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.d.ts +4 -0
- package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.js +8 -0
- package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.js.map +1 -0
- package/src/environment/path/getPlaydateSdkPath.d.ts +14 -0
- package/src/environment/path/getPlaydateSdkPath.js +16 -0
- package/src/environment/path/getPlaydateSdkPath.js.map +1 -0
- package/src/index.js +16 -12
- package/src/index.js.map +1 -1
- package/src/types.d.ts +26 -0
- package/src/types.js +17 -0
- package/src/types.js.map +1 -0
- package/src/utils/dirname.d.ts +1 -0
- package/src/utils/dirname.js +6 -0
- package/src/utils/dirname.js.map +1 -0
package/package.json
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "crankscript",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.0",
|
4
4
|
"scripts": {
|
5
5
|
"dev": "tsx src/index.ts"
|
6
6
|
},
|
7
7
|
"bin": {
|
8
8
|
"crankscript": "./src/index.js"
|
9
9
|
},
|
10
|
+
"license": "MIT",
|
10
11
|
"dependencies": {
|
12
|
+
"@inkjs/ui": "^2.0.0",
|
11
13
|
"@swc/helpers": "~0.5.11",
|
12
|
-
"
|
14
|
+
"clipanion": "^4.0.0-rc.4",
|
15
|
+
"ink": "^5.0.1",
|
16
|
+
"react": "^18.3.1",
|
17
|
+
"typanion": "^3.14.0",
|
18
|
+
"zod": "^3.23.8"
|
13
19
|
},
|
14
20
|
"type": "module",
|
15
21
|
"main": "./src/index.js",
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Command } from 'clipanion';
|
2
|
+
import { Text } from 'ink';
|
3
|
+
import React from 'react';
|
4
|
+
import { createEnvironment } from '@/cli/environment/createEnvironment.js';
|
5
|
+
import { HealthReport } from './EnvironmentAwareCommand/components/HealthReport.js';
|
6
|
+
import { RenderableCommand } from './RenderableCommand.js';
|
7
|
+
export class DoctorCommand extends RenderableCommand {
|
8
|
+
render() {
|
9
|
+
const environment = createEnvironment();
|
10
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Text, {
|
11
|
+
color: "gray"
|
12
|
+
}, "Checking the environment..."), /*#__PURE__*/ React.createElement(HealthReport, {
|
13
|
+
health: environment.health
|
14
|
+
}));
|
15
|
+
}
|
16
|
+
}
|
17
|
+
DoctorCommand.paths = [
|
18
|
+
[
|
19
|
+
'doctor'
|
20
|
+
]
|
21
|
+
];
|
22
|
+
DoctorCommand.usage = Command.Usage({
|
23
|
+
description: 'Check the health of the environment'
|
24
|
+
});
|
25
|
+
|
26
|
+
//# sourceMappingURL=DoctorCommand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/cli/src/commands/DoctorCommand.tsx"],"sourcesContent":["import { Command } from 'clipanion';\nimport { Text } from 'ink';\nimport React from 'react';\nimport { createEnvironment } from '@/cli/environment/createEnvironment.js';\nimport { HealthReport } from './EnvironmentAwareCommand/components/HealthReport.js';\nimport { RenderableCommand } from './RenderableCommand.js';\n\nexport class DoctorCommand extends RenderableCommand {\n static override paths = [['doctor']];\n\n static override usage = Command.Usage({\n description: 'Check the health of the environment',\n });\n\n override render() {\n const environment = createEnvironment();\n\n return (\n <>\n <Text color=\"gray\">Checking the environment...</Text>\n <HealthReport health={environment.health} />\n </>\n );\n }\n}\n"],"names":["Command","Text","React","createEnvironment","HealthReport","RenderableCommand","DoctorCommand","render","environment","color","health","paths","usage","Usage","description"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,WAAW,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ,yCAAyC;AAC3E,SAASC,YAAY,QAAQ,uDAAuD;AACpF,SAASC,iBAAiB,QAAQ,yBAAyB;AAE3D,OAAO,MAAMC,sBAAsBD;IAOtBE,SAAS;QACd,MAAMC,cAAcL;QAEpB,qBACI,wDACI,oBAACF;YAAKQ,OAAM;WAAO,8CACnB,oBAACL;YAAaM,QAAQF,YAAYE,MAAM;;IAGpD;AACJ;AAjBaJ,cACOK,QAAQ;IAAC;QAAC;KAAS;CAAC;AAD3BL,cAGOM,QAAQZ,QAAQa,KAAK,CAAC;IAClCC,aAAa;AACjB"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { JSX } from 'react';
|
2
|
+
import { RenderableCommand } from '@/cli/commands/RenderableCommand.js';
|
3
|
+
import { Environment } from '@/cli/environment/dto/Environment.js';
|
4
|
+
export declare abstract class EnvironmentAwareCommand extends RenderableCommand {
|
5
|
+
private environment;
|
6
|
+
protected abstract renderWithEnvironment(environment: Environment): JSX.Element;
|
7
|
+
render(): JSX.Element;
|
8
|
+
execute(): Promise<void>;
|
9
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { HealthReport } from '@/cli/commands/EnvironmentAwareCommand/components/HealthReport.js';
|
3
|
+
import { RenderableCommand } from '@/cli/commands/RenderableCommand.js';
|
4
|
+
import { createEnvironment } from '@/cli/environment/createEnvironment.js';
|
5
|
+
export class EnvironmentAwareCommand extends RenderableCommand {
|
6
|
+
render() {
|
7
|
+
if (!this.environment) {
|
8
|
+
throw new Error('Environment is not set');
|
9
|
+
}
|
10
|
+
return this.renderWithEnvironment(this.environment);
|
11
|
+
}
|
12
|
+
async execute() {
|
13
|
+
const environmentHealth = createEnvironment();
|
14
|
+
if (!environmentHealth.isHealthy) {
|
15
|
+
this.renderElement(/*#__PURE__*/ React.createElement(HealthReport, {
|
16
|
+
health: environmentHealth.health
|
17
|
+
}));
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
this.environment = environmentHealth.environment;
|
21
|
+
this.renderElement(this.render());
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
//# sourceMappingURL=EnvironmentAwareCommand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.tsx"],"sourcesContent":["import React, { JSX } from 'react';\nimport { HealthReport } from '@/cli/commands/EnvironmentAwareCommand/components/HealthReport.js';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { createEnvironment } from '@/cli/environment/createEnvironment.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport abstract class EnvironmentAwareCommand extends RenderableCommand {\n private environment: Environment | undefined;\n\n protected abstract renderWithEnvironment(\n environment: Environment\n ): JSX.Element;\n\n override render() {\n if (!this.environment) {\n throw new Error('Environment is not set');\n }\n\n return this.renderWithEnvironment(this.environment);\n }\n\n override async execute() {\n const environmentHealth = createEnvironment();\n\n if (!environmentHealth.isHealthy) {\n this.renderElement(\n <HealthReport health={environmentHealth.health} />\n );\n\n return;\n }\n\n this.environment = environmentHealth.environment;\n\n this.renderElement(this.render());\n }\n}\n"],"names":["React","HealthReport","RenderableCommand","createEnvironment","EnvironmentAwareCommand","render","environment","Error","renderWithEnvironment","execute","environmentHealth","isHealthy","renderElement","health"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,WAAoB,QAAQ;AACnC,SAASC,YAAY,QAAQ,oEAAoE;AACjG,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,iBAAiB,QAAQ,yCAAyC;AAG3E,OAAO,MAAeC,gCAAgCF;IAOzCG,SAAS;QACd,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE;YACnB,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAO,IAAI,CAACC,qBAAqB,CAAC,IAAI,CAACF,WAAW;IACtD;IAEA,MAAeG,UAAU;QACrB,MAAMC,oBAAoBP;QAE1B,IAAI,CAACO,kBAAkBC,SAAS,EAAE;YAC9B,IAAI,CAACC,aAAa,eACd,oBAACX;gBAAaY,QAAQH,kBAAkBG,MAAM;;YAGlD;QACJ;QAEA,IAAI,CAACP,WAAW,GAAGI,kBAAkBJ,WAAW;QAEhD,IAAI,CAACM,aAAa,CAAC,IAAI,CAACP,MAAM;IAClC;AACJ"}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { StatusMessage } from '@inkjs/ui';
|
2
|
+
import { Text } from 'ink';
|
3
|
+
import React from 'react';
|
4
|
+
import { HealthCheckStatus } from '@/cli/types.js';
|
5
|
+
const SuccessMessages = {
|
6
|
+
configurationFilePresent: {
|
7
|
+
[HealthCheckStatus.Unknown]: 'Configuration file status unknown',
|
8
|
+
[HealthCheckStatus.Healthy]: 'Configuration file found',
|
9
|
+
[HealthCheckStatus.Unhealthy]: 'Configuration file not found'
|
10
|
+
},
|
11
|
+
configurationFileValid: {
|
12
|
+
[HealthCheckStatus.Unknown]: 'Configuration file validity unknown',
|
13
|
+
[HealthCheckStatus.Healthy]: 'Configuration file is valid',
|
14
|
+
[HealthCheckStatus.Unhealthy]: 'Configuration file is invalid'
|
15
|
+
},
|
16
|
+
sdkPathKnown: {
|
17
|
+
[HealthCheckStatus.Unknown]: 'SDK path status unknown',
|
18
|
+
[HealthCheckStatus.Healthy]: 'SDK path found',
|
19
|
+
[HealthCheckStatus.Unhealthy]: 'SDK path not found'
|
20
|
+
}
|
21
|
+
};
|
22
|
+
const ColorMap = {
|
23
|
+
[HealthCheckStatus.Healthy]: 'green',
|
24
|
+
[HealthCheckStatus.Unhealthy]: 'red',
|
25
|
+
[HealthCheckStatus.Unknown]: 'gray'
|
26
|
+
};
|
27
|
+
export const HealthReport = ({ health })=>{
|
28
|
+
return Object.keys(health).map((eachKey)=>{
|
29
|
+
const healthKey = eachKey;
|
30
|
+
const keyHealth = health[healthKey];
|
31
|
+
let variant = 'info';
|
32
|
+
if (health[healthKey] === HealthCheckStatus.Unhealthy) {
|
33
|
+
variant = 'error';
|
34
|
+
}
|
35
|
+
if (health[healthKey] === HealthCheckStatus.Healthy) {
|
36
|
+
variant = 'success';
|
37
|
+
}
|
38
|
+
return /*#__PURE__*/ React.createElement(StatusMessage, {
|
39
|
+
key: healthKey,
|
40
|
+
variant: variant
|
41
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
42
|
+
color: ColorMap[keyHealth]
|
43
|
+
}, keyHealth === HealthCheckStatus.Unhealthy && ' ', SuccessMessages[healthKey][keyHealth]));
|
44
|
+
});
|
45
|
+
};
|
46
|
+
|
47
|
+
//# sourceMappingURL=HealthReport.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/components/HealthReport.tsx"],"sourcesContent":["import { StatusMessage, StatusMessageProps } from '@inkjs/ui';\nimport { Text, TextProps } from 'ink';\nimport React from 'react';\nimport { EnvironmentHealth, HealthCheckStatus } from '@/cli/types.js';\n\ninterface Props {\n health: EnvironmentHealth;\n}\n\nconst SuccessMessages = {\n configurationFilePresent: {\n [HealthCheckStatus.Unknown]: 'Configuration file status unknown',\n [HealthCheckStatus.Healthy]: 'Configuration file found',\n [HealthCheckStatus.Unhealthy]: 'Configuration file not found',\n },\n configurationFileValid: {\n [HealthCheckStatus.Unknown]: 'Configuration file validity unknown',\n [HealthCheckStatus.Healthy]: 'Configuration file is valid',\n [HealthCheckStatus.Unhealthy]: 'Configuration file is invalid',\n },\n sdkPathKnown: {\n [HealthCheckStatus.Unknown]: 'SDK path status unknown',\n [HealthCheckStatus.Healthy]: 'SDK path found',\n [HealthCheckStatus.Unhealthy]: 'SDK path not found',\n },\n} satisfies {\n [key in keyof EnvironmentHealth]: {\n [HealthCheckStatus.Unknown]: string;\n [HealthCheckStatus.Healthy]: string;\n [HealthCheckStatus.Unhealthy]: string;\n };\n};\n\nconst ColorMap = {\n [HealthCheckStatus.Healthy]: 'green',\n [HealthCheckStatus.Unhealthy]: 'red',\n [HealthCheckStatus.Unknown]: 'gray',\n} satisfies {\n [key in HealthCheckStatus]: TextProps['color'];\n};\n\nexport const HealthReport = ({ health }: Props) => {\n return Object.keys(health).map((eachKey) => {\n const healthKey = eachKey as keyof EnvironmentHealth;\n const keyHealth = health[healthKey];\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (health[healthKey] === HealthCheckStatus.Unhealthy) {\n variant = 'error';\n }\n\n if (health[healthKey] === HealthCheckStatus.Healthy) {\n variant = 'success';\n }\n\n return (\n <StatusMessage key={healthKey} variant={variant}>\n <Text color={ColorMap[keyHealth]}>\n {keyHealth === HealthCheckStatus.Unhealthy && ' '}\n {SuccessMessages[healthKey][keyHealth]}\n </Text>\n </StatusMessage>\n );\n });\n};\n"],"names":["StatusMessage","Text","React","HealthCheckStatus","SuccessMessages","configurationFilePresent","Unknown","Healthy","Unhealthy","configurationFileValid","sdkPathKnown","ColorMap","HealthReport","health","Object","keys","map","eachKey","healthKey","keyHealth","variant","key","color"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAA4B,YAAY;AAC9D,SAASC,IAAI,QAAmB,MAAM;AACtC,OAAOC,WAAW,QAAQ;AAC1B,SAA4BC,iBAAiB,QAAQ,iBAAiB;AAMtE,MAAMC,kBAAkB;IACpBC,0BAA0B;QACtB,CAACF,kBAAkBG,OAAO,CAAC,EAAE;QAC7B,CAACH,kBAAkBI,OAAO,CAAC,EAAE;QAC7B,CAACJ,kBAAkBK,SAAS,CAAC,EAAE;IACnC;IACAC,wBAAwB;QACpB,CAACN,kBAAkBG,OAAO,CAAC,EAAE;QAC7B,CAACH,kBAAkBI,OAAO,CAAC,EAAE;QAC7B,CAACJ,kBAAkBK,SAAS,CAAC,EAAE;IACnC;IACAE,cAAc;QACV,CAACP,kBAAkBG,OAAO,CAAC,EAAE;QAC7B,CAACH,kBAAkBI,OAAO,CAAC,EAAE;QAC7B,CAACJ,kBAAkBK,SAAS,CAAC,EAAE;IACnC;AACJ;AAQA,MAAMG,WAAW;IACb,CAACR,kBAAkBI,OAAO,CAAC,EAAE;IAC7B,CAACJ,kBAAkBK,SAAS,CAAC,EAAE;IAC/B,CAACL,kBAAkBG,OAAO,CAAC,EAAE;AACjC;AAIA,OAAO,MAAMM,eAAe,CAAC,EAAEC,MAAM,EAAS;IAC1C,OAAOC,OAAOC,IAAI,CAACF,QAAQG,GAAG,CAAC,CAACC;QAC5B,MAAMC,YAAYD;QAClB,MAAME,YAAYN,MAAM,CAACK,UAAU;QACnC,IAAIE,UAAyC;QAE7C,IAAIP,MAAM,CAACK,UAAU,KAAKf,kBAAkBK,SAAS,EAAE;YACnDY,UAAU;QACd;QAEA,IAAIP,MAAM,CAACK,UAAU,KAAKf,kBAAkBI,OAAO,EAAE;YACjDa,UAAU;QACd;QAEA,qBACI,oBAACpB;YAAcqB,KAAKH;YAAWE,SAASA;yBACpC,oBAACnB;YAAKqB,OAAOX,QAAQ,CAACQ,UAAU;WAC3BA,cAAchB,kBAAkBK,SAAS,IAAI,KAC7CJ,eAAe,CAACc,UAAU,CAACC,UAAU;IAItD;AACJ,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './EnvironmentAwareCommand.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/index.ts"],"sourcesContent":["export * from './EnvironmentAwareCommand.js';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,+BAA+B"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';
|
3
|
+
import { Environment } from '@/cli/environment/dto/Environment.js';
|
4
|
+
export declare class GenerateTypesCommand extends EnvironmentAwareCommand {
|
5
|
+
static paths: string[][];
|
6
|
+
static usage: import("clipanion").Usage;
|
7
|
+
version: any;
|
8
|
+
renderWithEnvironment(environment: Environment): React.JSX.Element;
|
9
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { Command, Option } from 'clipanion';
|
2
|
+
import React from 'react';
|
3
|
+
import * as t from 'typanion';
|
4
|
+
import { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';
|
5
|
+
import { PlaydateSdkVersionIdentifier } from '@/cli/types.js';
|
6
|
+
import { GenerateTypes } from './components/GenerateTypes.js';
|
7
|
+
export class GenerateTypesCommand extends EnvironmentAwareCommand {
|
8
|
+
renderWithEnvironment(environment) {
|
9
|
+
return /*#__PURE__*/ React.createElement(GenerateTypes, {
|
10
|
+
version: this.version === PlaydateSdkVersionIdentifier.FromConfig ? environment.configuration.version : this.version
|
11
|
+
});
|
12
|
+
}
|
13
|
+
constructor(...args){
|
14
|
+
super(...args);
|
15
|
+
this.version = Option.String('-v,--version', PlaydateSdkVersionIdentifier.FromConfig, {
|
16
|
+
description: 'The version',
|
17
|
+
validator: t.isOneOf([
|
18
|
+
t.isLiteral(PlaydateSdkVersionIdentifier.FromConfig),
|
19
|
+
t.matchesRegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
20
|
+
])
|
21
|
+
});
|
22
|
+
}
|
23
|
+
}
|
24
|
+
GenerateTypesCommand.paths = [
|
25
|
+
[
|
26
|
+
'generate-types'
|
27
|
+
]
|
28
|
+
];
|
29
|
+
GenerateTypesCommand.usage = Command.Usage({
|
30
|
+
description: 'Generate types from the Playdate SDK documentation'
|
31
|
+
});
|
32
|
+
|
33
|
+
//# sourceMappingURL=GenerateTypesCommand.js.map
|
@@ -0,0 +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 '-v,--version',\n PlaydateSdkVersionIdentifier.FromConfig,\n {\n description: 'The version',\n validator: t.isOneOf([\n t.isLiteral(PlaydateSdkVersionIdentifier.FromConfig),\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","description","validator","isOneOf","isLiteral","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;IAoB7BI,sBAAsBC,WAAwB,EAAE;QACrD,qBACI,oBAACH;YACGI,SACI,IAAI,CAACA,OAAO,KAAKL,6BAA6BM,UAAU,GAClDF,YAAYG,aAAa,CAACF,OAAO,GACjC,IAAI,CAACA,OAAO;;IAIlC;;;aAxBAA,UAAUT,OAAOY,MAAM,CACnB,gBACAR,6BAA6BM,UAAU,EACvC;YACIG,aAAa;YACbC,WAAWZ,EAAEa,OAAO,CAAC;gBACjBb,EAAEc,SAAS,CAACZ,6BAA6BM,UAAU;gBACnDR,EAAEe,aAAa,CACX;aAEP;QACL;;AAcR;AA/BaX,qBACOY,QAAQ;IAAC;QAAC;KAAiB;CAAC;AADnCZ,qBAEOa,QAAQpB,QAAQqB,KAAK,CAAC;IAClCP,aAAa;AACjB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import { Text } from 'ink';\nimport React from 'react';\n\ninterface Props {\n version: string;\n}\n\nexport const GenerateTypes = ({ version }: Props) => {\n return <Text>{version}</Text>;\n};\n"],"names":["Text","React","GenerateTypes","version"],"rangeMappings":";;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,MAAM;AAC3B,OAAOC,WAAW,QAAQ;AAM1B,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,OAAO,EAAS;IAC5C,qBAAO,oBAACH,YAAMG;AAClB,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './GenerateTypesCommand.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/GenerateTypes/index.ts"],"sourcesContent":["export * from './GenerateTypesCommand.js';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,4BAA4B"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Command } from 'clipanion';
|
2
|
+
import { render } from 'ink';
|
3
|
+
export class RenderableCommand extends Command {
|
4
|
+
renderElement(element) {
|
5
|
+
render(element);
|
6
|
+
}
|
7
|
+
async execute() {
|
8
|
+
this.renderElement(this.render());
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
//# sourceMappingURL=RenderableCommand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/cli/src/commands/RenderableCommand.ts"],"sourcesContent":["import { Command } from 'clipanion';\nimport { render } from 'ink';\nimport { JSX } from 'react';\n\nexport abstract class RenderableCommand extends Command {\n protected abstract render(): JSX.Element;\n\n protected renderElement(element: JSX.Element) {\n render(element);\n }\n\n override async execute() {\n this.renderElement(this.render());\n }\n}\n"],"names":["Command","render","RenderableCommand","renderElement","element","execute"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SAASC,MAAM,QAAQ,MAAM;AAG7B,OAAO,MAAeC,0BAA0BF;IAGlCG,cAAcC,OAAoB,EAAE;QAC1CH,OAAOG;IACX;IAEA,MAAeC,UAAU;QACrB,IAAI,CAACF,aAAa,CAAC,IAAI,CAACF,MAAM;IAClC;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const CrankscriptConfigurationFileName = "crankscript.json";
|
package/src/constants.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["export const CrankscriptConfigurationFileName = 'crankscript.json';\n"],"names":["CrankscriptConfigurationFileName"],"rangeMappings":"","mappings":"AAAA,OAAO,MAAMA,mCAAmC,mBAAmB"}
|
@@ -0,0 +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":";;;","mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,sBAAsBD,EAAEE,MAAM,CAAC;IACxCC,SAASH,EAAEI,MAAM,GAAGC,KAAK,CAAC;AAC9B,GAAG"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/environment/configuration/dto/Configuration.ts"],"sourcesContent":["export class Configuration {\n public constructor(public readonly version: string) {}\n}\n"],"names":["Configuration","version"],"rangeMappings":";;;;","mappings":"AAAA,OAAO,MAAMA;IACT,YAAmB,AAAgBC,OAAe,CAAE;aAAjBA,UAAAA;IAAkB;AACzD"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { EnvironmentError } from '../../error/EnvironmentError.js';
|
2
|
+
export class ConfigurationFileNotFoundError extends EnvironmentError {
|
3
|
+
constructor(){
|
4
|
+
super('Configuration file not found');
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
//# sourceMappingURL=ConfigurationFileNotFoundError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/environment/configuration/error/ConfigurationFileNotFoundError.ts"],"sourcesContent":["import { EnvironmentError } from '../../error/EnvironmentError.js';\n\nexport class ConfigurationFileNotFoundError extends EnvironmentError {\n public constructor() {\n super('Configuration file not found');\n }\n}\n"],"names":["EnvironmentError","ConfigurationFileNotFoundError"],"rangeMappings":";;;;;","mappings":"AAAA,SAASA,gBAAgB,QAAQ,kCAAkC;AAEnE,OAAO,MAAMC,uCAAuCD;IAChD,aAAqB;QACjB,KAAK,CAAC;IACV;AACJ"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ConfigurationFileValidationErrorType } from '../../../types.js';
|
2
|
+
import { EnvironmentError } from '../../error/EnvironmentError.js';
|
3
|
+
export declare class ConfigurationFileValidationError extends EnvironmentError {
|
4
|
+
constructor(errorType: ConfigurationFileValidationErrorType, reason?: string);
|
5
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { EnvironmentError } from '../../error/EnvironmentError.js';
|
2
|
+
export class ConfigurationFileValidationError extends EnvironmentError {
|
3
|
+
constructor(errorType, reason = 'Unknown reason'){
|
4
|
+
super(`Configuration file is invalid (${errorType}): ${reason}`);
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
//# sourceMappingURL=ConfigurationFileValidationError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/environment/configuration/error/ConfigurationFileValidationError.ts"],"sourcesContent":["import { ConfigurationFileValidationErrorType } from '../../../types.js';\nimport { EnvironmentError } from '../../error/EnvironmentError.js';\n\nexport class ConfigurationFileValidationError extends EnvironmentError {\n public constructor(\n errorType: ConfigurationFileValidationErrorType,\n reason = 'Unknown reason'\n ) {\n super(`Configuration file is invalid (${errorType}): ${reason}`);\n }\n}\n"],"names":["EnvironmentError","ConfigurationFileValidationError","errorType","reason"],"rangeMappings":";;;;;","mappings":"AACA,SAASA,gBAAgB,QAAQ,kCAAkC;AAEnE,OAAO,MAAMC,yCAAyCD;IAClD,YACIE,SAA+C,EAC/CC,SAAS,gBAAgB,CAC3B;QACE,KAAK,CAAC,CAAC,+BAA+B,EAAED,UAAU,GAAG,EAAEC,OAAO,CAAC;IACnE;AACJ"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { readFileSync } from 'fs';
|
2
|
+
import { join } from 'node:path';
|
3
|
+
import * as process from 'node:process';
|
4
|
+
import { ConfigurationSchema } from './ConfigurationSchema.js';
|
5
|
+
import { CrankscriptConfigurationFileName } from '../../constants.js';
|
6
|
+
import { ConfigurationFileNotFoundError } from './error/ConfigurationFileNotFoundError.js';
|
7
|
+
import { ConfigurationFileValidationError } from './error/ConfigurationFileValidationError.js';
|
8
|
+
import { ConfigurationFileValidationErrorType } from '../../types.js';
|
9
|
+
export const getConfiguration = (input)=>{
|
10
|
+
const { workingDirectory = process.cwd() } = input != null ? input : {};
|
11
|
+
const configurationFilePath = join(workingDirectory, CrankscriptConfigurationFileName);
|
12
|
+
let contents = '';
|
13
|
+
let parsedObject;
|
14
|
+
try {
|
15
|
+
contents = readFileSync(configurationFilePath, 'utf8');
|
16
|
+
} catch (error) {
|
17
|
+
throw new ConfigurationFileNotFoundError();
|
18
|
+
}
|
19
|
+
try {
|
20
|
+
parsedObject = JSON.parse(contents);
|
21
|
+
} catch (error) {
|
22
|
+
throw new ConfigurationFileValidationError(ConfigurationFileValidationErrorType.InvalidJson, !!error && typeof error === 'object' && 'message' in error && typeof error.message === 'string' ? error.message : 'Error parsing JSON');
|
23
|
+
}
|
24
|
+
const validation = ConfigurationSchema.safeParse(parsedObject);
|
25
|
+
if (!validation.success) {
|
26
|
+
throw new ConfigurationFileValidationError(ConfigurationFileValidationErrorType.InvalidSchema, validation.error.errors.join(', '));
|
27
|
+
}
|
28
|
+
return validation.data;
|
29
|
+
};
|
30
|
+
|
31
|
+
//# sourceMappingURL=getConfiguration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/environment/configuration/getConfiguration.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport * as process from 'node:process';\nimport { ConfigurationSchema } from './ConfigurationSchema.js';\nimport { CrankscriptConfigurationFileName } from '../../constants.js';\nimport { ConfigurationFileNotFoundError } from './error/ConfigurationFileNotFoundError.js';\nimport { ConfigurationFileValidationError } from './error/ConfigurationFileValidationError.js';\nimport { ConfigurationFileValidationErrorType } from '../../types.js';\nimport { Configuration } from './dto/Configuration.js';\n\nexport const getConfiguration = (input?: {\n workingDirectory: string;\n}): Configuration => {\n const { workingDirectory = process.cwd() } = input ?? {};\n const configurationFilePath = join(\n workingDirectory,\n CrankscriptConfigurationFileName\n );\n let contents = '';\n let parsedObject: object;\n\n try {\n contents = readFileSync(configurationFilePath, 'utf8');\n } catch (error) {\n throw new ConfigurationFileNotFoundError();\n }\n\n try {\n parsedObject = JSON.parse(contents);\n } catch (error) {\n throw new ConfigurationFileValidationError(\n ConfigurationFileValidationErrorType.InvalidJson,\n !!error &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ? error.message\n : 'Error parsing JSON'\n );\n }\n\n const validation = ConfigurationSchema.safeParse(parsedObject);\n\n if (!validation.success) {\n throw new ConfigurationFileValidationError(\n ConfigurationFileValidationErrorType.InvalidSchema,\n validation.error.errors.join(', ')\n );\n }\n\n return validation.data;\n};\n"],"names":["readFileSync","join","process","ConfigurationSchema","CrankscriptConfigurationFileName","ConfigurationFileNotFoundError","ConfigurationFileValidationError","ConfigurationFileValidationErrorType","getConfiguration","input","workingDirectory","cwd","configurationFilePath","contents","parsedObject","error","JSON","parse","InvalidJson","message","validation","safeParse","success","InvalidSchema","errors","data"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,YAAYC,aAAa,eAAe;AACxC,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,gCAAgC,QAAQ,qBAAqB;AACtE,SAASC,8BAA8B,QAAQ,4CAA4C;AAC3F,SAASC,gCAAgC,QAAQ,8CAA8C;AAC/F,SAASC,oCAAoC,QAAQ,iBAAiB;AAGtE,OAAO,MAAMC,mBAAmB,CAACC;IAG7B,MAAM,EAAEC,mBAAmBR,QAAQS,GAAG,EAAE,EAAE,GAAGF,gBAAAA,QAAS,CAAC;IACvD,MAAMG,wBAAwBX,KAC1BS,kBACAN;IAEJ,IAAIS,WAAW;IACf,IAAIC;IAEJ,IAAI;QACAD,WAAWb,aAAaY,uBAAuB;IACnD,EAAE,OAAOG,OAAO;QACZ,MAAM,IAAIV;IACd;IAEA,IAAI;QACAS,eAAeE,KAAKC,KAAK,CAACJ;IAC9B,EAAE,OAAOE,OAAO;QACZ,MAAM,IAAIT,iCACNC,qCAAqCW,WAAW,EAChD,CAAC,CAACH,SACF,OAAOA,UAAU,YACjB,aAAaA,SACb,OAAOA,MAAMI,OAAO,KAAK,WACnBJ,MAAMI,OAAO,GACb;IAEd;IAEA,MAAMC,aAAajB,oBAAoBkB,SAAS,CAACP;IAEjD,IAAI,CAACM,WAAWE,OAAO,EAAE;QACrB,MAAM,IAAIhB,iCACNC,qCAAqCgB,aAAa,EAClDH,WAAWL,KAAK,CAACS,MAAM,CAACvB,IAAI,CAAC;IAErC;IAEA,OAAOmB,WAAWK,IAAI;AAC1B,EAAE"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { EnvironmentHealthResult } from '../types.js';
|
2
|
+
/**
|
3
|
+
* Will create a configuration object from the environment.
|
4
|
+
*/
|
5
|
+
export declare const createEnvironment: (input?: {
|
6
|
+
/**
|
7
|
+
* The environment to create the configuration from.
|
8
|
+
*
|
9
|
+
* Defaults to `process.env`.
|
10
|
+
*/
|
11
|
+
environment: Record<string, unknown>;
|
12
|
+
}) => EnvironmentHealthResult;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { HealthCheckStatus } from '../types.js';
|
2
|
+
import { ConfigurationFileNotFoundError } from './configuration/error/ConfigurationFileNotFoundError.js';
|
3
|
+
import { ConfigurationFileValidationError } from './configuration/error/ConfigurationFileValidationError.js';
|
4
|
+
import { getConfiguration } from './configuration/getConfiguration.js';
|
5
|
+
import { Environment } from './dto/Environment.js';
|
6
|
+
import { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';
|
7
|
+
/**
|
8
|
+
* Will create a configuration object from the environment.
|
9
|
+
*/ export const createEnvironment = (input)=>{
|
10
|
+
const { environment = process.env } = input != null ? input : {};
|
11
|
+
let configuration;
|
12
|
+
let sdkPath;
|
13
|
+
try {
|
14
|
+
configuration = getConfiguration();
|
15
|
+
} catch (error) {
|
16
|
+
return {
|
17
|
+
isHealthy: false,
|
18
|
+
health: {
|
19
|
+
configurationFilePresent: error instanceof ConfigurationFileNotFoundError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.Healthy,
|
20
|
+
configurationFileValid: error instanceof ConfigurationFileValidationError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.Healthy,
|
21
|
+
sdkPathKnown: HealthCheckStatus.Unknown
|
22
|
+
}
|
23
|
+
};
|
24
|
+
}
|
25
|
+
try {
|
26
|
+
sdkPath = getPlaydateSdkPath({
|
27
|
+
environment
|
28
|
+
});
|
29
|
+
} catch (error) {
|
30
|
+
return {
|
31
|
+
isHealthy: false,
|
32
|
+
health: {
|
33
|
+
configurationFilePresent: HealthCheckStatus.Healthy,
|
34
|
+
configurationFileValid: HealthCheckStatus.Healthy,
|
35
|
+
sdkPathKnown: HealthCheckStatus.Unhealthy
|
36
|
+
}
|
37
|
+
};
|
38
|
+
}
|
39
|
+
return {
|
40
|
+
isHealthy: true,
|
41
|
+
environment: new Environment({
|
42
|
+
configuration,
|
43
|
+
sdkPath
|
44
|
+
}),
|
45
|
+
health: {
|
46
|
+
configurationFilePresent: HealthCheckStatus.Healthy,
|
47
|
+
configurationFileValid: HealthCheckStatus.Healthy,
|
48
|
+
sdkPathKnown: HealthCheckStatus.Healthy
|
49
|
+
}
|
50
|
+
};
|
51
|
+
};
|
52
|
+
|
53
|
+
//# sourceMappingURL=createEnvironment.js.map
|
@@ -0,0 +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.Healthy,\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","sdkPathKnown","Unknown"],"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,mCACXF,kBAAkBiB,SAAS,GAC3BjB,kBAAkBkB,OAAO;gBACnCE,cAAcpB,kBAAkBqB,OAAO;YAC3C;QACJ;IACJ;IAEA,IAAI;QACAT,UAAUP,mBAAmB;YAAEG;QAAY;IAC/C,EAAE,OAAOK,OAAO;QACZ,OAAO;YACHC,WAAW;YACXC,QAAQ;gBACJC,0BAA0BhB,kBAAkBkB,OAAO;gBACnDC,wBAAwBnB,kBAAkBkB,OAAO;gBACjDE,cAAcpB,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;YACjDE,cAAcpB,kBAAkBkB,OAAO;QAC3C;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ConfigurationType } from '../configuration/ConfigurationSchema.js';
|
2
|
+
import { PlaydateSdkPath } from '../path/dto/PlaydateSdkPath.js';
|
3
|
+
export declare class Environment {
|
4
|
+
configuration: ConfigurationType;
|
5
|
+
sdkPath: PlaydateSdkPath;
|
6
|
+
constructor({ configuration, sdkPath, }: {
|
7
|
+
configuration: ConfigurationType;
|
8
|
+
sdkPath: PlaydateSdkPath;
|
9
|
+
});
|
10
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/environment/dto/Environment.ts"],"sourcesContent":["import { ConfigurationType } from '../configuration/ConfigurationSchema.js';\nimport { PlaydateSdkPath } from '../path/dto/PlaydateSdkPath.js';\n\nexport class Environment {\n configuration: ConfigurationType;\n sdkPath: PlaydateSdkPath;\n\n public constructor({\n configuration,\n sdkPath,\n }: {\n configuration: ConfigurationType;\n sdkPath: PlaydateSdkPath;\n }) {\n this.configuration = configuration;\n this.sdkPath = sdkPath;\n }\n}\n"],"names":["Environment","configuration","sdkPath"],"rangeMappings":";;;;;","mappings":"AAGA,OAAO,MAAMA;IAIT,YAAmB,EACfC,aAAa,EACbC,OAAO,EAIV,CAAE;QACC,IAAI,CAACD,aAAa,GAAGA;QACrB,IAAI,CAACC,OAAO,GAAGA;IACnB;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/environment/error/EnvironmentError.ts"],"sourcesContent":["export class EnvironmentError extends Error {}\n"],"names":["EnvironmentError","Error"],"rangeMappings":";","mappings":"AAAA,OAAO,MAAMA,yBAAyBC;AAAO"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/environment/path/dto/PlaydateSdkPath.ts"],"sourcesContent":["export class PlaydateSdkPath {\n private constructor(public readonly path: string) {}\n\n public static fromString(path: string): PlaydateSdkPath {\n return new PlaydateSdkPath(path);\n }\n}\n"],"names":["PlaydateSdkPath","fromString","path"],"rangeMappings":";;;;;;;","mappings":"AAAA,OAAO,MAAMA;IAGT,OAAcC,WAAWC,IAAY,EAAmB;QACpD,OAAO,IAAIF,gBAAgBE;IAC/B;IAJA,YAAoB,AAAgBA,IAAY,CAAE;aAAdA,OAAAA;IAAe;AAKvD"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { EnvironmentError } from '../../error/EnvironmentError.js';
|
2
|
+
export class PlaydateSdkPathVariableNotSetError extends EnvironmentError {
|
3
|
+
constructor(){
|
4
|
+
super('Playdate SDK path variable not set.');
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
//# sourceMappingURL=PlaydateSdkPathVariableNotSetError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/environment/path/error/PlaydateSdkPathVariableNotSetError.ts"],"sourcesContent":["import { EnvironmentError } from '../../error/EnvironmentError.js';\n\nexport class PlaydateSdkPathVariableNotSetError extends EnvironmentError {\n constructor() {\n super('Playdate SDK path variable not set.');\n }\n}\n"],"names":["EnvironmentError","PlaydateSdkPathVariableNotSetError","constructor"],"rangeMappings":";;;;;","mappings":"AAAA,SAASA,gBAAgB,QAAQ,kCAAkC;AAEnE,OAAO,MAAMC,2CAA2CD;IACpDE,aAAc;QACV,KAAK,CAAC;IACV;AACJ"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { PlaydateSdkPath } from './dto/PlaydateSdkPath.js';
|
2
|
+
/**
|
3
|
+
* Get the path to the Playdate SDK from the environment.
|
4
|
+
*
|
5
|
+
* @throws {PlaydateSdkPathVariableNotSetError} Thrown if the PLAYDATE_SDK_PATH environment variable is not set.
|
6
|
+
*/
|
7
|
+
export declare const getPlaydateSdkPath: (input: {
|
8
|
+
/**
|
9
|
+
* The environment to get the Playdate SDK path from.
|
10
|
+
*
|
11
|
+
* Defaults to `process.env`.
|
12
|
+
*/
|
13
|
+
environment: Record<string, unknown>;
|
14
|
+
}) => PlaydateSdkPath;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import * as process from 'node:process';
|
2
|
+
import { PlaydateSdkPath } from './dto/PlaydateSdkPath.js';
|
3
|
+
import { PlaydateSdkPathVariableNotSetError } from './error/PlaydateSdkPathVariableNotSetError.js';
|
4
|
+
/**
|
5
|
+
* Get the path to the Playdate SDK from the environment.
|
6
|
+
*
|
7
|
+
* @throws {PlaydateSdkPathVariableNotSetError} Thrown if the PLAYDATE_SDK_PATH environment variable is not set.
|
8
|
+
*/ export const getPlaydateSdkPath = (input)=>{
|
9
|
+
const { environment = process.env } = input;
|
10
|
+
if (!('PLAYDATE_SDK_PATH' in environment)) {
|
11
|
+
throw new PlaydateSdkPathVariableNotSetError();
|
12
|
+
}
|
13
|
+
return PlaydateSdkPath.fromString(environment['PLAYDATE_SDK_PATH']);
|
14
|
+
};
|
15
|
+
|
16
|
+
//# sourceMappingURL=getPlaydateSdkPath.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/environment/path/getPlaydateSdkPath.ts"],"sourcesContent":["import * as process from 'node:process';\nimport { PlaydateSdkPath } from './dto/PlaydateSdkPath.js';\nimport { PlaydateSdkPathVariableNotSetError } from './error/PlaydateSdkPathVariableNotSetError.js';\n\n/**\n * Get the path to the Playdate SDK from the environment.\n *\n * @throws {PlaydateSdkPathVariableNotSetError} Thrown if the PLAYDATE_SDK_PATH environment variable is not set.\n */\nexport const getPlaydateSdkPath = (input: {\n /**\n * The environment to get the Playdate SDK path from.\n *\n * Defaults to `process.env`.\n */\n environment: Record<string, unknown>;\n}) => {\n const { environment = process.env } = input;\n\n if (!('PLAYDATE_SDK_PATH' in environment)) {\n throw new PlaydateSdkPathVariableNotSetError();\n }\n\n return PlaydateSdkPath.fromString(\n environment['PLAYDATE_SDK_PATH'] as string\n );\n};\n"],"names":["process","PlaydateSdkPath","PlaydateSdkPathVariableNotSetError","getPlaydateSdkPath","input","environment","env","fromString"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAAA,YAAYA,aAAa,eAAe;AACxC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,kCAAkC,QAAQ,gDAAgD;AAEnG;;;;CAIC,GACD,OAAO,MAAMC,qBAAqB,CAACC;IAQ/B,MAAM,EAAEC,cAAcL,QAAQM,GAAG,EAAE,GAAGF;IAEtC,IAAI,CAAE,CAAA,uBAAuBC,WAAU,GAAI;QACvC,MAAM,IAAIH;IACd;IAEA,OAAOD,gBAAgBM,UAAU,CAC7BF,WAAW,CAAC,oBAAoB;AAExC,EAAE"}
|
package/src/index.js
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
|
8
|
-
const packageJsonContents = readFileSync(join(
|
2
|
+
import { readFileSync } from 'fs';
|
3
|
+
import { join } from 'node:path';
|
4
|
+
import { Cli } from 'clipanion';
|
5
|
+
import { DoctorCommand } from '@/cli/commands/DoctorCommand.js';
|
6
|
+
import { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';
|
7
|
+
import { RootFolder } from '@/cli/utils/dirname.js';
|
8
|
+
const packageJsonContents = readFileSync(join(RootFolder, 'package.json'), 'utf-8');
|
9
9
|
const packageJson = JSON.parse(packageJsonContents);
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
const args = process.argv.slice(2);
|
11
|
+
const cli = new Cli({
|
12
|
+
binaryLabel: 'crankscript',
|
13
|
+
binaryName: 'crankscript',
|
14
|
+
binaryVersion: packageJson.version
|
15
|
+
});
|
16
|
+
cli.register(DoctorCommand);
|
17
|
+
cli.register(GenerateTypesCommand);
|
18
|
+
cli.runExit(args);
|
15
19
|
|
16
20
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Cli } from 'clipanion';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';\nimport { RootFolder } from '@/cli/utils/dirname.js';\n\nconst packageJsonContents = readFileSync(\n join(RootFolder, 'package.json'),\n 'utf-8'\n);\nconst packageJson = JSON.parse(packageJsonContents);\n\nconst args = process.argv.slice(2);\n\nconst cli = new Cli({\n binaryLabel: 'crankscript',\n binaryName: 'crankscript',\n binaryVersion: packageJson.version,\n});\n\ncli.register(DoctorCommand);\ncli.register(GenerateTypesCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","DoctorCommand","GenerateTypesCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","register","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,YAAY;AAChC,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,uDAAuD;AAC5F,SAASC,UAAU,QAAQ,yBAAyB;AAEpD,MAAMC,sBAAsBN,aACxBC,KAAKI,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIZ,IAAI;IAChBa,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAJ,IAAIK,QAAQ,CAAChB;AACbW,IAAIK,QAAQ,CAACf;AACbU,IAAIM,OAAO,CAACV"}
|
package/src/types.d.ts
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Environment } from '@/cli/environment/dto/Environment.js';
|
2
|
+
export declare enum PlaydateSdkVersionIdentifier {
|
3
|
+
FromConfig = "FromConfig"
|
4
|
+
}
|
5
|
+
export type EnvironmentHealthResult = {
|
6
|
+
isHealthy: true;
|
7
|
+
environment: Environment;
|
8
|
+
health: EnvironmentHealth;
|
9
|
+
} | {
|
10
|
+
isHealthy: false;
|
11
|
+
health: EnvironmentHealth;
|
12
|
+
};
|
13
|
+
export declare enum HealthCheckStatus {
|
14
|
+
Healthy = "Healthy",
|
15
|
+
Unhealthy = "Unhealthy",
|
16
|
+
Unknown = "Unknown"
|
17
|
+
}
|
18
|
+
export interface EnvironmentHealth {
|
19
|
+
configurationFilePresent: HealthCheckStatus;
|
20
|
+
configurationFileValid: HealthCheckStatus;
|
21
|
+
sdkPathKnown: HealthCheckStatus;
|
22
|
+
}
|
23
|
+
export declare enum ConfigurationFileValidationErrorType {
|
24
|
+
InvalidJson = "InvalidJson",
|
25
|
+
InvalidSchema = "InvalidSchema"
|
26
|
+
}
|
package/src/types.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
export var PlaydateSdkVersionIdentifier;
|
2
|
+
(function(PlaydateSdkVersionIdentifier) {
|
3
|
+
PlaydateSdkVersionIdentifier["FromConfig"] = "FromConfig";
|
4
|
+
})(PlaydateSdkVersionIdentifier || (PlaydateSdkVersionIdentifier = {}));
|
5
|
+
export var HealthCheckStatus;
|
6
|
+
(function(HealthCheckStatus) {
|
7
|
+
HealthCheckStatus["Healthy"] = "Healthy";
|
8
|
+
HealthCheckStatus["Unhealthy"] = "Unhealthy";
|
9
|
+
HealthCheckStatus["Unknown"] = "Unknown";
|
10
|
+
})(HealthCheckStatus || (HealthCheckStatus = {}));
|
11
|
+
export var ConfigurationFileValidationErrorType;
|
12
|
+
(function(ConfigurationFileValidationErrorType) {
|
13
|
+
ConfigurationFileValidationErrorType["InvalidJson"] = "InvalidJson";
|
14
|
+
ConfigurationFileValidationErrorType["InvalidSchema"] = "InvalidSchema";
|
15
|
+
})(ConfigurationFileValidationErrorType || (ConfigurationFileValidationErrorType = {}));
|
16
|
+
|
17
|
+
//# sourceMappingURL=types.js.map
|
package/src/types.js.map
ADDED
@@ -0,0 +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":";;;;;;;;;;;;;;","mappings":";UAEYA;;GAAAA,iCAAAA;;UAeAC;;;;GAAAA,sBAAAA;;UAYAC;;;GAAAA,yCAAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const RootFolder: string;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/cli/src/utils/dirname.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const RootFolder = join(__dirname, '..', '..');\n"],"names":["dirname","join","fileURLToPath","__dirname","url","RootFolder"],"rangeMappings":";;;","mappings":"AAAA,SAASA,OAAO,EAAEC,IAAI,QAAQ,YAAY;AAC1C,SAASC,aAAa,QAAQ,WAAW;AAEzC,MAAMC,YAAYH,QAAQE,cAAc,YAAYE,GAAG;AAEvD,OAAO,MAAMC,aAAaJ,KAAKE,WAAW,MAAM,MAAM"}
|