pockethost 1.0.0 → 1.1.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
CHANGED
|
@@ -71,12 +71,12 @@ export const ConfigCommand = () => {
|
|
|
71
71
|
const values = _parse()
|
|
72
72
|
|
|
73
73
|
if (keys(values).length > 0) {
|
|
74
|
-
info(
|
|
74
|
+
info()
|
|
75
75
|
info(`Config values from ${envFile()}:`)
|
|
76
76
|
forEach(values, (v, k) => {
|
|
77
77
|
info(`\t${k}=${v}`)
|
|
78
78
|
})
|
|
79
|
-
info(
|
|
79
|
+
info()
|
|
80
80
|
} else {
|
|
81
81
|
info(`No config values found in ${envFile()}`)
|
|
82
82
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { uniq } from '@s-libs/micro-dash'
|
|
1
2
|
import { Command } from 'commander'
|
|
2
3
|
import { parse } from 'dotenv'
|
|
3
4
|
import { existsSync, readFileSync, writeFileSync } from 'fs'
|
|
4
|
-
import { error, info } from '
|
|
5
|
-
import { PH_HOME, PH_PLUGINS, PH_PROJECT_DIR } from '
|
|
6
|
-
import { getCompatibleVersions, removePackage } from './util'
|
|
5
|
+
import { error, info } from '../..'
|
|
6
|
+
import { PH_HOME, PH_PLUGINS, PH_PROJECT_DIR } from '../../../constants'
|
|
7
|
+
import { getCompatibleVersions, getPackageJson, removePackage } from './util'
|
|
7
8
|
|
|
8
9
|
const envFile = () => {
|
|
9
10
|
const envFile = PH_HOME(`.env`)
|
|
@@ -33,13 +34,13 @@ export const PluginCommand = () => {
|
|
|
33
34
|
await getCompatibleVersions(`pockethost`, version, [name])
|
|
34
35
|
|
|
35
36
|
const values = _parse()
|
|
36
|
-
values[`PH_PLUGINS`] = [
|
|
37
|
+
values[`PH_PLUGINS`] = uniq([
|
|
37
38
|
...(values[`PH_PLUGINS`]
|
|
38
39
|
?.split(/,/)
|
|
39
40
|
.map((v) => v.trim())
|
|
40
41
|
.filter((v) => !!v) || []),
|
|
41
42
|
name,
|
|
42
|
-
].join(`,`)
|
|
43
|
+
]).join(`,`)
|
|
43
44
|
writeFileSync(
|
|
44
45
|
envFile(),
|
|
45
46
|
Object.entries(values)
|
|
@@ -54,6 +55,23 @@ export const PluginCommand = () => {
|
|
|
54
55
|
}),
|
|
55
56
|
)
|
|
56
57
|
|
|
58
|
+
.addCommand(
|
|
59
|
+
new Command(`list`)
|
|
60
|
+
.alias(`ls`)
|
|
61
|
+
.description(`List plugins`)
|
|
62
|
+
.action(async (name: string) => {
|
|
63
|
+
try {
|
|
64
|
+
for (const plugin of PH_PLUGINS()) {
|
|
65
|
+
const pkg = await getPackageJson(plugin)
|
|
66
|
+
console.log({ pkg })
|
|
67
|
+
info(`${plugin}@${pkg.version} - ${pkg?.description}`)
|
|
68
|
+
}
|
|
69
|
+
} catch (e) {
|
|
70
|
+
error(`${e}`)
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
)
|
|
74
|
+
|
|
57
75
|
.addCommand(
|
|
58
76
|
new Command(`remove`)
|
|
59
77
|
.alias(`rm`)
|
|
@@ -65,12 +83,12 @@ export const PluginCommand = () => {
|
|
|
65
83
|
try {
|
|
66
84
|
await removePackage(name)
|
|
67
85
|
const values = _parse()
|
|
68
|
-
values[`PH_PLUGINS`] = [
|
|
86
|
+
values[`PH_PLUGINS`] = uniq([
|
|
69
87
|
...(values[`PH_PLUGINS`]
|
|
70
88
|
?.split(/,/)
|
|
71
89
|
.map((v) => v.trim())
|
|
72
90
|
.filter((v) => v !== name) || []),
|
|
73
|
-
].join(`,`)
|
|
91
|
+
]).join(`,`)
|
|
74
92
|
writeFileSync(
|
|
75
93
|
envFile(),
|
|
76
94
|
Object.entries(values)
|
|
@@ -84,6 +102,7 @@ export const PluginCommand = () => {
|
|
|
84
102
|
}
|
|
85
103
|
}),
|
|
86
104
|
)
|
|
105
|
+
|
|
87
106
|
.addCommand(
|
|
88
107
|
new Command(`update`)
|
|
89
108
|
.alias(`up`)
|
|
@@ -9,7 +9,7 @@ import util from 'util'
|
|
|
9
9
|
const execPromise = util.promisify(exec)
|
|
10
10
|
const require = createRequire(import.meta.url)
|
|
11
11
|
|
|
12
|
-
async function getPackageJson(packageName: string): Promise<any | null> {
|
|
12
|
+
export async function getPackageJson(packageName: string): Promise<any | null> {
|
|
13
13
|
try {
|
|
14
14
|
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
15
15
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'))
|
|
@@ -19,7 +19,9 @@ async function getPackageJson(packageName: string): Promise<any | null> {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async function fetchPackageData(
|
|
22
|
+
export async function fetchPackageData(
|
|
23
|
+
packageName: string,
|
|
24
|
+
): Promise<any | null> {
|
|
23
25
|
const npmRegistryUrl = `https://registry.npmjs.org/${packageName}`
|
|
24
26
|
try {
|
|
25
27
|
const response = await fetch(npmRegistryUrl)
|
package/src/cli/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
|
+
import { uniq } from '@s-libs/micro-dash'
|
|
3
4
|
import { Command, program } from 'commander'
|
|
4
5
|
import {
|
|
5
6
|
DEBUG,
|
|
@@ -10,8 +11,8 @@ import {
|
|
|
10
11
|
filter,
|
|
11
12
|
loadPlugins,
|
|
12
13
|
} from '../../core'
|
|
13
|
-
import { PluginCommand } from './PluginCommand'
|
|
14
14
|
import { ConfigCommand } from './commands/ConfigCommand'
|
|
15
|
+
import { PluginCommand } from './commands/PluginCommand'
|
|
15
16
|
import { ServeCommand } from './commands/ServeCommand'
|
|
16
17
|
|
|
17
18
|
export const { dbg, info, error } = LoggerService({
|
|
@@ -19,7 +20,7 @@ export const { dbg, info, error } = LoggerService({
|
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
export const main = async () => {
|
|
22
|
-
await loadPlugins(PH_PLUGINS())
|
|
23
|
+
await loadPlugins(uniq(PH_PLUGINS()))
|
|
23
24
|
|
|
24
25
|
program.name('pockethost').description('Multitenant PocketBase hosting')
|
|
25
26
|
|