Skip to content

Commit a71cabb

Browse files
silverwindtechknowlogick
authored andcommitted
add 'npm' and 'npm-update' make targets and lockfile (#7246)
* add 'npm' and 'npm-update' make targets and lockfile - `make npm` installs and updates node_modules, triggered automatically on `make css` and `make js` as it completes reasonably fast and ensures consistent modules. - `make npm-update` updates all dependencies to their latest version, regenerates `node_modules` from scratch and updates `package-lock.json`. It uses npm modules `updates` written by yours truly to find the latest version of each dependency. * add suggested make dependencies * remove package-lock.json during npm-update * regenerate package-lock.json
1 parent 33ad554 commit a71cabb

File tree

7 files changed

+4913
-36
lines changed

7 files changed

+4913
-36
lines changed

.drone.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ pipeline:
5252
image: webhippie/nodejs:latest
5353
pull: true
5454
commands:
55-
- npm install
5655
- make css
5756
- make js
5857
when:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ coverage.all
6767
/node_modules
6868
/modules/indexer/issues/indexers
6969
routers/repo/authorized_keys
70-
/package-lock.json
7170
/yarn.lock
7271

7372
# Snapcraft

.npmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
package-lock=false
21
save-exact=true

Makefile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -366,29 +366,32 @@ release-compress:
366366
fi
367367
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
368368

369-
.PHONY: js
370-
js:
371-
@if ([ ! -d "$(PWD)/node_modules" ]); then \
372-
echo "node_modules directory is absent, please run 'npm install' first"; \
369+
npm-check:
370+
@hash npm > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
371+
echo "Please install Node.js 8.x or greater with npm"; \
373372
exit 1; \
374373
fi;
375374
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
376-
echo "Please install npm version 5.2+"; \
375+
echo "Please install Node.js 8.x or greater with npm"; \
377376
exit 1; \
378377
fi;
378+
379+
.PHONY: npm
380+
npm: npm-check
381+
npm install --no-save
382+
383+
.PHONY: npm-update
384+
npm-update: npm-check
385+
npx updates -cu
386+
rm -rf node_modules package-lock.json
387+
npm install --package-lock
388+
389+
.PHONY: js
390+
js: npm
379391
npx eslint public/js
380392

381393
.PHONY: css
382-
css:
383-
@if ([ ! -d "$(PWD)/node_modules" ]); then \
384-
echo "node_modules directory is absent, please run 'npm install' first"; \
385-
exit 1; \
386-
fi;
387-
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
388-
echo "Please install npm version 5.2+"; \
389-
exit 1; \
390-
fi;
391-
394+
css: npm
392395
npx lesshint public/less/
393396
npx lessc --clean-css="--s0 -b" public/less/index.less public/css/index.css
394397
$(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),npx lessc --clean-css="--s0 -b" public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)

docs/content/doc/advanced/hacking-on-gitea.en-us.md

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,7 @@ make vet lint misspell-check
138138

139139
### Updating CSS
140140

141-
To generate the CSS, you will need [Node.js](https://nodejs.org/) 8.0 or greater and the build dependencies:
142-
143-
```bash
144-
npm install
145-
```
146-
147-
At present we use [less](http://lesscss.org/) and [postcss](https://postcss.org) to generate our CSS. Do
148-
**not** edit the files in `public/css` directly, as they are generated from `lessc` from the files in `public/less`.
141+
To generate the CSS, you will need [Node.js](https://nodejs.org/) 8.0 or greater with npm. At present we use [less](http://lesscss.org/) and [postcss](https://postcss.org) to generate our CSS. Do **not** edit the files in `public/css` directly, as they are generated from `lessc` from the files in `public/less`.
149142

150143
Edit files in `public/less`, run the linter, regenerate the CSS and commit all changed files:
151144

@@ -155,13 +148,7 @@ make css
155148

156149
### Updating JS
157150

158-
To run the JavaScript linter you will need [Node.js](https://nodejs.org/) 8.0 or greater and the build dependencies:
159-
160-
```bash
161-
npm install
162-
```
163-
164-
Edit files in `public/js` and run the linter:
151+
To run the JavaScript linter you will need [Node.js](https://nodejs.org/) 8.0 or greater with npm. Edit files in `public/js` and run the linter:
165152

166153
```bash
167154
make js
@@ -250,7 +237,7 @@ TAGS="bindata sqlite sqlite_unlock_notify" make generate build test-sqlite
250237
```
251238

252239
will run the integration tests in an sqlite environment. Other database tests
253-
are available but may need adjustment to the local environment.
240+
are available but may need adjustment to the local environment.
254241

255242
Look at
256243
[`integrations/README.md`](https://github.com/go-gitea/gitea/blob/master/integrations/README.md)

0 commit comments

Comments
 (0)