Skip to content

Commit

Permalink
refactor: resolving linting, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterBrown committed Dec 22, 2024
1 parent fa6c1ef commit fc37664
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 33 deletions.
22 changes: 11 additions & 11 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ const command = buildCommand({
const filteredChoices = choices.filter((choice) =>
choice.includes(String(example)),
)
; ({ example: selectedExample } = await prompt.ask([
{
type: 'autocomplete',
name: 'example',
message: 'Here are the available examples templates:',
choices: filteredChoices.length > 0 ? filteredChoices : choices,
},
]))
;({ example: selectedExample } = await prompt.ask([
{
type: 'autocomplete',
name: 'example',
message: 'Here are the available examples templates:',
choices: filteredChoices.length > 0 ? filteredChoices : choices,
},
]))
}

// copy files into new project directory
Expand All @@ -89,9 +89,9 @@ const command = buildCommand({
const includes = [
io
? [
'"$(MODDABLE)/modules/io/manifest.json"',
'"$(MODDABLE)/examples/manifest_net.json"',
]
'"$(MODDABLE)/modules/io/manifest.json"',
'"$(MODDABLE)/examples/manifest_net.json"',
]
: '"$(MODDABLE)/examples/manifest_base.json"',
typescript && '"$(MODDABLE)/examples/manifest_typings.json"',
]
Expand Down
3 changes: 1 addition & 2 deletions src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ const command = buildCommand({
branch: {
kind: 'parsed',
parse: String,
brief:
'The remote branch to use as the source for Moddable SDK set up',
brief: 'The remote branch to use as the source for Moddable SDK set up',
optional: true,
},
release: {
Expand Down
4 changes: 3 additions & 1 deletion src/toolbox/prompt/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export function collectChoicesFromTree(
): string[] {
if (
fd.type === 'dir' &&
fd.children.find((file) => ['manifest.json', 'package.json'].includes(file.name)) !== undefined
fd.children.find((file) =>
['manifest.json', 'package.json'].includes(file.name),
) !== undefined
) {
results.push(root + fd.name)
} else if (fd.type === 'dir') {
Expand Down
8 changes: 4 additions & 4 deletions src/toolbox/setup/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { fetchRelease, downloadReleaseTools } from './moddable'

const chmodPromise = promisify(chmod)

export default async function({
export default async function ({
sourceRepo,
branch,
release,
Expand Down Expand Up @@ -70,7 +70,7 @@ export default async function({
if (filesystem.exists(INSTALL_PATH) !== false) {
spinner.info('Moddable repo already installed')
} else {
if (release && (branch === undefined || branch === null)) {
if (release !== undefined && (branch === undefined || branch === null)) {
spinner.start('Getting latest Moddable-OpenSource/moddable release')
const remoteRelease = await fetchRelease(release)
await system.spawn(
Expand Down Expand Up @@ -117,15 +117,15 @@ export default async function({
await upsert(EXPORTS_FILE_PATH, `export PATH="${BIN_PATH}:$PATH"`)

// 5. Build the Moddable command line tools, simulator, and debugger from the command line:
if (branch) {
if (typeof branch === 'string') {
spinner.start('Building platform tooling')
await system.exec('make', { cwd: BUILD_DIR, stdout: process.stdout })
spinner.succeed()
}

// 6. Install the desktop simulator and xsbug debugger applications
spinner.start('Installing simulator')
if (release && (branch === undefined || branch === null)) {
if (release !== undefined && (branch === undefined || branch === null)) {
filesystem.dir(
filesystem.resolve(
BUILD_DIR,
Expand Down
4 changes: 2 additions & 2 deletions src/toolbox/setup/mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { PlatformSetupArgs } from './types'

const chmodPromise = promisify(chmod)

export default async function({
export default async function ({
sourceRepo,
branch,
release,
Expand Down Expand Up @@ -73,7 +73,7 @@ export default async function({
spinner.info('Moddable repo already installed')
} else {
try {
if (release && (branch === undefined || branch === null)) {
if (release !== undefined && (branch === undefined || branch === null)) {
spinner.start('Getting latest Moddable-OpenSource/moddable release')
const remoteRelease = await fetchRelease(release)
await system.spawn(
Expand Down
6 changes: 4 additions & 2 deletions src/toolbox/setup/moddable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ type GitHubRelease = ExtractFromArray<
RestEndpointMethodTypes['repos']['listReleases']['response']['data']
>

export async function fetchRelease(release: 'latest' | string): Promise<GitHubRelease> {
export async function fetchRelease(
release: 'latest' | string,
): Promise<GitHubRelease> {
const octokit = new Octokit()
if (release === 'latest') {
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
Expand All @@ -74,7 +76,7 @@ export async function fetchRelease(release: 'latest' | string): Promise<GitHubRe
const { data: taggedRelease } = await octokit.rest.repos.getReleaseByTag({
owner: 'Moddable-OpenSource',
repo: 'moddable',
tag: release
tag: release,
})
return taggedRelease
}
Expand Down
6 changes: 3 additions & 3 deletions src/toolbox/setup/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function ensureModdableCommandPrompt(
}
}

export default async function({
export default async function ({
sourceRepo,
branch,
release,
Expand Down Expand Up @@ -217,7 +217,7 @@ export default async function({
spinner.info('Moddable repo already installed')
} else {
try {
if (release && (branch === undefined || branch === null)) {
if (release !== undefined && (branch === undefined || branch === null)) {
spinner.start(`Getting latest Moddable-OpenSource/moddable release`)
const remoteRelease = await fetchRelease(release)
await system.spawn(
Expand Down Expand Up @@ -271,7 +271,7 @@ export default async function({
}

// 3. build tools if needed
if (branch) {
if (typeof branch === 'string') {
try {
spinner.start(`Building Moddable SDK tools`)
await system.exec(`build.bat`, { cwd: BUILD_DIR, stdout: process.stdout })
Expand Down
10 changes: 6 additions & 4 deletions src/toolbox/update/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { execWithSudo, sourceEnvironment } from '../system/exec'

const chmodPromise = promisify(chmod)

export default async function({ branch, release }: SetupArgs): Promise<void> {
export default async function ({ branch, release }: SetupArgs): Promise<void> {
await sourceEnvironment()

// 0. ensure Moddable exists
Expand All @@ -33,7 +33,7 @@ export default async function({ branch, release }: SetupArgs): Promise<void> {
'lin',
)

if (release && (branch === undefined || branch === null)) {
if (release !== undefined && (branch === undefined || branch === null)) {
// get tag for current repo
const currentTag: string = await system.exec('git tag', {
cwd: process.env.MODDABLE,
Expand Down Expand Up @@ -140,7 +140,7 @@ export default async function({ branch, release }: SetupArgs): Promise<void> {
)
}

if (branch) {
if (typeof branch === 'string') {
const currentRev: string = await system.exec(`git rev-parse ${branch}`, {
cwd: process.env.MODDABLE,
})
Expand All @@ -159,7 +159,9 @@ export default async function({ branch, release }: SetupArgs): Promise<void> {

spinner.start('Stashing any unsaved changes before committing')
await system.exec('git stash', { cwd: process.env.MODDABLE })
await system.exec(`git pull origin ${branch}`, { cwd: process.env.MODDABLE })
await system.exec(`git pull origin ${branch}`, {
cwd: process.env.MODDABLE,
})

await system.exec('rm -rf build/{tmp,bin}', { cwd: process.env.MODDABLE })
spinner.succeed()
Expand Down
10 changes: 6 additions & 4 deletions src/toolbox/update/mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { sourceEnvironment } from '../system/exec'

const chmodPromise = promisify(chmod)

export default async function({ branch, release }: SetupArgs): Promise<void> {
export default async function ({ branch, release }: SetupArgs): Promise<void> {
print.info('Checking for SDK changes')

await sourceEnvironment()
Expand All @@ -27,7 +27,7 @@ export default async function({ branch, release }: SetupArgs): Promise<void> {
process.exit(1)
}

if (release && (branch === undefined || branch === null)) {
if (release !== undefined && (branch === undefined || branch === null)) {
// get tag for current repo
const currentTag: string = await system.exec('git tag', {
cwd: process.env.MODDABLE,
Expand Down Expand Up @@ -121,7 +121,7 @@ export default async function({ branch, release }: SetupArgs): Promise<void> {
)
}

if (branch) {
if (typeof branch === 'string') {
const currentRev: string = await system.exec(`git rev-parse ${branch}`, {
cwd: process.env.MODDABLE,
})
Expand All @@ -140,7 +140,9 @@ export default async function({ branch, release }: SetupArgs): Promise<void> {

spinner.start('Stashing any unsaved changes before committing')
await system.exec('git stash', { cwd: process.env.MODDABLE })
await system.exec(`git pull origin ${branch}`, { cwd: process.env.MODDABLE })
await system.exec(`git pull origin ${branch}`, {
cwd: process.env.MODDABLE,
})

const BUILD_DIR = filesystem.resolve(
process.env.MODDABLE ?? '',
Expand Down

0 comments on commit fc37664

Please sign in to comment.