crankscript 0.1.2 → 0.3.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.
Files changed (81) hide show
  1. package/package.json +10 -3
  2. package/src/commands/DoctorCommand.d.ts +7 -0
  3. package/src/commands/DoctorCommand.js +26 -0
  4. package/src/commands/DoctorCommand.js.map +1 -0
  5. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +9 -0
  6. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +25 -0
  7. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js.map +1 -0
  8. package/src/commands/EnvironmentAwareCommand/components/HealthReport.d.ts +7 -0
  9. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js +47 -0
  10. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js.map +1 -0
  11. package/src/commands/EnvironmentAwareCommand/index.d.ts +1 -0
  12. package/src/commands/EnvironmentAwareCommand/index.js +3 -0
  13. package/src/commands/EnvironmentAwareCommand/index.js.map +1 -0
  14. package/src/commands/GenerateTypes/GenerateTypesCommand.d.ts +9 -0
  15. package/src/commands/GenerateTypes/GenerateTypesCommand.js +35 -0
  16. package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -0
  17. package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +7 -0
  18. package/src/commands/GenerateTypes/components/GenerateTypes.js +22 -0
  19. package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -0
  20. package/src/commands/GenerateTypes/index.d.ts +1 -0
  21. package/src/commands/GenerateTypes/index.js +3 -0
  22. package/src/commands/GenerateTypes/index.js.map +1 -0
  23. package/src/commands/RenderableCommand.d.ts +7 -0
  24. package/src/commands/RenderableCommand.js +12 -0
  25. package/src/commands/RenderableCommand.js.map +1 -0
  26. package/src/components/CheckList/CheckList.d.ts +7 -0
  27. package/src/components/CheckList/CheckList.js +34 -0
  28. package/src/components/CheckList/CheckList.js.map +1 -0
  29. package/src/components/CheckList/Item.d.ts +7 -0
  30. package/src/components/CheckList/Item.js +79 -0
  31. package/src/components/CheckList/Item.js.map +1 -0
  32. package/src/components/CheckList/index.d.ts +1 -0
  33. package/src/components/CheckList/index.js +3 -0
  34. package/src/components/CheckList/index.js.map +1 -0
  35. package/src/constants.d.ts +1 -0
  36. package/src/constants.js +3 -0
  37. package/src/constants.js.map +1 -0
  38. package/src/environment/configuration/ConfigurationSchema.d.ts +9 -0
  39. package/src/environment/configuration/ConfigurationSchema.js +9 -0
  40. package/src/environment/configuration/ConfigurationSchema.js.map +1 -0
  41. package/src/environment/configuration/dto/Configuration.d.ts +4 -0
  42. package/src/environment/configuration/dto/Configuration.js +7 -0
  43. package/src/environment/configuration/dto/Configuration.js.map +1 -0
  44. package/src/environment/configuration/error/ConfigurationFileNotFoundError.d.ts +4 -0
  45. package/src/environment/configuration/error/ConfigurationFileNotFoundError.js +8 -0
  46. package/src/environment/configuration/error/ConfigurationFileNotFoundError.js.map +1 -0
  47. package/src/environment/configuration/error/ConfigurationFileValidationError.d.ts +5 -0
  48. package/src/environment/configuration/error/ConfigurationFileValidationError.js +8 -0
  49. package/src/environment/configuration/error/ConfigurationFileValidationError.js.map +1 -0
  50. package/src/environment/configuration/getConfiguration.d.ts +4 -0
  51. package/src/environment/configuration/getConfiguration.js +31 -0
  52. package/src/environment/configuration/getConfiguration.js.map +1 -0
  53. package/src/environment/createEnvironment.d.ts +12 -0
  54. package/src/environment/createEnvironment.js +53 -0
  55. package/src/environment/createEnvironment.js.map +1 -0
  56. package/src/environment/dto/Environment.d.ts +10 -0
  57. package/src/environment/dto/Environment.js +8 -0
  58. package/src/environment/dto/Environment.js.map +1 -0
  59. package/src/environment/error/EnvironmentError.d.ts +2 -0
  60. package/src/environment/error/EnvironmentError.js +4 -0
  61. package/src/environment/error/EnvironmentError.js.map +1 -0
  62. package/src/environment/path/dto/PlaydateSdkPath.d.ts +5 -0
  63. package/src/environment/path/dto/PlaydateSdkPath.js +10 -0
  64. package/src/environment/path/dto/PlaydateSdkPath.js.map +1 -0
  65. package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.d.ts +4 -0
  66. package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.js +8 -0
  67. package/src/environment/path/error/PlaydateSdkPathVariableNotSetError.js.map +1 -0
  68. package/src/environment/path/getPlaydateSdkPath.d.ts +14 -0
  69. package/src/environment/path/getPlaydateSdkPath.js +16 -0
  70. package/src/environment/path/getPlaydateSdkPath.js.map +1 -0
  71. package/src/hooks/useQuitOnCtrlC.d.ts +1 -0
  72. package/src/hooks/useQuitOnCtrlC.js +10 -0
  73. package/src/hooks/useQuitOnCtrlC.js.map +1 -0
  74. package/src/index.js +16 -12
  75. package/src/index.js.map +1 -1
  76. package/src/types.d.ts +35 -0
  77. package/src/types.js +18 -0
  78. package/src/types.js.map +1 -0
  79. package/src/utils/dirname.d.ts +1 -0
  80. package/src/utils/dirname.js +6 -0
  81. package/src/utils/dirname.js.map +1 -0
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "crankscript",
3
- "version": "0.1.2",
3
+ "version": "0.3.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"
9
10
  },
