Skip to content

Commit 3284633

Browse files
committed
Prepare for npm package
1 parent 3990407 commit 3284633

File tree

7 files changed

+69
-6
lines changed

7 files changed

+69
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
icons/build
33
static/themes.json
4+
dist/

package.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@
55
"author": "Sourcepole AG",
66
"license": "BSD-2-Clause",
77
"repository": "[email protected]:qgis/qwc2.git",
8+
"homepage": "https://https://qwc-services.github.io/",
9+
"bugs": {
10+
"url": "https://github.com/qgis/qwc2/issues"
11+
},
12+
"keywords": [
13+
"qgis",
14+
"webgis",
15+
"mapping",
16+
"geospatial"
17+
],
818
"dependencies": {
19+
"@furkot/webfonts-generator": "^2.0.2",
920
"@giro3d/giro3d": "^0.42.2",
1021
"@kayahr/text-encoding": "^2.0.0",
1122
"@loaders.gl/core": "^4.3.3",
@@ -36,8 +47,10 @@
3647
"lodash.isequal": "^4.5.0",
3748
"lodash.omit": "^4.5.0",
3849
"mime-to-extensions": "^1.0.2",
50+
"mkdirp": "^3.0.1",
3951
"mousetrap": "^1.6.5",
4052
"nearley": "^2.20.1",
53+
"object-path": "^0.11.8",
4154
"ol": "^10.3.1",
4255
"ol-ext": "^4.0.24",
4356
"ol-mapbox-style": "^12.3.5",
@@ -74,13 +87,13 @@
7487
"uuid": "^11.0.3"
7588
},
7689
"devDependencies": {
90+
"@babel/cli": "^7.27.0",
7791
"@babel/core": "^7.26.0",
7892
"@babel/eslint-parser": "^7.25.9",
7993
"@babel/plugin-transform-class-properties": "^7.25.9",
8094
"@babel/plugin-transform-object-rest-spread": "^7.25.9",
8195
"@babel/preset-env": "^7.26.0",
8296
"@babel/preset-react": "^7.26.3",
83-
"@furkot/webfonts-generator": "^2.0.2",
8497
"@microsoft/eslint-formatter-sarif": "^3.1.0",
8598
"@types/react": "^18.3.1",
8699
"babel-loader": "^9.2.1",
@@ -92,8 +105,6 @@
92105
"eslint-plugin-perfectionist": "^2.10.0",
93106
"eslint-plugin-react": "^7.37.2",
94107
"html-webpack-plugin": "^5.6.3",
95-
"mkdirp": "^3.0.1",
96-
"object-path": "^0.11.8",
97108
"react-docgen": "^5.4.3",
98109
"source-map-loader": "^5.0.0",
99110
"style-loader": "^4.0.0",
@@ -103,13 +114,19 @@
103114
"webpack-cli": "^5.1.4",
104115
"webpack-dev-server": "^5.1.0"
105116
},
117+
"bin": {
118+
"qwc_build_iconfont": "./scripts/makeIconkit.js",
119+
"qwc_gen_themesconfig": "./scripts/themesConfig.js",
120+
"qwc_update_translations": "./scripts/updateTranslations.js"
121+
},
106122
"scripts": {
107123
"prod": "npm run tsupdate && npm run themesconfig && npm run iconfont && webpack --mode production --progress",
108124
"start": "npm run tsupdate && npm run themesconfig && npm run iconfont && webpack serve --mode development --progress --host 0.0.0.0 --port 8081",
109125
"iconfont": "node scripts/makeIconkit.js",
110126
"themesconfig": "node scripts/themesConfig.js || :",
111127
"tsupdate": "node scripts/updateTranslations.js",
112128
"plugindoc": "node scripts/gen-plugin-docs.js",
129+
"dist": "./scripts/dist.sh",
113130
"build": "npm run prod",
114131
"analyze": "webpack --mode production --json | webpack-bundle-size-analyzer",
115132
"release": "node -e \"process.exit(require('os').platform() === 'win32' ? 0 : 1)\" && scripts\\package-commands.bat release || ./scripts/package-commands.sh release"

scripts/dist.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#/bin/bash
2+
3+
rm -rf dist
4+
for dir in actions components libs plugins reducers scripts selectors stores utils;
5+
do
6+
mkdir -p dist/$dir
7+
npx babel $dir --copy-files --out-dir dist/$dir --extensions ".js,.jsx" --minified
8+
done
9+
mkdir -p dist/static/translations
10+
mkdir -p dist/icons
11+
cp -a icons/*.svg dist/icons/
12+
cp -a static/translations/*.json dist/static/translations/
13+
cp -a {package.json,LICENSE,README.md} dist/
14+
15+
echo "Ready to publish!"
16+
echo "Run publish in the dist folder to publish the package."

scripts/gen-plugin-docs.js

100644100755
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Copyright 2024 Sourcepole AG
5+
* All rights reserved.
6+
*
7+
* This source code is licensed under the BSD-style license found in the
8+
* LICENSE file in the root directory of this source tree.
9+
*/
10+
11+
112
const fs = require("fs");
213
const path = require("path");
314
const reactDocs = require("react-docgen");

scripts/makeIconkit.js

100644100755
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
const webfontsGenerator = require('@furkot/webfonts-generator');
24
const glob = require('glob');
35
const mkdirp = require('mkdirp');
@@ -12,12 +14,18 @@ const readJSON = (filename) => {
1214
}
1315
};
1416

