TagSpaces is an offline, open source, document manager with tagging support
use ws packaged with webpack
sytolk69dba0c59cc6
diff --git a/app/main.dev.ts b/app/main.dev.tsindex 25c2115f1..ae226852e 100644--- a/app/main.dev.ts+++ b/app/main.dev.ts@@ -557,12 +557,12 @@ app.on('ready', async () => {let script;let envPath;if (devMode || testMode) {- filepath = path.join(__dirname, 'node_modules/tagspaces-ws');+ filepath = path.join(__dirname, 'node_modules/tagspaces-ws/build');script = 'index.js';envPath = path.join(__dirname, '.env');} else {filepath = process.resourcesPath;- script = 'app.asar/node_modules/tagspaces-ws/index.js';+ script = 'app.asar/node_modules/tagspaces-ws/build/index.js';envPath = path.join(process.resourcesPath, 'app.asar/.env');}const properties = propertiesReader(envPath);diff --git a/app/package.json b/app/package.jsonindex bad955977..078483ed4 100644--- a/app/package.json+++ b/app/package.json@@ -11,8 +11,13 @@"url": "https://www.tagspaces.org"},"license": "AGPL-3.0",- "dependencies": {+ "scripts": {},+ "webDependencies": {+ "@tagspaces/extensions": "https://github.com/tagspaces/tagspaces-extensions#main"+ },+ "nodeDependencies": {"@tagspaces/extensions": "https://github.com/tagspaces/tagspaces-extensions#main",- "tagspaces-ws": "^1.0.37"+ "sharp": "^0.29.1",+ "tagspaces-ws": "^1.0.43"}}diff --git a/app/ws_install_sharp.js b/app/ws_install_sharp.jsnew file mode 100644index 000000000..da31b6af8--- /dev/null+++ b/app/ws_install_sharp.js@@ -0,0 +1,131 @@+#! /usr/bin/env node++const fs = require('fs-extra');+const path = require('path');+const npm = require('npm');+const pkg = require('./package.json');++let platform = 'node';++if (process.env.PD_PLATFORM) {+ platform = process.env.PD_PLATFORM;+}++/* function checkSharpPlatform(targetPlatform, arch) {+ try {+ let shrapPath = require.resolve('sharp');+ shrapPath = path.join(+ shrapPath,+ '..',+ '..',+ 'vendor',+ '8.11.3',+ 'platform.json'+ );+ if (!fs.existsSync(shrapPath)) {+ return false;+ }+ const data = fs.readFileSync(shrapPath, 'utf8');+ return data === '"' + targetPlatform + '-' + arch + '"';+ } catch (e) {+ return false;+ }+}++if (process.env.TARGET_PLATFORM && process.env.TARGET_ARCH) {+ process.argv.push('--platform=' + process.env.TARGET_PLATFORM);+ process.argv.push('--arch=' + process.env.TARGET_ARCH);+ if (+ !checkSharpPlatform(process.env.TARGET_PLATFORM, process.env.TARGET_ARCH)+ ) {+ // fs.removeSync(path.join(__dirname, '..', 'node_modules'));+ }+} */++const dependencies = platform + 'Dependencies';+const dependenciesObj = pkg[dependencies];++if (dependenciesObj && Object.keys(dependenciesObj).length) {+ console.log('Installing dependencies for ' + platform);+ const npmArgs = [];+ let npmInstall = false;++ for (const dep in dependenciesObj) {+ // eslint-disable-next-line no-prototype-builtins+ if (dependenciesObj.hasOwnProperty(dep)) {+ npmArgs.push(dep.concat('@').concat(dependenciesObj[dep]));+ const packagePath = path.join(__dirname, 'node_modules', dep);+ if (!fs.existsSync(packagePath)) {+ npmInstall = true;+ } else {+ const packageJson = require(path.join(packagePath, 'package.json'));+ const cleanVersion = dependenciesObj[dep].startsWith('^')+ ? dependenciesObj[dep].substr(1)+ : dependenciesObj[dep];+ if (+ packageJson.version !== cleanVersion &&+ !cleanVersion.endsWith('#main')+ ) {+ // TODO Temp fix tagspaces-extension is not npm package with version+ npmInstall = true;+ }+ }+ }+ }+ if (platform === 'web') {+ npmInstall = true;+ fs.removeSync(path.join(__dirname, 'node_modules'));+ }+ // npmArgs.push('--no-save --force');+ if (npmInstall && npmArgs.length > 0) {+ npm.load(er => {+ if (er) {+ console.log('err:', er);+ return; // handlError(er)+ }+ npm.config.set('save', false);+ npm.config.set('package-lock', false);+ // npm.config.set('no-save', true);+ // npm.config.set('no-package-lock', true);+ npm.commands.install(npmArgs, (err, data) => {+ if (err) {+ console.log('err:', err);+ }+ /* npm.commands.dedupe([], (er) => {+ if (er) {+ console.log("err:", er);+ }+ }); */+ });+ npm.on('log', message => {+ console.log('npm:' + message);+ });+ });+ } else {+ console.log(+ 'Installing dependencies for ' + platform + ' are already installed.'+ );+ }+} else {+ console.log('No specific dependencies on this platform: ' + platform);+ // fs.removeSync(path.join(__dirname, '..', 'node_modules'));+ /* const dir = path.join(__dirname, 'node_modules');+ fs.readdir(dir, (err, files) => {+ if (err) {+ console.log(err);+ }++ files.forEach(file => {+ if (file !== '@tagspaces') {+ const fileDir = path.join(dir, file);+ const isDir = fs.lstatSync(fileDir).isDirectory();+ if (isDir) {+ fs.rmdirSync(fileDir, { recursive: true });+ // fs.emptyDirSync(fileDir);+ } else {+ fs.unlinkSync(fileDir);+ }+ }+ });+ }); */+}diff --git a/package.json b/package.jsonindex 00f7475be..427a9cf1b 100644--- a/package.json+++ b/package.json@@ -51,11 +51,11 @@"package-win-pro": "cross-env TARGET_PLATFORM=win32 TARGET_ARCH=x64 yarn install-ext-node && electron-builder --win --x64 --config extensions/tagspacespro/resources/builder-pro.json","package-linux": "cross-env TARGET_PLATFORM=linux TARGET_ARCH=x64 yarn install-ext-node && electron-builder --linux --config resources/builder.json","package-linux-pro": "cross-env TARGET_PLATFORM=linux TARGET_ARCH=x64 yarn install-ext-node && electron-builder electron-builder --linux --config extensions/tagspacespro/resources/builder-pro.json",- "package-pro": "node scripts/enablepro.js && yarn install-ext && yarn build && yarn package-web-pro && yarn clean-maps && yarn package-win-pro && yarn package-linux-pro && yarn package-web-pro && yarn package-mac-pro",+ "package-pro": "node scripts/enablepro.js && yarn install-ext-node && yarn build && yarn package-web-pro && yarn clean-maps && yarn package-win-pro && yarn package-linux-pro && yarn package-web-pro && yarn package-mac-pro","package-android": "yarn build-cordova && cd cordova && npm install && cordova build --release android","package-web": "yarn prepare-web && yarn clean-maps && zip -r ../builds/tagspaces-web.zip web -x web/files/**\\*","package-web-pro": "yarn prepare-web-pro && yarn clean-maps && zip -r ../builds/tagspaces-pro-web.zip web -xi web/files/**\\* ",- "prepare-node": "yarn install-ext && yarn postinstall-node-check",+ "prepare-node": "yarn install-ext-node && yarn postinstall-node-check","prepare-web": "yarn version-meta && yarn install-ext-web && yarn postinstall-web-check && rimraf web/node_modules && shx cp -rL app/node_modules/ web && shx cp LICENSE.txt web","prepare-web-pro": "yarn version-meta && yarn install-ext-web && yarn postinstall-web-check && rimraf web/node_modules && shx cp -rL app/node_modules/ web && shx cp extensions/tagspacespro/EULA.txt web && node scripts/genswconf.js","prepare-cordova": "rimraf cordova/www/dist && rimraf cordova/www/node_modules && shx cp -rL app/node_modules cordova/www && shx cp LICENSE.txt cordova/www",@@ -68,10 +68,8 @@"clean": "rimraf node_modules && rimraf app/dist","clean-pro": "yarn clean-maps","clean-maps": "rimraf app/dist/**/*.map && rimraf web/dist/**/*.map",- "install-ext": "cd app && cross-env PD_PLATFORM=node yarn install --force --prod --no-lockfile && cd ..",- "install-ext-aws": "cd app && cross-env PD_PLATFORM=web yarn install --force --prod --no-lockfile && cd ..",- "install-ext-node": "cd app && cross-env PD_PLATFORM=node yarn add tagspaces-ws --force --prod --no-lockfile && cd ..",- "install-ext-web": "cd app && cross-env PD_PLATFORM=web yarn add tagspaces-ws --force --prod --no-lockfile && cd ..",+ "install-ext-node": "cd app && cross-env PD_PLATFORM=node node ws_install_sharp.js && cd ..",+ "install-ext-web": "cd app && cross-env PD_PLATFORM=web node ws_install_sharp.js && cd ..","setup-ext": "node scripts/setupextensions.js","setup-pro": "node scripts/setuppro.js","check-extensions": "node scripts/checkExtensions.js",