phio 0.3.1 → 0.3.3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phio",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "A CLI tool to manage your PocketHost instances",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,11 +22,11 @@
22
22
  "type": "module",
23
23
  "types": "src/index.ts",
24
24
  "devDependencies": {
25
- "@changesets/cli": "^2.27.10",
26
- "@types/bun": "latest",
25
+ "@changesets/cli": "^2.28.1",
26
+ "@types/bun": "^1.2.3",
27
27
  "@types/fs-extra": "^11.0.4",
28
- "@types/node": "^22.5.5",
29
- "prettier-plugin-organize-imports": "^4.0.0"
28
+ "@types/node": "^22.13.5",
29
+ "prettier-plugin-organize-imports": "^4.1.0"
30
30
  },
31
31
  "scripts": {
32
32
  "dev": "tsx ./src/cli.ts"
@@ -38,23 +38,23 @@
38
38
  "src"
39
39
  ],
40
40
  "dependencies": {
41
- "@inquirer/prompts": "^5.5.0",
41
+ "@inquirer/prompts": "^7.3.2",
42
42
  "@s-libs/micro-dash": "^18.0.0",
43
- "@samkirkland/ftp-deploy": "github:benallfree/ftp-deploy#glob",
44
- "@sentool/fetch-event-source": "^0.5.0",
43
+ "@samkirkland/ftp-deploy": "github:benallfree/ftp-deploy#132389e",
44
+ "@sentool/fetch-event-source": "^0.6.0",
45
45
  "bottleneck": "^2.19.5",
46
- "chokidar": "^4.0.0",
47
- "commander": "^12.1.0",
46
+ "chokidar": "^4.0.3",
47
+ "commander": "^13.1.0",
48
48
  "email-validator": "^2.0.4",
49
49
  "env-paths": "^3.0.0",
50
50
  "env-var": "^7.5.0",
51
51
  "event-stream": "^4.0.1",
52
- "fs-extra": "^11.2.0",
52
+ "fs-extra": "^11.3.0",
53
53
  "multimatch": "^7.0.0",
54
- "ora": "^8.1.0",
55
- "pocketbase": "^0.21.5",
56
- "tsx": "^4.19.1",
57
- "typescript": "^5.6.2"
54
+ "ora": "^8.2.0",
55
+ "pocketbase": "^0.25.1",
56
+ "tsx": "^4.19.3",
57
+ "typescript": "^5.7.3"
58
58
  },
59
59
  "prettier": {
60
60
  "semi": false,
@@ -1,16 +1,14 @@
1
1
  import { debounce } from '@s-libs/micro-dash'
2
- import * as ftp from '@samkirkland/ftp-deploy'
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
- import { config } from '../lib/config'
9
- import { getInstanceBySubdomainCnameOrId } from '../lib/getClient'
8
+ import { ensureLoggedIn } from '../lib/ensureLoggedIn'
9
+ import { getClient, getInstanceBySubdomainCnameOrId } from '../lib/getClient'
10
10
  import { savedInstanceName } from './../lib/defaultInstanceId'
11
11
 
12
- const { deploy, excludeDefaults } = ftp
13
-
14
12
  export const DEFAULT_INCLUDES = [
15
13
  `pb_*`,
16
14
  'pb_*/**/*',
@@ -29,24 +27,29 @@ export type DeployOptions = {
29
27
  }
30
28
 
31
29
  export const watchAndDeploy = async (
32
- _instanceId: string,
30
+ instanceName: string,
33
31
  options: DeployOptions = {
34
32
  include: DEFAULT_INCLUDES,
35
33
  exclude: DEFAULT_EXCLUDES,
36
34
  verbose: false,
37
35
  }
38
36
  ) => {
39
- if (!_instanceId) {
40
- console.error(
37
+ if (!instanceName) {
38
+ throw new Error(
41
39
  `No instance name provided and none was found in package.json or pockethost.json. Use 'phio link <instance>'`
42
40
  )
43
- process.exit(1)
44
41
  }
45
42
  console.log(`Dev mode`)
46
43
  const { include, exclude, verbose } = options
47
44
  // console.log({ include, exclude })
48
45
 
49
- const instance = await getInstanceBySubdomainCnameOrId(_instanceId)
46
+ const instance = await (async () => {
47
+ try {
48
+ return await getInstanceBySubdomainCnameOrId(instanceName)
49
+ } catch (error) {
50
+ throw new Error(`Instance ${instanceName} not found`)
51
+ }
52
+ })()
50
53
 
51
54
  const limiter = new Bottleneck({ maxConcurrent: 1 })
52
55
  const upload = debounce(
@@ -94,11 +97,13 @@ export async function deployMyCode(
94
97
  exclude: string[],
95
98
  verbose: boolean
96
99
  ) {
100
+ await ensureLoggedIn()
101
+ const client = await getClient()
97
102
  console.log(`🚚 Deploy started for ${instanceName}`)
98
103
  const args: IFtpDeployArguments = {
99
104
  server: 'ftp.pockethost.io',
100
105
  username: `__auth__`,
101
- password: config(`auth`)!.token,
106
+ password: client.authStore.token,
102
107
  'server-dir': `${instanceName}/`,
103
108
  include,
104
109
  exclude: [...excludeDefaults, ...exclude],
@@ -111,7 +116,7 @@ export async function deployMyCode(
111
116
 
112
117
  export const DevCommand = () => {
113
118
  return new Command('dev')
114
- .argument(`[instanceId]`, `Instance name`, savedInstanceName())
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(
package/src/index.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import { config } from './lib/config'
2
2
 
3
- export const isLoggedIn = () => {
4
- return !!config('auth')
5
- }
6
-
7
3
  export * from './commands/DevCommand'
8
4
  export * from './commands/LinkCommand'
9
5
  export * from './commands/LoginCommand'