15-
const workspaces = readJSON('/package.json').workspaces || [];
17+
// Determine workspaces / dependencies
18+
const packageJson = readJSON('/package.json');
19+
const workspaces = packageJson.workspaces || [];
20+
const qwcDeps = Object.keys(packageJson.dependencies ?? {"qwc2": "0"}).filter(dep => dep.startsWith("qwc"));
1621

1722
let icons = [];
1823
for (const workspace of workspaces) {
1924
icons = icons.concat(glob.sync(workspace + "/icons/*.svg"));
2025
}
26+
for (const qwcDep of qwcDeps) {
27+
icons = icons.concat(glob.sync('node_modules/' + qwcDep + '/icons/*.svg'));
28+
}
2129
icons = icons.concat(glob.sync("icons/*.svg"));
2230

2331
// Filter duplicate icons (user icons can override submodule icons, hence reverse)

scripts/themesConfig.js

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
/**
24
* Copyright 2016-2024 Sourcepole AG
35
* All rights reserved.

scripts/updateTranslations.js

100644100755
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
/**
24
* Copyright 2017-2024 Sourcepole AG
35
* All rights reserved.
@@ -89,8 +91,10 @@ const updateTsConfig = (topdir, tsconfig, collectedMsgIds = null) => {
8991
return msgIds;
9092
};
9193

92-
// Determine workspaces
93-
const workspaces = readJSON('/package.json').workspaces || [];
94+
// Determine workspaces / dependencies
95+
const packageJson = readJSON('/package.json');
96+
const workspaces = packageJson.workspaces || [];
97+
const qwcDeps = Object.keys(packageJson.dependencies ?? {qwc2: "0"}).filter(dep => dep.startsWith("qwc"));
9498

9599
// Generate workspace translations
96100
let collectedMsgIds = new Set();
@@ -141,6 +145,10 @@ for (const lang of config.languages || []) {
141145
for (const workspace of workspaces) {
142146
data = merge(data, readJSON('/' + workspace + '/static/translations/' + lang + '.json'));
143147
}
148+
// Merge translations from dependencies
149+
for (const qwcDep of qwcDeps) {
150+
data = merge(data, readJSON('/node_modules/' + qwcDep + '/static/translations/' + lang + '.json'));
151+
}
144152

145153
// Revert to original values for strings specified in overrides
146154
for (const path of config.overrides || []) {

0 commit comments

Comments
 (0)