@gutenye/script.js 2.1.0 → 2.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 +1 -1
- package/src/ake/akectl.ts +3 -2
- package/src/ake/shared.ts +7 -4
- package/src/completion.ts +2 -2
package/package.json
CHANGED
package/src/ake/akectl.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { castArray } from 'lodash-es'
|
|
4
4
|
import fs from '../utils/fs'
|
|
5
5
|
import {
|
|
6
|
+
AKE_FILENAMES,
|
|
6
7
|
exitWithError,
|
|
7
8
|
findAkeFiles,
|
|
8
9
|
getRemoteDir,
|
|
@@ -23,11 +24,11 @@ app
|
|
|
23
24
|
if (akeFiles.length > 0) {
|
|
24
25
|
exitWithError('Already have an ake file, cannot create a new one')
|
|
25
26
|
}
|
|
26
|
-
let target =
|
|
27
|
+
let target = AKE_FILENAMES[0]
|
|
27
28
|
if (place === 'remote') {
|
|
28
29
|
const remoteDir = getRemoteDir()
|
|
29
30
|
await fs.mkdirp(remoteDir)
|
|
30
|
-
target = `${remoteDir}
|
|
31
|
+
target = `${remoteDir}/${AKE_FILENAMES[0]}`
|
|
31
32
|
}
|
|
32
33
|
const templateFile = `${STORAGE_DIR}/${TEMPLATE_NAME}`
|
|
33
34
|
if (await fs.pathExists(templateFile)) {
|
package/src/ake/shared.ts
CHANGED
|
@@ -5,6 +5,7 @@ import fs from '../utils/fs'
|
|
|
5
5
|
const HOME = os.homedir()
|
|
6
6
|
const CWD = process.cwd()
|
|
7
7
|
|
|
8
|
+
export const AKE_FILENAMES = ['ake', 'ake.ts']
|
|
8
9
|
export const STORAGE_DIR = `${HOME}/bin.src/ake`
|
|
9
10
|
export const TEMPLATE_NAME = 'template'
|
|
10
11
|
|
|
@@ -14,10 +15,12 @@ export async function findAkeFiles(): Promise<string[]> {
|
|
|
14
15
|
const dirsToCheck = [localDir, remoteDir]
|
|
15
16
|
|
|
16
17
|
const akeFiles = await Promise.all(
|
|
17
|
-
dirsToCheck.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
dirsToCheck.flatMap((dir) =>
|
|
19
|
+
AKE_FILENAMES.map(async (name) => {
|
|
20
|
+
const akeFile = `${dir}/${name}`
|
|
21
|
+
return (await fs.pathExists(akeFile)) ? akeFile : null
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
21
24
|
)
|
|
22
25
|
|
|
23
26
|
return akeFiles.filter(Boolean) as string[]
|
package/src/completion.ts
CHANGED
|
@@ -2,7 +2,7 @@ import nodeFs from 'node:fs'
|
|
|
2
2
|
import os from 'node:os'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import * as yaml from 'yaml'
|
|
5
|
-
import { getCompletionName } from './ake/shared'
|
|
5
|
+
import { AKE_FILENAMES, getCompletionName } from './ake/shared'
|
|
6
6
|
import type { Command } from './Command'
|
|
7
7
|
|
|
8
8
|
export type CompletionValue = string[] | (() => string[])
|
|
@@ -126,7 +126,7 @@ export async function installCompletion(
|
|
|
126
126
|
try {
|
|
127
127
|
if (!command.name && options.scriptPath) {
|
|
128
128
|
const basename = path.basename(options.scriptPath)
|
|
129
|
-
if (basename
|
|
129
|
+
if (AKE_FILENAMES.includes(basename)) {
|
|
130
130
|
command.name = getCompletionName()
|
|
131
131
|
}
|
|
132
132
|
}
|