[pnpm] Migrate devenv (#10480)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {createServer as createHTTPServer} from 'node:http'
|
||||
import {parse} from 'node:url'
|
||||
|
||||
import {createServer, type TestPDS} from './test-pds'
|
||||
import {createServer, type TestPDS} from './test-pds.ts'
|
||||
|
||||
let server: TestPDS
|
||||
// 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', 'carla')
|
||||
console.log('Generating mock posts')
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let posts: Record<string, any[]> = {
|
||||
alice: [],
|
||||
bob: [],
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{
|
||||
"name": "dev-env",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"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": {
|
||||
"@atproto/dev-env": "^0.3.215",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^6.0.2"
|
||||
"@atproto/api": "^0.20.0",
|
||||
"@atproto/dev-env": "^0.5.0",
|
||||
"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 {type TestBsky, TestNetwork} from '@atproto/dev-env'
|
||||
import fs from 'fs'
|
||||
import net from 'net'
|
||||
import path from 'path'
|
||||
|
||||
export interface TestUser {
|
||||
email: string
|
||||
@@ -21,9 +22,11 @@ export interface TestPDS {
|
||||
|
||||
class StringIdGenerator {
|
||||
_nextId = [0]
|
||||
constructor(
|
||||
public _chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
) {}
|
||||
_chars: string
|
||||
|
||||
constructor(chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
|
||||
this._chars = chars
|
||||
}
|
||||
|
||||
next() {
|
||||
const r = []
|
||||
@@ -83,13 +86,13 @@ export async function createServer(
|
||||
// DISABLED - looks like dev-env added this and now it conflicts
|
||||
// add the test mod authority
|
||||
// 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',
|
||||
// handle: 'mod-authority.test',
|
||||
// password: 'hunter2',
|
||||
// })
|
||||
// agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`)
|
||||
// await agent.api.app.bsky.actor.profile.create(
|
||||
// agent.setHeader('Authorization', `Bearer ${res.data.accessJwt}`)
|
||||
// await agent.app.bsky.actor.profile.create(
|
||||
// {repo: res.data.did},
|
||||
// {
|
||||
// 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'},
|
||||
// {
|
||||
// policies: {
|
||||
@@ -109,7 +112,7 @@ export async function createServer(
|
||||
// )
|
||||
|
||||
const pic = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'assets', 'default-avatar.png'),
|
||||
path.join(import.meta.dirname, '..', 'assets', 'default-avatar.png'),
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -125,12 +128,14 @@ export async function createServer(
|
||||
class Mocker {
|
||||
agent: BskyAgent
|
||||
users: Record<string, TestUser> = {}
|
||||
testNet: TestNetwork
|
||||
service: string
|
||||
pic: Uint8Array
|
||||
|
||||
constructor(
|
||||
public testNet: TestNetwork,
|
||||
public service: string,
|
||||
public pic: Uint8Array,
|
||||
) {
|
||||
constructor(testNet: TestNetwork, service: string, pic: Uint8Array) {
|
||||
this.testNet = testNet
|
||||
this.service = service
|
||||
this.pic = pic
|
||||
this.agent = new BskyAgent({service})
|
||||
}
|
||||
|
||||
@@ -161,7 +166,7 @@ class Mocker {
|
||||
async createUser(name: string) {
|
||||
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},
|
||||
{
|
||||
headers: this.pds.adminAuthHeaders(),
|
||||
@@ -309,20 +314,21 @@ class Mocker {
|
||||
'app.bsky.feed.generator',
|
||||
rkey,
|
||||
)
|
||||
// @ts-expect-error
|
||||
const fg1 = await this.testNet.createFeedGen({
|
||||
[fgUri.toString()]: async () => {
|
||||
[fgUri.toString()]: () => {
|
||||
return {
|
||||
encoding: 'application/json',
|
||||
encoding: 'application/json' as const,
|
||||
body: {
|
||||
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',
|
||||
})
|
||||
return await agent.api.app.bsky.feed.generator.create(
|
||||
return await agent.app.bsky.feed.generator.create(
|
||||
{repo: this.users[user].did, rkey},
|
||||
{
|
||||
did: fg1.did,
|
||||
@@ -336,7 +342,7 @@ class Mocker {
|
||||
|
||||
async createInvite(forAccount: string) {
|
||||
const agent = new BskyAgent({service: this.service})
|
||||
await agent.api.com.atproto.server.createInviteCode(
|
||||
await agent.com.atproto.server.createInviteCode(
|
||||
{useCount: 1, forAccount},
|
||||
{
|
||||
headers: this.pds.adminAuthHeaders(),
|
||||
|
||||
+7
-37
@@ -1,47 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "commonjs",
|
||||
"types": ["react-native", "jest"],
|
||||
"lib": [
|
||||
"es2019",
|
||||
"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",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"types": ["node"],
|
||||
"lib": ["esnext"],
|
||||
"noEmit": true,
|
||||
"isolatedModules": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"paths": {
|
||||
"#/*": ["./src/*"],
|
||||
"lib/*": ["./src/lib/*"],
|
||||
"platform/*": ["./src/platform/*"],
|
||||
"state/*": ["./src/state/*"],
|
||||
"view/*": ["./src/view/*"],
|
||||
"crypto": ["./src/platform/crypto.ts"]
|
||||
}
|
||||
"erasableSyntaxOnly": true,
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"babel.config.js",
|
||||
"metro.config.js",
|
||||
"jest.config.js"
|
||||
]
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
-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: {
|
||||
'import-x/no-nodejs-modules': 'off',
|
||||
},
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@
|
||||
"lint-native": "swiftlint ./modules && ktlint ./modules",
|
||||
"lint-native:fix": "swiftlint --fix ./modules && ktlint --format ./modules",
|
||||
"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-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",
|
||||
|
||||
Reference in New Issue
Block a user