Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 53520ca

Browse files
authored
fix: workshop flow #128
2 parents 6098bce + 6d6b073 commit 53520ca

File tree

11 files changed

+31
-26
lines changed

11 files changed

+31
-26
lines changed

.prettierrc.cjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ module.exports = {
44
tabWidth: 2,
55
semi: false,
66
singleQuote: true,
7-
importOrder: ['^[./]'],
8-
importOrderSeparation: true,
9-
importOrderSortSpecifiers: true,
107
}

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,20 @@
2525
"test:dev": "vitest"
2626
},
2727
"dependencies": {
28+
"@ucanto/interface": "^1.0.0",
2829
"@ipld/unixfs": "^1.1.0-dev",
2930
"@ucanto/server": "^1.0.2",
31+
"@ucanto/transport": "^1.0.1",
32+
"@ucanto/core": "^1.0.1",
33+
"uint8arrays": "^3.1.0",
34+
"@ipld/dag-cbor": "^8.0.0",
35+
"@ipld/dag-json": "^8.0.11",
36+
"@ipld/dag-pb": "^2.1.18",
37+
"@ucanto/principal": "^1.0.1",
3038
"@web-std/stream": "^1.0.1",
31-
"@web3-storage/w3up-client": "3.0.2",
39+
"@web3-storage/w3up-client": "^3.0.4",
40+
"multiformats": "^9.9.0",
41+
"@ipld/car": "^4.1.6",
3242
"archy": "^1.0.0",
3343
"cli-table": "^0.3.11",
3444
"conf": "^10.2.0",
@@ -41,7 +51,6 @@
4151
"yargs": "^17.5.1"
4252
},
4353
"devDependencies": {
44-
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
4554
"@types/inquirer": "^9.0.1",
4655
"@types/yargs": "^17.0.11",
4756
"chai": "^4.3.6",

src/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export function getClient(profile = 'main') {
5454
const settings = getProfileSettings(profile)
5555

5656
const client = new W3Client({
57-
serviceDID: cliSettings.W3_STORE_DID,
57+
serviceDID: /** @type {`did:${string}`} */ (cliSettings.W3_STORE_DID),
5858
serviceURL: cliSettings.SERVICE_URL,
59-
accessDID: cliSettings.ACCESS_DID,
59+
accessDID: /** @type {`did:${string}`} */ (cliSettings.ACCESS_DID),
6060
accessURL: cliSettings.ACCESS_URL,
6161
settings,
6262
})

src/commands/delegations/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const handler = async ({ profile }) => {
1818
const client = getClient(profile)
1919
const id = await client.account()
2020
const settings = await client.settings
21-
const selected = settings.get('delegation')
21+
const selected = settings.get('account')
2222
const delegations = settings.get('delegations')
2323

2424
const table = buildSimpleConsoleTable(['selected', 'alias', 'did'])

src/commands/delegations/switch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const handler = async ({ did, alias, profile }) => {
4040
const found = choices.find((x) => x.alias == alias)
4141
if (found) {
4242
const del = found.value
43-
settings.set('delegation', del)
43+
settings.set('account', del)
4444
console.log(`now using account: ${del}`)
4545
} else {
4646
console.log(
@@ -68,12 +68,12 @@ async function inquirerPick(choices, client) {
6868
type: 'list',
6969
name: 'Choose an account',
7070
choices,
71-
default: settings.get('delegation'),
71+
default: settings.get('account'),
7272
},
7373
])
7474
.then((answers) => {
7575
const del = answers['Choose an account']
76-
settings.set('delegation', del)
76+
settings.set('account', del)
7777
console.log(`now using account: ${del}`)
7878
})
7979
}

src/commands/settings/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const handler = async ({ filename, profile, stdout = false, yes = false }) => {
2828
const client = getClient(profile)
2929

3030
if (stdout) {
31-
const store = await exportSettings(client.settings)
31+
const store = await exportSettings(await client.settings)
3232
process.stdout.write(JSON.stringify(store))
3333
return
3434
}

src/commands/settings/import.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ const handler = async ({ fileName, profile, yes = false }) => {
4343

4444
if (show && fileName) {
4545
try {
46-
client.settings.clear()
46+
const settings = await client.settings
47+
settings.clear()
4748
const json = fs.readFileSync(fileName, { encoding: 'utf-8' })
4849
const imported = await importSettings(json)
4950

5051
for (const [key, value] of imported.entries()) {
51-
client.settings.set(key, value)
52+
settings.set(key, value)
5253
}
5354

5455
await client.identity()

src/commands/uploadCars.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// @ts-expect-error
2-
import * as CAR from '@ipld/car'
1+
import { CarReader } from '@ipld/car/reader'
32
import fs from 'fs'
43
import ora from 'ora'
54
import path from 'path'
65
// @ts-ignore
76
import toIterator from 'stream-to-it'
7+
import { TransformStream } from '@web-std/stream'
88

99
import { getClient } from '../client.js'
1010
import { getAllFiles, isDirectory } from '../lib/car/file.js'
@@ -103,7 +103,7 @@ const handler = async (argv) => {
103103
uploadExistingCar(car, client, view).then(async (buffer) => {
104104
if (buffer) {
105105
const bytes = Uint8Array.from(buffer)
106-
const reader = await CAR.CarReader.fromBytes(bytes)
106+
const reader = await CarReader.fromBytes(bytes)
107107
const roots = await reader.getRoots()
108108
const cid = await bytesToCarCID(bytes)
109109
for (const root of roots) {

src/lib/car/buildCar.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import * as CAR from '@ipld/car'
33
import * as UnixFS from '@ipld/unixfs'
44
import fs from 'fs'
55
import path from 'path'
6-
import 'web-streams-polyfill'
76

87
import { isDirectory } from '../../utils.js'
98
import { walkDir, wrapFilesWithDir } from './dir.js'
109
import { streamFileToBlock } from './file.js'
11-
10+
import { TransformStream } from '@web-std/stream'
1211
// Internal unixfs read stream capacity that can hold around 32 blocks
1312
const CAPACITY = UnixFS.BLOCK_SIZE_LIMIT * 32
1413
const MAX_CARS_AT_ONCE = 8

src/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ import whoami from './commands/whoami.js'
1818
import printQuickstart from './quickstart.js'
1919

2020
/**
21-
* @type {import('yargs').Argv<{}>} yargs
21+
* @param {string[]} args
2222
*/
23-
const yargs = _yargs(hideBin(process.argv))
24-
25-
export const main = async () => {
23+
export const main = async (args = hideBin(process.argv)) => {
24+
const yargs = _yargs(args)
2625
const argv = await yargs
2726
.scriptName('w3up')
2827
// .usage('Usage:\n $0 <cmd> [options]')

0 commit comments

Comments
 (0)