Skip to content

Commit 463814e

Browse files
authored
Improve NPM package to boost NPM search ranking (#260)
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent 8c42739 commit 463814e

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

.github/workflows/package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: JSON Schema
1+
name: CD
22

33
on:
44
push:

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: JSON Schema
1+
name: CI
22

33
on:
44
pull_request:

README.markdown

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
![JSON Schema](./assets/banner.png)
22

3+
[![NPM Version](https://img.shields.io/npm/v/@sourcemeta/jsonschema)](https://www.npmjs.com/package/@sourcemeta/jsonschema)
4+
[![GitHub Release](https://img.shields.io/github/v/release/sourcemeta/jsonschema)](https://github.com/sourcemeta/jsonschema/releases)
5+
[![GitHub Actions](https://github.com/sourcemeta/jsonschema/actions/workflows/test.yml/badge.svg)](https://github.com/sourcemeta/jsonschema/actions)
6+
[![GitHub contributors](https://img.shields.io/github/contributors/sourcemeta/jsonschema.svg)](https://github.com/sourcemeta/jsonschema/graphs/contributors/)
7+
38
The command-line tool for working with [JSON Schema](https://json-schema.org),
49
the world most popular schema language. It is a comprehensive solution for
510
maintaining **repositories of schemas** and ensuring their quality, both during

npm-deploy.sh

+49-5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ install -m 0755 "$OUTPUT/npm/artifacts/jsonschema-$VERSION-windows-x86_64/bin/js
4444
"$OUTPUT/npm/staging/jsonschema-windows-x86_64.exe"
4545
install -m 0644 "$(pwd)/README.markdown" "$OUTPUT/npm/staging/README.md"
4646

47+
# To boost NPM ranking
48+
# See https://github.com/npms-io/npms-analyzer/blob/master/lib/analyze/evaluate/quality.js
49+
install -m 0644 "$(pwd)/LICENSE" "$OUTPUT/npm/staging/LICENSE"
50+
install -m 0644 "$(pwd)/.gitignore" "$OUTPUT/npm/staging/.gitignore"
51+
echo "/build" > "$OUTPUT/npm/staging/.npmignore"
52+
4753
cat << EOF > "$OUTPUT/npm/staging/package.json"
4854
{
4955
"name": "@sourcemeta/jsonschema",
@@ -53,14 +59,28 @@ cat << EOF > "$OUTPUT/npm/staging/package.json"
5359
"bin": {
5460
"jsonschema": "cli.js"
5561
},
62+
"scripts": {
63+
"test": "eslint cli.js && node cli.js"
64+
},
5665
"license": "AGPL-3.0",
5766
"homepage": "https://github.com/sourcemeta/jsonschema",
58-
"author": "Juan Cruz Viotti <[email protected]>",
67+
"author": {
68+
"email": "[email protected]",
69+
"name": "Sourcemeta",
70+
"url": "https://wwwsourcemeta.com"
71+
},
72+
"os": [ "darwin", "linux", "win32" ],
73+
"cpu": [ "x64", "arm64" ],
74+
"engines": {
75+
"node": ">=16"
76+
},
77+
"funding": "https://github.com/sponsors/sourcemeta",
5978
"keywords": [
6079
"jsonschema", "json", "schema", "json-schema",
6180
"cli", "\$ref", "dereference", "reference", "resolve",
62-
"json-pointer", "validator", "bundle",
63-
"lint", "format"
81+
"json-pointer", "validator", "validation", "bundle",
82+
"json-schema-validator", "json-schema-validation",
83+
"lint", "format", "draft"
6484
],
6585
"bugs": {
6686
"url": "https://github.com/sourcemeta/jsonschema/issues"
@@ -71,6 +91,11 @@ cat << EOF > "$OUTPUT/npm/staging/package.json"
7191
},
7292
"publishConfig": {
7393
"access": "public"
94+
},
95+
"devDependencies": {
96+
"@eslint/js": "^9.23.0",
97+
"eslint": "^9.23.0",
98+
"globals": "^16.0.0"
7499
}
75100
}
76101
EOF
@@ -103,10 +128,29 @@ const result = child_process.spawnSync(EXECUTABLE,
103128
process.exit(result.status);
104129
EOF
105130

106-
# (3) Try packaging
131+
cat << 'EOF' > "$OUTPUT/npm/staging/eslint.config.mjs"
132+
import { defineConfig } from "eslint/config";
133+
import globals from "globals";
134+
import js from "@eslint/js";
135+
136+
export default defineConfig([
137+
{ files: ["**/*.{js,mjs,cjs}"] },
138+
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
139+
{ files: ["**/*.{js,mjs,cjs}"], languageOptions: { globals: globals.node } },
140+
{ files: ["**/*.{js,mjs,cjs}"], plugins: { js }, extends: ["js/recommended"] },
141+
]);
142+
EOF
143+
144+
# (3) Run checks
145+
cd "$OUTPUT/npm/staging"
146+
npm install
147+
npm test
148+
cd -
149+
150+
# (4) Try packaging
107151
cd "$OUTPUT/npm"
108152
npm pack ./staging
109153
cd -
110154

111-
# (4) Deploy to NPM
155+
# (5) Deploy to NPM
112156
npm publish "$OUTPUT/npm/staging"

0 commit comments

Comments
 (0)