phio 0.3.1 → 0.3.2
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 +3 -3
- package/src/commands/DevCommand.ts +14 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phio",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A CLI tool to manage your PocketHost instances",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@inquirer/prompts": "^5.5.0",
|
|
42
42
|
"@s-libs/micro-dash": "^18.0.0",
|
|
43
|
-
"@samkirkland/ftp-deploy": "github:benallfree/ftp-deploy#
|
|
43
|
+
"@samkirkland/ftp-deploy": "github:benallfree/ftp-deploy#132389e",
|
|
44
44
|
"@sentool/fetch-event-source": "^0.5.0",
|
|
45
45
|
"bottleneck": "^2.19.5",
|
|
46
46
|
"chokidar": "^4.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"multimatch": "^7.0.0",
|
|
54
54
|
"ora": "^8.1.0",
|
|
55
55
|
"pocketbase": "^0.21.5",
|
|
56
|
-
"tsx": "^4.19.
|
|
56
|
+
"tsx": "^4.19.3",
|
|
57
57
|
"typescript": "^5.6.2"
|
|
58
58
|
},
|
|
59
59
|
"prettier": {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { debounce } from '@s-libs/micro-dash'
|
|
2
|
-
import
|
|
2
|
+
import { deploy, excludeDefaults } from '@samkirkland/ftp-deploy'
|
|
3
3
|
import { IFtpDeployArguments } from '@samkirkland/ftp-deploy/src/types'
|
|
4
4
|
import Bottleneck from 'bottleneck'
|
|
5
5
|
import { watch } from 'chokidar'
|
|
6
6
|
import { Command } from 'commander'
|
|
7
7
|
import multimatch from 'multimatch'
|
|
8
8
|
import { config } from '../lib/config'
|
|
9
|
+
import { ensureLoggedIn } from '../lib/ensureLoggedIn'
|
|
9
10
|
import { getInstanceBySubdomainCnameOrId } from '../lib/getClient'
|
|
10
11
|
import { savedInstanceName } from './../lib/defaultInstanceId'
|
|
11
12
|
|
|
12
|
-
const { deploy, excludeDefaults } = ftp
|
|
13
|
-
|
|
14
13
|
export const DEFAULT_INCLUDES = [
|
|
15
14
|
`pb_*`,
|
|
16
15
|
'pb_*/**/*',
|
|
@@ -29,24 +28,29 @@ export type DeployOptions = {
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
export const watchAndDeploy = async (
|
|
32
|
-
|
|
31
|
+
instanceName: string,
|
|
33
32
|
options: DeployOptions = {
|
|
34
33
|
include: DEFAULT_INCLUDES,
|
|
35
34
|
exclude: DEFAULT_EXCLUDES,
|
|
36
35
|
verbose: false,
|
|
37
36
|
}
|
|
38
37
|
) => {
|
|
39
|
-
if (!
|
|
40
|
-
|
|
38
|
+
if (!instanceName) {
|
|
39
|
+
throw new Error(
|
|
41
40
|
`No instance name provided and none was found in package.json or pockethost.json. Use 'phio link <instance>'`
|
|
42
41
|
)
|
|
43
|
-
process.exit(1)
|
|
44
42
|
}
|
|
45
43
|
console.log(`Dev mode`)
|
|
46
44
|
const { include, exclude, verbose } = options
|
|
47
45
|
// console.log({ include, exclude })
|
|
48
46
|
|
|
49
|
-
const instance = await
|
|
47
|
+
const instance = await (async () => {
|
|
48
|
+
try {
|
|
49
|
+
return await getInstanceBySubdomainCnameOrId(instanceName)
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error(`Instance ${instanceName} not found`)
|
|
52
|
+
}
|
|
53
|
+
})()
|
|
50
54
|
|
|
51
55
|
const limiter = new Bottleneck({ maxConcurrent: 1 })
|
|
52
56
|
const upload = debounce(
|
|
@@ -94,6 +98,7 @@ export async function deployMyCode(
|
|
|
94
98
|
exclude: string[],
|
|
95
99
|
verbose: boolean
|
|
96
100
|
) {
|
|
101
|
+
await ensureLoggedIn()
|
|
97
102
|
console.log(`🚚 Deploy started for ${instanceName}`)
|
|
98
103
|
const args: IFtpDeployArguments = {
|
|
99
104
|
server: 'ftp.pockethost.io',
|
|
@@ -111,7 +116,7 @@ export async function deployMyCode(
|
|
|
111
116
|
|
|
112
117
|
export const DevCommand = () => {
|
|
113
118
|
return new Command('dev')
|
|
114
|
-
.argument(`[
|
|
119
|
+
.argument(`[instanceName]`, `Instance name`, savedInstanceName())
|
|
115
120
|
.description(`Watch for local modifications and sync to remote`)
|
|
116
121
|
.option(`-v, --verbose`, `Verbose output`)
|
|
117
122
|
.option(
|