[pnpm] Migrate devenv (#10480)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import {createServer as createHTTPServer} from 'node:http'
|
import {createServer as createHTTPServer} from 'node:http'
|
||||||
import {parse} from 'node:url'
|
import {parse} from 'node:url'
|
||||||
|
|
||||||
import {createServer, type TestPDS} from './test-pds'
|
import {createServer, type TestPDS} from './test-pds.ts'
|
||||||
|
|
||||||
let server: TestPDS
|
let server: TestPDS
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
@@ -97,6 +97,7 @@ createHTTPServer(async (req, res) => {
|
|||||||
await server.mocker.follow('alice', 'bob')
|
await server.mocker.follow('alice', 'bob')
|
||||||
await server.mocker.follow('alice', 'carla')
|
await server.mocker.follow('alice', 'carla')
|
||||||
console.log('Generating mock posts')
|
console.log('Generating mock posts')
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
let posts: Record<string, any[]> = {
|
let posts: Record<string, any[]> = {
|
||||||
alice: [],
|
alice: [],
|
||||||
bob: [],
|
bob: [],
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "dev-env",
|
"name": "dev-env",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "NODE_ENV=development ./dev-infra/with-test-redis-and-db.sh ts-node ./mock-server.ts"
|
"start": "NODE_ENV=development ./dev-infra/with-test-redis-and-db.sh node ./mock-server.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto/dev-env": "^0.3.215",
|
"@atproto/api": "^0.20.0",
|
||||||
"ts-node": "^10.9.2",
|
"@atproto/dev-env": "^0.5.0",
|
||||||
"typescript": "^6.0.2"
|
"typescript": "^6.0.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^25.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+4447
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
|||||||
|
allowBuilds:
|
||||||
|
'better-sqlite3': true
|
||||||
|
'core-js': true
|
||||||
|
'protobufjs': true
|
||||||
|
'sharp': true
|
||||||
|
'unrs-resolver': true
|
||||||
|
minimumReleaseAgeExclude:
|
||||||
|
- '@atproto/*'
|
||||||
|
- '@atproto-labs/*'
|
||||||
+28
-22
@@ -1,8 +1,9 @@
|
|||||||
|
import fs from 'node:fs'
|
||||||
|
import net from 'node:net'
|
||||||
|
import path from 'node:path'
|
||||||
|
|
||||||
import {AtUri, BskyAgent} from '@atproto/api'
|
import {AtUri, BskyAgent} from '@atproto/api'
|
||||||
import {type TestBsky, TestNetwork} from '@atproto/dev-env'
|
import {type TestBsky, TestNetwork} from '@atproto/dev-env'
|
||||||
import fs from 'fs'
|
|
||||||
import net from 'net'
|
|
||||||
import path from 'path'
|
|
||||||
|
|
||||||
export interface TestUser {
|
export interface TestUser {
|
||||||
email: string
|
email: string
|
||||||
@@ -21,9 +22,11 @@ export interface TestPDS {
|
|||||||
|
|
||||||
class StringIdGenerator {
|
class StringIdGenerator {
|
||||||
_nextId = [0]
|
_nextId = [0]
|
||||||
constructor(
|
_chars: string
|
||||||
public _chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
||||||
) {}
|
constructor(chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
|
||||||
|
this._chars = chars
|
||||||
|
}
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
const r = []
|
const r = []
|
||||||
@@ -83,13 +86,13 @@ export async function createServer(
|
|||||||
// DISABLED - looks like dev-env added this and now it conflicts
|
// DISABLED - looks like dev-env added this and now it conflicts
|
||||||
// add the test mod authority
|
// add the test mod authority
|
||||||
// const agent = new BskyAgent({service: pdsUrl})
|
// const agent = new BskyAgent({service: pdsUrl})
|
||||||
// const res = await agent.api.com.atproto.server.createAccount({
|
// const res = await agent.com.atproto.server.createAccount({
|
||||||
// email: 'mod-authority@test.com',
|
// email: 'mod-authority@test.com',
|
||||||
// handle: 'mod-authority.test',
|
// handle: 'mod-authority.test',
|
||||||
// password: 'hunter2',
|
// password: 'hunter2',
|
||||||
// })
|
// })
|
||||||
// agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`)
|
// agent.setHeader('Authorization', `Bearer ${res.data.accessJwt}`)
|
||||||
// await agent.api.app.bsky.actor.profile.create(
|
// await agent.app.bsky.actor.profile.create(
|
||||||
// {repo: res.data.did},
|
// {repo: res.data.did},
|
||||||
// {
|
// {
|
||||||
// displayName: 'Dev-env Moderation',
|
// displayName: 'Dev-env Moderation',
|
||||||
@@ -97,7 +100,7 @@ export async function createServer(
|
|||||||
// },
|
// },
|
||||||
// )
|
// )
|
||||||
|
|
||||||
// await agent.api.app.bsky.labeler.service.create(
|
// await agent.app.bsky.labeler.service.create(
|
||||||
// {repo: res.data.did, rkey: 'self'},
|
// {repo: res.data.did, rkey: 'self'},
|
||||||
// {
|
// {
|
||||||
// policies: {
|
// policies: {
|
||||||
@@ -109,7 +112,7 @@ export async function createServer(
|
|||||||
// )
|
// )
|
||||||
|
|
||||||
const pic = fs.readFileSync(
|
const pic = fs.readFileSync(
|
||||||
path.join(__dirname, '..', 'assets', 'default-avatar.png'),
|
path.join(import.meta.dirname, '..', 'assets', 'default-avatar.png'),
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -125,12 +128,14 @@ export async function createServer(
|
|||||||
class Mocker {
|
class Mocker {
|
||||||
agent: BskyAgent
|
agent: BskyAgent
|
||||||
users: Record<string, TestUser> = {}
|
users: Record<string, TestUser> = {}
|
||||||
|
testNet: TestNetwork
|
||||||
|
service: string
|
||||||
|
pic: Uint8Array
|
||||||
|
|
||||||
constructor(
|
constructor(testNet: TestNetwork, service: string, pic: Uint8Array) {
|
||||||
public testNet: TestNetwork,
|
this.testNet = testNet
|
||||||
public service: string,
|
this.service = service
|
||||||
public pic: Uint8Array,
|
this.pic = pic
|
||||||
) {
|
|
||||||
this.agent = new BskyAgent({service})
|
this.agent = new BskyAgent({service})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +166,7 @@ class Mocker {
|
|||||||
async createUser(name: string) {
|
async createUser(name: string) {
|
||||||
const agent = new BskyAgent({service: this.service})
|
const agent = new BskyAgent({service: this.service})
|
||||||
|
|
||||||
const inviteRes = await agent.api.com.atproto.server.createInviteCode(
|
const inviteRes = await agent.com.atproto.server.createInviteCode(
|
||||||
{useCount: 1},
|
{useCount: 1},
|
||||||
{
|
{
|
||||||
headers: this.pds.adminAuthHeaders(),
|
headers: this.pds.adminAuthHeaders(),
|
||||||
@@ -309,20 +314,21 @@ class Mocker {
|
|||||||
'app.bsky.feed.generator',
|
'app.bsky.feed.generator',
|
||||||
rkey,
|
rkey,
|
||||||
)
|
)
|
||||||
|
// @ts-expect-error
|
||||||
const fg1 = await this.testNet.createFeedGen({
|
const fg1 = await this.testNet.createFeedGen({
|
||||||
[fgUri.toString()]: async () => {
|
[fgUri.toString()]: () => {
|
||||||
return {
|
return {
|
||||||
encoding: 'application/json',
|
encoding: 'application/json' as const,
|
||||||
body: {
|
body: {
|
||||||
feed: posts.slice(0, 30).map(uri => ({post: uri})),
|
feed: posts.slice(0, 30).map(uri => ({post: uri})),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const avatarRes = await agent.api.com.atproto.repo.uploadBlob(this.pic, {
|
const avatarRes = await agent.com.atproto.repo.uploadBlob(this.pic, {
|
||||||
encoding: 'image/png',
|
encoding: 'image/png',
|
||||||
})
|
})
|
||||||
return await agent.api.app.bsky.feed.generator.create(
|
return await agent.app.bsky.feed.generator.create(
|
||||||
{repo: this.users[user].did, rkey},
|
{repo: this.users[user].did, rkey},
|
||||||
{
|
{
|
||||||
did: fg1.did,
|
did: fg1.did,
|
||||||
@@ -336,7 +342,7 @@ class Mocker {
|
|||||||
|
|
||||||
async createInvite(forAccount: string) {
|
async createInvite(forAccount: string) {
|
||||||
const agent = new BskyAgent({service: this.service})
|
const agent = new BskyAgent({service: this.service})
|
||||||
await agent.api.com.atproto.server.createInviteCode(
|
await agent.com.atproto.server.createInviteCode(
|
||||||
{useCount: 1, forAccount},
|
{useCount: 1, forAccount},
|
||||||
{
|
{
|
||||||
headers: this.pds.adminAuthHeaders(),
|
headers: this.pds.adminAuthHeaders(),
|
||||||
|
|||||||
+7
-37
@@ -1,47 +1,17 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"module": "commonjs",
|
"module": "nodenext",
|
||||||
"types": ["react-native", "jest"],
|
"moduleResolution": "nodenext",
|
||||||
"lib": [
|
"types": ["node"],
|
||||||
"es2019",
|
"lib": ["esnext"],
|
||||||
"es2020.bigint",
|
|
||||||
"es2020.date",
|
|
||||||
"es2020.number",
|
|
||||||
"es2020.promise",
|
|
||||||
"es2020.string",
|
|
||||||
"es2020.symbol.wellknown",
|
|
||||||
"es2021.promise",
|
|
||||||
"es2021.string",
|
|
||||||
"es2021.weakref",
|
|
||||||
"es2022.array",
|
|
||||||
"es2022.object",
|
|
||||||
"es2022.string"
|
|
||||||
],
|
|
||||||
"allowJs": true,
|
|
||||||
"jsx": "react-native",
|
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"moduleResolution": "node",
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"forceConsistentCasingInFileNames": false,
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"paths": {
|
"erasableSyntaxOnly": true,
|
||||||
"#/*": ["./src/*"],
|
"allowImportingTsExtensions": true
|
||||||
"lib/*": ["./src/lib/*"],
|
|
||||||
"platform/*": ["./src/platform/*"],
|
|
||||||
"state/*": ["./src/state/*"],
|
|
||||||
"view/*": ["./src/view/*"],
|
|
||||||
"crypto": ["./src/platform/crypto.ts"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": ["node_modules"]
|
||||||
"node_modules",
|
|
||||||
"babel.config.js",
|
|
||||||
"metro.config.js",
|
|
||||||
"jest.config.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
-4424
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -296,10 +296,10 @@ export default defineConfig(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bskyogcard - server-side, Node.js imports are fine
|
* bskyogcard, dev-env - server-side, Node.js imports are fine
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
files: ['bskyogcard/**/*.{js,jsx,ts,tsx}'],
|
files: ['bskyogcard/**/*.{js,jsx,ts,tsx}', 'dev-env/**/*.{js,jsx,ts,tsx}'],
|
||||||
rules: {
|
rules: {
|
||||||
'import-x/no-nodejs-modules': 'off',
|
'import-x/no-nodejs-modules': 'off',
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@
|
|||||||
"lint-native": "swiftlint ./modules && ktlint ./modules",
|
"lint-native": "swiftlint ./modules && ktlint ./modules",
|
||||||
"lint-native:fix": "swiftlint --fix ./modules && ktlint --format ./modules",
|
"lint-native:fix": "swiftlint --fix ./modules && ktlint --format ./modules",
|
||||||
"typecheck": "tsgo --project ./tsconfig.check.json",
|
"typecheck": "tsgo --project ./tsconfig.check.json",
|
||||||
"e2e:mock-server": "cd dev-env && yarn start",
|
"e2e:mock-server": "cd dev-env && pnpm start",
|
||||||
"e2e:build": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:ios",
|
"e2e:build": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:ios",
|
||||||
"e2e:build-android": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:android",
|
"e2e:build-android": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo run:android",
|
||||||
"e2e:start": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo start -c",
|
"e2e:start": "EXPO_PUBLIC_ENV=e2e NODE_ENV=test RN_SRC_EXT=e2e.ts,e2e.tsx expo start -c",
|
||||||
|
|||||||
Reference in New Issue
Block a user