Skip to content

Commit

Permalink
refactor: resolve formatting, linting from CI
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterBrown committed Nov 10, 2024
1 parent 6c7cd5a commit e2e347d
Show file tree
Hide file tree
Showing 48 changed files with 1,010 additions and 618 deletions.
6 changes: 3 additions & 3 deletions docs/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineCollection } from 'astro:content';
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
import { defineCollection } from 'astro:content'
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema'

export const collections = {
docs: defineCollection({ schema: docsSchema() }),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
};
}
44 changes: 27 additions & 17 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ const command = buildCommand({
docs: {
brief: 'Build project for release to target device',
},
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
async func(this: LocalContext, flags: BuildOptions, projectPath: string = '.') {
async func(
this: LocalContext,
flags: BuildOptions,
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
projectPath: string = '.',
) {
const { filesystem } = this
const { build } = await import('../toolbox/build/index')
const currentPlatform: Device = platformType().toLowerCase() as Device
Expand All @@ -36,15 +40,18 @@ const command = buildCommand({
mode = (process.env.NODE_ENV as Mode) ?? 'development',
output,
port,
config = []
config = [],
} = flags
const targetPlatform: string = DEVICE_ALIAS[device] ?? device
projectPath = filesystem.resolve(projectPath)
const parsedConfig = config.reduce<Record<string, string>>((result, setting) => {
const [key, value] = setting.split('=')
result[key] = value
return result
}, {})
const parsedConfig = config.reduce<Record<string, string>>(
(result, setting) => {
const [key, value] = setting.split('=')
result[key] = value
return result
},
{},
)

await build({
listExamples,
Expand All @@ -56,7 +63,7 @@ const command = buildCommand({
mode,
deployStatus: deploy ? 'push' : 'none',
outputDir: output,
config: parsedConfig
config: parsedConfig,
})
},
parameters: {
Expand All @@ -69,14 +76,15 @@ const command = buildCommand({
parse: String,
default: '.',
optional: true,
}
]
},
],
},
flags: {
device: {
kind: 'enum',
values: Object.keys(DEVICE_ALIAS) as NonNullable<Device[]>,
brief: 'Target device or platform for the project, use --list-devices to select from interactive list; defaults to current OS simulator',
brief:
'Target device or platform for the project, use --list-devices to select from interactive list; defaults to current OS simulator',
optional: true,
},
deploy: {
Expand All @@ -87,7 +95,8 @@ const command = buildCommand({
example: {
kind: 'parsed',
parse: String,
brief: 'Name of example project to run, use --list-examples to select from an interactive list',
brief:
'Name of example project to run, use --list-examples to select from an interactive list',
optional: true,
},
listExamples: {
Expand All @@ -109,7 +118,8 @@ const command = buildCommand({
output: {
kind: 'parsed',
parse: String,
brief: 'Output directory for build result; defaults to internal $MODDABLE build directory for project',
brief:
'Output directory for build result; defaults to internal $MODDABLE build directory for project',
optional: true,
},
port: {
Expand All @@ -124,14 +134,14 @@ const command = buildCommand({
brief: 'Extra configuration options to provide to build',
optional: true,
variadic: true,
}
},
},
aliases: {
d: 'device',
m: 'mode',
o: 'output',
}
}
},
},
})

export default command
45 changes: 27 additions & 18 deletions src/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ const command = buildCommand({
docs: {
brief: 'Remove build artifacts for project',
},
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
async func(this: LocalContext, flags: CleanOptions, projectPath: string = '.') {
async func(
this: LocalContext,
flags: CleanOptions,
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
projectPath: string = '.',
) {
const { filesystem } = this
const { build } = await import('../toolbox/build/index')
const currentPlatform: Device = platformType().toLowerCase() as Device
Expand All @@ -32,15 +36,18 @@ const command = buildCommand({
listDevices = false,
mode = (process.env.NODE_ENV as Mode) ?? 'development',
output,
config = []
config = [],
} = flags
const targetPlatform: string = DEVICE_ALIAS[device] ?? device
projectPath = filesystem.resolve(projectPath)
const parsedConfig = config.reduce<Record<string, string>>((result, setting) => {
const [key, value] = setting.split('=')
result[key] = value
return result
}, {})
const parsedConfig = config.reduce<Record<string, string>>(
(result, setting) => {
const [key, value] = setting.split('=')
result[key] = value
return result
},
{},
)

await build({
listExamples,
Expand All @@ -51,7 +58,7 @@ const command = buildCommand({
mode,
deployStatus: 'clean',
outputDir: output,
config: parsedConfig
config: parsedConfig,
})
},
parameters: {
Expand All @@ -64,20 +71,22 @@ const command = buildCommand({
parse: String,
default: '.',
optional: true,
}
]
},
],
},
flags: {
device: {
kind: 'enum',
values: Object.keys(DEVICE_ALIAS) as NonNullable<Device[]>,
brief: 'Target device or platform for the project, use --list-devices to select from interactive list; defaults to current OS simulator',
brief:
'Target device or platform for the project, use --list-devices to select from interactive list; defaults to current OS simulator',
optional: true,
},
example: {
kind: 'parsed',
parse: String,
brief: 'Name of example project to run, use --list-examples to select from an interactive list',
brief:
'Name of example project to run, use --list-examples to select from an interactive list',
optional: true,
},
listExamples: {
Expand All @@ -99,7 +108,8 @@ const command = buildCommand({
output: {
kind: 'parsed',
parse: String,
brief: 'Output directory for build result; defaults to internal $MODDABLE build directory for project',
brief:
'Output directory for build result; defaults to internal $MODDABLE build directory for project',
optional: true,
},
config: {
Expand All @@ -108,15 +118,14 @@ const command = buildCommand({
brief: 'Extra configuration options to provide to build',
optional: true,
variadic: true,
}
},
},
aliases: {
d: 'device',
m: 'mode',
o: 'output',
}
}
},
},
})

export default command

25 changes: 16 additions & 9 deletions src/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ const command = buildCommand({
docs: {
brief: 'Connect to running debugging session on target device or simulator',
},
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
async func(this: LocalContext, flags: DebugOptions, projectPath: string = '.') {
async func(
this: LocalContext,
flags: DebugOptions,
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
projectPath: string = '.',
) {
const { filesystem } = this
const currentPlatform: Device = platformType().toLowerCase() as Device
const {
Expand Down Expand Up @@ -62,20 +66,22 @@ const command = buildCommand({
parse: String,
default: '.',
optional: true,
}
]
},
],
},
flags: {
device: {
kind: 'enum',
values: Object.keys(DEVICE_ALIAS) as NonNullable<Device[]>,
brief: 'Target device or platform for the project, use --list-devices to select from interactive list; defaults to current OS simulator',
brief:
'Target device or platform for the project, use --list-devices to select from interactive list; defaults to current OS simulator',
optional: true,
},
example: {
kind: 'parsed',
parse: String,
brief: 'Name of example project to run, use --list-examples to select from an interactive list',
brief:
'Name of example project to run, use --list-examples to select from an interactive list',
optional: true,
},
listExamples: {
Expand All @@ -97,16 +103,17 @@ const command = buildCommand({
output: {
kind: 'parsed',
parse: String,
brief: 'Output directory for build result; defaults to internal $MODDABLE build directory for project',
brief:
'Output directory for build result; defaults to internal $MODDABLE build directory for project',
optional: true,
},
},
aliases: {
d: 'device',
m: 'mode',
o: 'output',
}
}
},
},
})

export default command
Loading

0 comments on commit e2e347d

Please sign in to comment.