Skip to content

Commit

Permalink
Fix dev env package (#1245)
Browse files Browse the repository at this point in the history
* v0.2.1

* fix dev-env publish

* v0.2.2

* fix package.json
  • Loading branch information
dholms committed Jun 28, 2023
1 parent ba870d3 commit 207d447
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/bsky/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/bsky",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
60 changes: 35 additions & 25 deletions packages/dev-env/build.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
const pkgJson = require('@npmcli/package-json')
const { copy } = require('esbuild-plugin-copy')
const { nodeExternalsPlugin } = require('esbuild-node-externals')

require('esbuild')
.build({
logLevel: 'info',
entryPoints: ['src/index.ts', 'src/bin.ts'],
bundle: true,
sourcemap: true,
outdir: 'dist',
platform: 'node',
external: [
'better-sqlite3',
// Referenced in pg driver, but optional and we don't use it
'pg-native',
'sharp',
],
plugins: [
copy({
assets: {
from: ['../pds/src/mailer/templates/**/*'],
to: ['./templates'],
keepStructure: true,
},
}),
],
})
.catch(() => process.exit(1))
const buildShallow =
process.argv.includes('--shallow') || process.env.ATP_BUILD_SHALLOW === 'true'

if (process.argv.includes('--update-main-to-dist')) {
return pkgJson
.load(__dirname)
.then((pkg) => pkg.update({ main: 'dist/index.js' }))
.then((pkg) => pkg.save())
}

require('esbuild').build({
logLevel: 'info',
entryPoints: ['src/index.ts', 'src/bin.ts'],
bundle: true,
sourcemap: true,
outdir: 'dist',
platform: 'node',
external: [
'better-sqlite3',
// Referenced in pg driver, but optional and we don't use it
'pg-native',
'sharp',
],
plugins: [].concat(buildShallow ? [nodeExternalsPlugin()] : []).concat([
copy({
assets: {
from: ['../pds/src/mailer/templates/**/*'],
to: ['./templates'],
keepStructure: true,
},
}),
]),
})
8 changes: 6 additions & 2 deletions packages/dev-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/dev-env",
"version": "0.2.0",
"version": "0.2.2",
"main": "src/index.ts",
"bin": "dist/bin.js",
"license": "MIT",
Expand All @@ -18,7 +18,11 @@
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "yarn lint --fix",
"verify": "run-p prettier lint",
"verify:fix": "yarn prettier:fix && yarn lint:fix"
"verify:fix": "yarn prettier:fix && yarn lint:fix",
"update-main-to-dist": "node ./update-pkg.js --update-main-to-dist",
"update-main-to-src": "node ./update-pkg.js --update-main-to-src",
"prepublish": "npm run update-main-to-dist",
"postpublish": "npm run update-main-to-src"
},
"dependencies": {
"@atproto/api": "*",
Expand Down
1 change: 1 addition & 0 deletions packages/dev-env/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist", // Your outDir,
"emitDeclarationOnly": true
},
Expand Down
14 changes: 14 additions & 0 deletions packages/dev-env/update-pkg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const pkgJson = require('@npmcli/package-json')

if (process.argv.includes('--update-main-to-dist')) {
return pkgJson
.load(__dirname)
.then((pkg) => pkg.update({ main: 'dist/index.js' }))
.then((pkg) => pkg.save())
}
if (process.argv.includes('--update-main-to-src')) {
return pkgJson
.load(__dirname)
.then((pkg) => pkg.update({ main: 'src/index.ts' }))
.then((pkg) => pkg.save())
}

0 comments on commit 207d447

Please sign in to comment.