Skip to content

Commit

Permalink
fix(starter): Avoid using npx in scripts (#1200)
Browse files Browse the repository at this point in the history
Removes `npx` from the example scripts as npx [will fetch a remote
package](https://docs.npmjs.com/cli/v8/commands/npx) by default if a
local one is not found.

There was an issue raised by someone who was running `npx pg-migrations
blah blah` without the appropriate @databases/pg-migrations package
installed which led to `npx` downloading the wrong `pg-migrations`
package leading to confusing red herring errors.

This way it ensures that scripts require the dependencies to be
installed to run, and that they run with the specified versions.
msfstef authored Apr 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent dd5bd65 commit 784f737
Showing 12 changed files with 306 additions and 315 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-rocks-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-electric-app": patch
---

Remove usage of `npx` in template scripts to ensure correct package is used.
2 changes: 1 addition & 1 deletion examples/checkout/package.json
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
"backend:down": "cd ./backend && docker compose -f docker-compose.yml -f ./dev/docker-compose.dev.yml down -v --remove-orphans",
"client:generate": "electric-sql generate --service http://localhost:5133 --proxy postgresql://prisma:proxy_password@localhost:65432/postgres",
"client:watch": "npm run client:generate --watch",
"db:migrate": "electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:load-data": "node ./db/load-data.js",
"dev": "vite",
"build": "tsc && vite build",
18 changes: 9 additions & 9 deletions examples/expo/package.json
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@
"license": "Apache-2.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"electric:start": "npx electric-sql start",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"electric:start": "electric-sql start",
"start": "expo start",
"start:android": "expo start --android",
"start:ios": "expo start --ios"
20 changes: 10 additions & 10 deletions examples/ionic-demo/package.json
Original file line number Diff line number Diff line change
@@ -4,15 +4,15 @@
"version": "0.9.4",
"type": "module",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"electric:start": "npx electric-sql start",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"electric:start": "electric-sql start",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
@@ -21,7 +21,7 @@
"lint": "eslint",
"typecheck": "tsc --noEmit --skipLibCheck",
"format": "prettier --write --loglevel warn .",
"make-icons": "npx @capacitor/assets generate"
"make-icons": "@capacitor/assets generate"
},
"dependencies": {
"@capacitor-community/sqlite": "^5.6.2",
18 changes: 9 additions & 9 deletions examples/linearlite/package.json
Original file line number Diff line number Diff line change
@@ -4,19 +4,19 @@
"license": "Apache-2.0",
"type": "module",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"db:load-data": "node ./db/load_data.js",
"db:process-data": "node ./db/process_data.js",
"db:truncate": "node ./db/truncate.js",
"db:reload-data": "npm run db:truncate && npm run db:load-data",
"electric:start": "npx electric-sql start",
"electric:start": "electric-sql start",
"reset": "npm run backend:down && npm run backend:up && sleep 5 && npm run db:migrate && npm run client:generate && npm run db:load-data",
"dev": "vite",
"start": "npm run dev",
18 changes: 9 additions & 9 deletions examples/react-native/package.json
Original file line number Diff line number Diff line change
@@ -4,15 +4,15 @@
"author": "ElectricSQL",
"license": "Apache-2.0",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"electric:start": "npx electric-sql start",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"electric:start": "electric-sql start",
"pods:install": "cd ios && bundle install && bundle exec pod install && cd ..",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"start": "react-native start",
8 changes: 4 additions & 4 deletions examples/recipes/package.json
Original file line number Diff line number Diff line change
@@ -10,10 +10,10 @@
"backend:stop": "npm run backend:compose stop",
"backend:up": "npm run backend:compose up -- --detach",
"backend:down": "npm run backend:compose down -- --volumes",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
18 changes: 9 additions & 9 deletions examples/tauri-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -4,15 +4,15 @@
"author": "ElectricSQL",
"type": "module",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"electric:start": "npx electric-sql start",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"electric:start": "electric-sql start",
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
197 changes: 97 additions & 100 deletions examples/web-wa-sqlite-vuejs/package-lock.json
30 changes: 15 additions & 15 deletions examples/web-wa-sqlite-vuejs/package.json
Original file line number Diff line number Diff line change
@@ -5,34 +5,34 @@
"license": "Apache-2.0",
"type": "module",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"electric:start": "npx electric-sql start",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"electric:start": "electric-sql start",
"dev": "vite",
"build": "vue-tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"electric-sql": "^0.10.0",
"vue": "^3.4.21",
"wa-sqlite": "github:rhashimoto/wa-sqlite#semver:^0.9.8"
"vue": "^3.4.25",
"wa-sqlite": "github:rhashimoto/wa-sqlite#semver:^0.9.11"
},
"devDependencies": {
"@databases/pg-migrations": "^5.0.3",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-vue": "^5.0.4",
"eslint": "^8.57.0",
"eslint-plugin-vue": "^9.24.1",
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vue-tsc": "^2.0.11"
"eslint-plugin-vue": "^9.25.0",
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vue-tsc": "^2.0.14"
}
}
255 changes: 122 additions & 133 deletions examples/web-wa-sqlite/package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions examples/web-wa-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -5,37 +5,37 @@
"license": "Apache-2.0",
"type": "module",
"scripts": {
"backend:start": "npx electric-sql start --with-postgres",
"backend:stop": "npx electric-sql stop",
"backend:up": "npx electric-sql start --with-postgres --detach",
"backend:down": "npx electric-sql stop --remove",
"client:generate": "npx electric-sql generate",
"client:watch": "npx electric-sql generate --watch",
"db:migrate": "npx electric-sql with-config \"npx pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "npx electric-sql psql",
"electric:start": "npx electric-sql start",
"backend:start": "electric-sql start --with-postgres",
"backend:stop": "electric-sql stop",
"backend:up": "electric-sql start --with-postgres --detach",
"backend:down": "electric-sql stop --remove",
"client:generate": "electric-sql generate",
"client:watch": "electric-sql generate --watch",
"db:migrate": "electric-sql with-config \"pg-migrations apply --database {{ELECTRIC_PROXY}} --directory ./db/migrations\"",
"db:psql": "electric-sql psql",
"electric:start": "electric-sql start",
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"electric-sql": "^0.10.0",
"electric-sql": "^0.10.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"wa-sqlite": "github:rhashimoto/wa-sqlite#semver:^0.9.8"
"wa-sqlite": "github:rhashimoto/wa-sqlite#semver:^0.9.11"
},
"devDependencies": {
"@databases/pg-migrations": "^5.0.3",
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"typescript": "^5.4.4",
"vite": "^5.2.8"
"typescript": "^5.4.5",
"vite": "^5.2.10"
}
}

0 comments on commit 784f737

Please sign in to comment.