11
+ "license": "MIT",
10
12
  "dependencies": {
13
+ "@inkjs/ui": "^2.0.0",
11
14
  "@swc/helpers": "~0.5.11",
12
- "yargs": "^17.7.2"
15
+ "clipanion": "^4.0.0-rc.4",
16
+ "ink": "^5.0.1",
17
+ "react": "^18.3.1",
18
+ "typanion": "^3.14.0",
19
+ "zod": "^3.23.8"
13
20
  },
14
21
  "type": "module",
15
22
  "main": "./src/index.js",
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { RenderableCommand } from './RenderableCommand.js';
3
+ export declare class DoctorCommand extends RenderableCommand {
4
+ static paths: string[][];
5
+ static usage: import("clipanion").Usage;
6
+ render(): React.JSX.Element;
7
+ }
@@ -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,7 @@
1
+ import React from 'react';
2
+ import { EnvironmentHealth } from '@/cli/types.js';
3
+ interface Props {
4
+ health: EnvironmentHealth;
5
+ }
6
+ export declare const HealthReport: ({ health }: Props) => React.JSX.Element[];
7
+ export {};
@@ -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,3 @@
1
+ export * from './EnvironmentAwareCommand.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -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,35 @@
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('-s,--sdk-version', PlaydateSdkVersionIdentifier.FromConfig, {
16
+ tolerateBoolean: false,
17
+ description: 'The version',
18
+ validator: t.isOneOf([
19
+ t.isLiteral(PlaydateSdkVersionIdentifier.FromConfig),
20
+ t.isLiteral(PlaydateSdkVersionIdentifier.Latest),
21
+ t.matchesRegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/)
22
+ ])
23
+ });
24
+ }
25
+ }
26
+ GenerateTypesCommand.paths = [
27
+ [
28
+ 'generate-types'
29
+ ]
30
+ ];
31
+ GenerateTypesCommand.usage = Command.Usage({
32
+ description: 'Generate types from the Playdate SDK documentation'
33
+ });
34
+
35
+ //# 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 '-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"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { ConfigurationType } from '@/cli/environment/configuration/ConfigurationSchema.js';
3
+ interface Props {
4
+ version: ConfigurationType['version'];
5
+ }
6
+ export declare const GenerateTypes: ({ version }: Props) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { CheckList } from '@/cli/components/CheckList/index.js';
3
+ import { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.js';
4
+ export const GenerateTypes = ({ version })=>{
5
+ useQuitOnCtrlC();
6
+ return /*#__PURE__*/ React.createElement(CheckList, {
7
+ items: [
8
+ {
9
+ // Example
10
+ waitingDescription: ()=>`Generating types for version ${version}`,
11
+ runningDescription: ()=>'Generating types...',
12
+ errorDescription: ()=>'Failed to generate types',
13
+ finishedDescription: ()=>'Types generated',
14
+ runner: async ()=>{
15
+ await new Promise((resolve)=>setTimeout(resolve, 1000));
16
+ }
17
+ }
18
+ ]
19
+ });
20
+ };
21
+
22
+ //# sourceMappingURL=GenerateTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/components/GenerateTypes.tsx"],"sourcesContent":["import React from 'react';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { ConfigurationType } from '@/cli/environment/configuration/ConfigurationSchema.js';\nimport { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.js';\n\ninterface Props {\n version: ConfigurationType['version'];\n}\n\nexport const GenerateTypes = ({ version }: Props) => {\n useQuitOnCtrlC();\n\n return (\n <CheckList\n items={[\n {\n // Example\n waitingDescription: () =>\n `Generating types for version ${version}`,\n runningDescription: () => 'Generating types...',\n errorDescription: () => 'Failed to generate types',\n finishedDescription: () => 'Types generated',\n runner: async () => {\n await new Promise((resolve) =>\n setTimeout(resolve, 1000)\n );\n },\n },\n ]}\n />\n );\n};\n"],"names":["React","CheckList","useQuitOnCtrlC","GenerateTypes","version","items","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","Promise","resolve","setTimeout"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,SAAS,QAAQ,sCAAsC;AAEhE,SAASC,cAAc,QAAQ,gCAAgC;AAM/D,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,OAAO,EAAS;IAC5CF;IAEA,qBACI,oBAACD;QACGI,OAAO;YACH;gBACI,UAAU;gBACVC,oBAAoB,IAChB,CAAC,6BAA6B,EAAEF,QAAQ,CAAC;gBAC7CG,oBAAoB,IAAM;gBAC1BC,kBAAkB,IAAM;gBACxBC,qBAAqB,IAAM;gBAC3BC,QAAQ;oBACJ,MAAM,IAAIC,QAAQ,CAACC,UACfC,WAAWD,SAAS;gBAE5B;YACJ;SACH;;AAGb,EAAE"}
@@ -0,0 +1 @@
1
+ export * from './GenerateTypesCommand.js';
@@ -0,0 +1,3 @@
1
+ export * from './GenerateTypesCommand.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -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,7 @@
1
+ import { Command } from 'clipanion';
2
+ import { JSX } from 'react';
3
+ export declare abstract class RenderableCommand extends Command {
4
+ protected abstract render(): JSX.Element;
5
+ protected renderElement(element: JSX.Element): void;
6
+ execute(): Promise<void>;
7
+ }
@@ -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,7 @@
1
+ import React from 'react';
2
+ import { CheckListItem } from '@/cli/types.js';
3
+ interface Props {
4
+ items: CheckListItem[];
5
+ }
6
+ export declare const CheckList: ({ items }: Props) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,34 @@
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 })=>{
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
+ }
20
+ };
21
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, items.map((item, index)=>/*#__PURE__*/ React.createElement(Item, {
22
+ key: index,
23
+ item: _extends({}, item, {
24
+ onFinish: ()=>{
25
+ var _item_onFinish;
26
+ item == null ? void 0 : (_item_onFinish = item.onFinish) == null ? void 0 : _item_onFinish.call(item);
27
+ handleFinish(index);
28
+ }
29
+ }),
30
+ start: index === currentIndex
31
+ })));
32
+ };
33
+
34
+ //# 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[];\n}\n\nexport const CheckList = ({ items }: 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 }\n };\n\n return (\n <>\n {items.map((item, index) => (\n <Item\n key={index}\n item={{\n ...item,\n onFinish: () => {\n item?.onFinish?.();\n handleFinish(index);\n },\n }}\n start={index === currentIndex}\n />\n ))}\n </>\n );\n};\n"],"names":["React","useEffect","useState","Item","CheckList","items","currentIndex","setCurrentIndex","length","handleFinish","index","map","item","key","onFinish","start"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,IAAI,QAAQ,YAAY;AAMjC,OAAO,MAAMC,YAAY,CAAC,EAAEC,KAAK,EAAS;IACtC,MAAM,CAACC,cAAcC,gBAAgB,GAAGL,SAAwB;IAEhED,UAAU;QACN,IAAIK,iBAAiB,QAAQD,MAAMG,MAAM,GAAG,GAAG;YAC3CD,gBAAgB;QACpB;IACJ,GAAG;QAACD;QAAcD;KAAM;IAExB,MAAMI,eAAe,CAACC;QAClB,IAAIA,QAAQ,IAAIL,MAAMG,MAAM,EAAE;YAC1BD,gBAAgBG,QAAQ;QAC5B,OAAO;YACHH,gBAAgB;QACpB;IACJ;IAEA,qBACI,0CACKF,MAAMM,GAAG,CAAC,CAACC,MAAMF,sBACd,oBAACP;YACGU,KAAKH;YACLE,MAAM,aACCA;gBACHE,UAAU;wBACNF;oBAAAA,yBAAAA,iBAAAA,KAAME,QAAQ,qBAAdF,oBAAAA;oBACAH,aAAaC;gBACjB;;YAEJK,OAAOL,UAAUJ;;AAKrC,EAAE"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { CheckListItem } from '@/cli/types.js';
3
+ export interface ItemProps {
4
+ item: CheckListItem;
5
+ start: boolean;
6
+ }
7
+ export declare const Item: ({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, runner, onFinish, }, start, }: ItemProps) => React.JSX.Element;
@@ -0,0 +1,79 @@
1
+ import { StatusMessage, Spinner, extendTheme, defaultTheme, ThemeProvider } from '@inkjs/ui';
2
+ import { Text } from 'ink';
3
+ import React, { useEffect, 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 }, start })=>{
20
+ const [resultPresent, setResultPresent] = useState(false);
21
+ const [failedReason, setfailedReason] = useState(null);
22
+ const hasResult = !failedReason && resultPresent;
23
+ const isRunning = !failedReason && !hasResult && start;
24
+ const isWaiting = !failedReason && !hasResult && !start;
25
+ useEffect(()=>{
26
+ if (failedReason) {
27
+ process.exit();
28
+ }
29
+ }, [
30
+ failedReason
31
+ ]);
32
+ useEffect(()=>{
33
+ if (!start) {
34
+ return;
35
+ }
36
+ runner().then((result)=>{
37
+ if (result === false) {
38
+ setfailedReason(errorDescription);
39
+ return;
40
+ }
41
+ setResultPresent(true);
42
+ onFinish == null ? void 0 : onFinish();
43
+ }).catch((reason)=>{
44
+ setfailedReason(reason.message);
45
+ });
46
+ }, [
47
+ errorDescription,
48
+ onFinish,
49
+ runner,
50
+ start
51
+ ]);
52
+ let message = waitingDescription();
53
+ let variant = 'info';
54
+ if (failedReason) {
55
+ message = failedReason;
56
+ variant = 'error';
57
+ } else if (isRunning) {
58
+ message = runningDescription();
59
+ variant = 'warning';
60
+ } else if (hasResult) {
61
+ message = finishedDescription();
62
+ variant = 'success';
63
+ }
64
+ if (isRunning) {
65
+ return /*#__PURE__*/ React.createElement(ThemeProvider, {
66
+ theme: SpinnerTheme
67
+ }, /*#__PURE__*/ React.createElement(Spinner, {
68
+ label: ` ${message}`
69
+ }));
70
+ }
71
+ return /*#__PURE__*/ React.createElement(StatusMessage, {
72
+ variant: variant
73
+ }, /*#__PURE__*/ React.createElement(Text, {
74
+ bold: !isWaiting,
75
+ color: isRunning ? 'yellow' : isWaiting ? 'gray' : failedReason ? 'red' : 'green'
76
+ }, message));
77
+ };
78
+
79
+ //# 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, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport interface ItemProps {\n item: CheckListItem;\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 = ({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n runner,\n onFinish,\n },\n start,\n}: ItemProps) => {\n const [resultPresent, setResultPresent] = useState(false);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const hasResult = !failedReason && resultPresent;\n const isRunning = !failedReason && !hasResult && start;\n const isWaiting = !failedReason && !hasResult && !start;\n\n useEffect(() => {\n if (failedReason) {\n process.exit();\n }\n }, [failedReason]);\n\n useEffect(() => {\n if (!start) {\n return;\n }\n\n runner()\n .then((result) => {\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResultPresent(true);\n onFinish?.();\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();\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 </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Spinner","extendTheme","defaultTheme","ThemeProvider","Text","React","useEffect","useState","SpinnerTheme","components","styles","frame","color","label","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","runner","onFinish","start","resultPresent","setResultPresent","failedReason","setfailedReason","hasResult","isRunning","isWaiting","process","exit","then","result","catch","reason","message","variant","theme","bold"],"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,QAAQ,QAAQ,QAAQ;AAQnD,8BAA8B;AAC9B,MAAMC,eAAeP,YAAYC,cAAc;IAC3CO,YAAY;QACRT,SAAS;YACLU,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,CAAC,EACjBC,MAAM,EACFC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,EACX,EACDC,KAAK,EACG;IACR,MAAM,CAACC,eAAeC,iBAAiB,GAAGjB,SAAS;IACnD,MAAM,CAACkB,cAAcC,gBAAgB,GAAGnB,SAAwB;IAChE,MAAMoB,YAAY,CAACF,gBAAgBF;IACnC,MAAMK,YAAY,CAACH,gBAAgB,CAACE,aAAaL;IACjD,MAAMO,YAAY,CAACJ,gBAAgB,CAACE,aAAa,CAACL;IAElDhB,UAAU;QACN,IAAImB,cAAc;YACdK,QAAQC,IAAI;QAChB;IACJ,GAAG;QAACN;KAAa;IAEjBnB,UAAU;QACN,IAAI,CAACgB,OAAO;YACR;QACJ;QAEAF,SACKY,IAAI,CAAC,CAACC;YACH,IAAIA,WAAW,OAAO;gBAClBP,gBAAgBR;gBAEhB;YACJ;YAEAM,iBAAiB;YACjBH,4BAAAA;QACJ,GACCa,KAAK,CAAC,CAACC;YACJT,gBAAgBS,OAAOC,OAAO;QAClC;IACR,GAAG;QAAClB;QAAkBG;QAAUD;QAAQE;KAAM;IAE9C,IAAIc,UAAUnB;IACd,IAAIoB,UAAyC;IAE7C,IAAIZ,cAAc;QACdW,UAAUX;QACVY,UAAU;IACd,OAAO,IAAIT,WAAW;QAClBQ,UAAUpB;QACVqB,UAAU;IACd,OAAO,IAAIV,WAAW;QAClBS,UAAUjB;QACVkB,UAAU;IACd;IAEA,IAAIT,WAAW;QACX,qBACI,oBAACzB;YAAcmC,OAAO9B;yBAClB,oBAACR;YAAQa,OAAO,CAAC,CAAC,EAAEuB,QAAQ,CAAC;;IAGzC;IAEA,qBACI,oBAACrC;QAAcsC,SAASA;qBACpB,oBAACjC;QACGmC,MAAM,CAACV;QACPjB,OACIgB,YACM,WACAC,YACA,SACAJ,eACA,QACA;OAGTW;AAIjB,EAAE"}
@@ -0,0 +1 @@
1
+ export * from './CheckList.js';
@@ -0,0 +1,3 @@
1
+ export * from './CheckList.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -0,0 +1 @@
1
+ export declare const CrankscriptConfigurationFileName = "crankscript.json";
@@ -0,0 +1,3 @@
1
+ export const CrankscriptConfigurationFileName = 'crankscript.json';
2
+
3
+ //# sourceMappingURL=constants.js.map
@@ -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,9 @@
1
+ import { z } from 'zod';
2
+ export declare const ConfigurationSchema: z.ZodObject<{
3
+ version: z.ZodUnion<[z.ZodString, z.ZodLiteral<"latest">]>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ version: string;
6
+ }, {
7
+ version: string;
8
+ }>;
9
+ export type ConfigurationType = z.infer<typeof ConfigurationSchema>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export const ConfigurationSchema = z.object({
3
+ version: z.union([
4
+ z.string().regex(/^\d+\.\d+\.\d+$/),
5
+ z.literal('latest')
6
+ ])
7
+ });
8
+
9
+ //# sourceMappingURL=ConfigurationSchema.js.map
@@ -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.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"}
@@ -0,0 +1,4 @@
1
+ export declare class Configuration {
2
+ readonly version: string;
3
+ constructor(version: string);
4
+ }
@@ -0,0 +1,7 @@
1
+ export class Configuration {
2
+ constructor(version){
3
+ this.version = version;
4
+ }
5
+ }
6
+
7
+ //# sourceMappingURL=Configuration.js.map
@@ -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,4 @@
1
+ import { EnvironmentError } from '../../error/EnvironmentError.js';
2
+ export declare class ConfigurationFileNotFoundError extends EnvironmentError {
3
+ constructor();
4
+ }
@@ -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,4 @@
1
+ import { Configuration } from './dto/Configuration.js';
2
+ export declare const getConfiguration: (input?: {
3
+ workingDirectory: string;
4
+ }) => Configuration;
@@ -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,8 @@
1
+ export class Environment {
2
+ constructor({ configuration, sdkPath }){
3
+ this.configuration = configuration;
4
+ this.sdkPath = sdkPath;
5
+ }
6
+ }
7
+
8
+ //# sourceMappingURL=Environment.js.map
@@ -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,2 @@
1
+ export declare class EnvironmentError extends Error {
2
+ }
@@ -0,0 +1,4 @@
1
+ export class EnvironmentError extends Error {
2
+ }
3
+
4
+ //# sourceMappingURL=EnvironmentError.js.map
@@ -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,5 @@
1
+ export declare class PlaydateSdkPath {
2
+ readonly path: string;
3
+ private constructor();
4
+ static fromString(path: string): PlaydateSdkPath;
5
+ }
@@ -0,0 +1,10 @@
1
+ export class PlaydateSdkPath {
2
+ static fromString(path) {
3
+ return new PlaydateSdkPath(path);
4
+ }
5
+ constructor(path){
6
+ this.path = path;
7
+ }
8
+ }
9
+
10
+ //# sourceMappingURL=PlaydateSdkPath.js.map
@@ -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,4 @@
1
+ import { EnvironmentError } from '../../error/EnvironmentError.js';
2
+ export declare class PlaydateSdkPathVariableNotSetError extends EnvironmentError {
3
+ constructor();
4
+ }
@@ -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"}
@@ -0,0 +1 @@
1
+ export declare const useQuitOnCtrlC: () => void;
@@ -0,0 +1,10 @@
1
+ import { useInput } from 'ink';
2
+ export const useQuitOnCtrlC = ()=>{
3
+ useInput((input, key)=>{
4
+ if (key.ctrl && input === 'c') {
5
+ process.exit();
6
+ }
7
+ });
8
+ };
9
+
10
+ //# sourceMappingURL=useQuitOnCtrlC.js.map
@@ -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
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import yargs from 'yargs';
3
- import { hideBin } from 'yargs/helpers';
4
- import { readFileSync } from 'node:fs';
5
- import { dirname, join } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
- const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const packageJsonContents = readFileSync(join(__dirname, '..', 'package.json'), 'utf-8');
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
- yargs(hideBin(process.argv)).version(packageJson.version).scriptName('crankscript').command('hello', 'says hello', {}, ()=>{
11
- console.info('Hello...');
12
- }).command('$0', 'says hi', {}, ()=>{
13
- console.info('Hi! Something here soon.');
14
- }).help().parse();
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 yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst packageJsonContents = readFileSync(\n join(__dirname, '..', 'package.json'),\n 'utf-8'\n);\nconst packageJson = JSON.parse(packageJsonContents);\n\nyargs(hideBin(process.argv))\n .version(packageJson.version)\n .scriptName('crankscript')\n .command('hello', 'says hello', {}, () => {\n console.info('Hello...');\n })\n .command('$0', 'says hi', {}, () => {\n console.info('Hi! Something here soon.');\n })\n .help()\n .parse();\n"],"names":["yargs","hideBin","readFileSync","dirname","join","fileURLToPath","__dirname","url","packageJsonContents","packageJson","JSON","parse","process","argv","version","scriptName","command","console","info","help"],"rangeMappings":";;;;;;;;;;;;;","mappings":";AAEA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AAC1C,SAASC,aAAa,QAAQ,WAAW;AAEzC,MAAMC,YAAYH,QAAQE,cAAc,YAAYE,GAAG;AAEvD,MAAMC,sBAAsBN,aACxBE,KAAKE,WAAW,MAAM,iBACtB;AAEJ,MAAMG,cAAcC,KAAKC,KAAK,CAACH;AAE/BR,MAAMC,QAAQW,QAAQC,IAAI,GACrBC,OAAO,CAACL,YAAYK,OAAO,EAC3BC,UAAU,CAAC,eACXC,OAAO,CAAC,SAAS,cAAc,CAAC,GAAG;IAChCC,QAAQC,IAAI,CAAC;AACjB,GACCF,OAAO,CAAC,MAAM,WAAW,CAAC,GAAG;IAC1BC,QAAQC,IAAI,CAAC;AACjB,GACCC,IAAI,GACJR,KAAK"}
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,35 @@
1
+ import { Environment } from '@/cli/environment/dto/Environment.js';
2
+ export declare enum PlaydateSdkVersionIdentifier {
3
+ FromConfig = "FromConfig",
4
+ Latest = "latest"
5
+ }
6
+ export type EnvironmentHealthResult = {
7
+ isHealthy: true;
8
+ environment: Environment;
9
+ health: EnvironmentHealth;
10
+ } | {
11
+ isHealthy: false;
12
+ health: EnvironmentHealth;
13
+ };
14
+ export declare enum HealthCheckStatus {
15
+ Healthy = "Healthy",
16
+ Unhealthy = "Unhealthy",
17
+ Unknown = "Unknown"
18
+ }
19
+ export interface EnvironmentHealth {
20
+ configurationFilePresent: HealthCheckStatus;
21
+ configurationFileValid: HealthCheckStatus;
22
+ sdkPathKnown: HealthCheckStatus;
23
+ }
24
+ export declare enum ConfigurationFileValidationErrorType {
25
+ InvalidJson = "InvalidJson",
26
+ InvalidSchema = "InvalidSchema"
27
+ }
28
+ export type CheckListItem = {
29
+ runningDescription: () => string;
30
+ waitingDescription: () => string;
31
+ errorDescription: () => string;
32
+ finishedDescription: () => string;
33
+ runner: () => Promise<void> | Promise<false>;
34
+ onFinish?: () => void;
35
+ };
package/src/types.js ADDED
@@ -0,0 +1,18 @@
1
+ export var PlaydateSdkVersionIdentifier;
2
+ (function(PlaydateSdkVersionIdentifier) {
3
+ PlaydateSdkVersionIdentifier["FromConfig"] = "FromConfig";
4
+ PlaydateSdkVersionIdentifier["Latest"] = "latest";
5
+ })(PlaydateSdkVersionIdentifier || (PlaydateSdkVersionIdentifier = {}));
6
+ export var HealthCheckStatus;
7
+ (function(HealthCheckStatus) {
8
+ HealthCheckStatus["Healthy"] = "Healthy";
9
+ HealthCheckStatus["Unhealthy"] = "Unhealthy";
10
+ HealthCheckStatus["Unknown"] = "Unknown";
11
+ })(HealthCheckStatus || (HealthCheckStatus = {}));
12
+ export var ConfigurationFileValidationErrorType;
13
+ (function(ConfigurationFileValidationErrorType) {
14
+ ConfigurationFileValidationErrorType["InvalidJson"] = "InvalidJson";
15
+ ConfigurationFileValidationErrorType["InvalidSchema"] = "InvalidSchema";
16
+ })(ConfigurationFileValidationErrorType || (ConfigurationFileValidationErrorType = {}));
17
+
18
+ //# sourceMappingURL=types.js.map
@@ -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 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 = {\n runningDescription: () => string;\n waitingDescription: () => string;\n errorDescription: () => string;\n finishedDescription: () => string;\n runner: () => Promise<void> | Promise<false>;\n onFinish?: () => void;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatus","ConfigurationFileValidationErrorType"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":";UAEYA;;;GAAAA,iCAAAA;;UAgBAC;;;;GAAAA,sBAAAA;;UAYAC;;;GAAAA,yCAAAA"}
@@ -0,0 +1 @@
1
+ export declare const RootFolder: string;
@@ -0,0 +1,6 @@
1
+ import { dirname, join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ const __dirname = dirname(fileURLToPath(import.meta.url));
4
+ export const RootFolder = join(__dirname, '..', '..');
5
+
6
+ //# sourceMappingURL=dirname.js.map
@@ -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"}