Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix: tsamp update script does not update the extensions (#1840)

Stanimir1762979e634e
diff --git a/package.json b/package.json
index a86ca761b..7c570321a 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,6 @@
"build-web": "rimraf web/dist && webpack --config ./configs/webpack.config.web.prod.babel.js",
"build-web-dev": "rimraf web/dist && webpack --config ./configs/webpack.config.web.dev.babel.js",
"bump-version": "npm run third-party && cd app && yarn version && cd .. && npm run version-meta",
- "check-extensions": "node scripts/checkExtensions.js",
"clean": "rimraf node_modules && rimraf app/dist",
"clean-maps": "rimraf app/dist/**/*.map && rimraf web/dist/**/*.map",
"clean-pro": "npm run clean-maps",
@@ -48,7 +47,7 @@
"cordova-list-emulators": "cd cordova && cordova run --list --emulator && cd ..",
"cordova-remove-android": "cd cordova && cordova platform remove android && cd ..",
"cordova-remove-ios": "cd cordova && cordova platform remove ios && cd ..",
- "dev": "npm run prepare-node && npm run generate-jwt && npm run check-extensions && cross-env START_HOT=1 node -r @babel/register ./internals/scripts/CheckPortInUse.js && cross-env START_HOT=1 npm run start-renderer-dev",
+ "dev": "npm run prepare-node && npm run generate-jwt && cross-env START_HOT=1 node -r @babel/register ./internals/scripts/CheckPortInUse.js && cross-env START_HOT=1 npm run start-renderer-dev",
"generate-jwt": "node scripts/jwt_generate.js",
"install-ext-node-check": "npx cross-env PD_PLATFORM=node node scripts/checkWSinstalled.js",
"install-ext-web-check": "npx cross-env PD_PLATFORM=web node scripts/checkWSinstalled.js",
diff --git a/scripts/checkWSinstalled.js b/scripts/checkWSinstalled.js
index 62667f675..a30bfd306 100644
--- a/scripts/checkWSinstalled.js
+++ b/scripts/checkWSinstalled.js
@@ -2,12 +2,30 @@
const path = require('path');
const fs = require('fs-extra');
-const shell = require('shelljs');
+// const shell = require('shelljs');
+const childProcess = require('child_process');
+const packageJson = require('../app/package.json');
-function isInstalled(packageName) {
+function isInstalled(packageName, checkVersion = undefined) {
try {
- require.resolve('../app/node_modules/' + packageName);
- return true;
+ const packageVersions =
+ packageName + (checkVersion ? '@' + checkVersion : '');
+ const versions = childProcess
+ .execSync('npm list --depth=0 --prefix ' + path.join(__dirname, '../app'))
+ //.execSync('npm view ' + packageName + ' version')
+ .toString();
+ if (versions.indexOf(packageVersions) > 0) {
+ return true;
+ }
+ /*if (checkVersion) {
+ if (checkVersion === version) {
+ return true;
+ }
+ } else if (version.length > 0) {
+ return true;
+ }*/
+ // require.resolve('../app/node_modules/' + packageName);
+ return false;
} catch (err) {
return false;
}
@@ -53,20 +71,35 @@ if (platform === 'node') {
if (
//!checkSharpPlatform(process.env.TARGET_PLATFORM, process.env.TARGET_ARCH) ||
!dirExist(dir) ||
- !isInstalled('@tagspaces/tagspaces-ws')
+ !isInstalled(
+ '@tagspaces/extensions',
+ packageJson.nodeDependencies['@tagspaces/extensions']
+ ) ||
+ !isInstalled(
+ '@tagspaces/tagspaces-ws',
+ packageJson.nodeDependencies['@tagspaces/tagspaces-ws']
+ )
) {
installCmd = 'npm run-script install-ext-node';
}
} else if (platform === 'web') {
- if (!dirExist(dir) || isInstalled('@tagspaces/tagspaces-ws')) {
+ if (
+ !dirExist(dir) ||
+ !isInstalled(
+ '@tagspaces/extensions',
+ packageJson.webDependencies['@tagspaces/extensions']
+ ) ||
+ isInstalled('@tagspaces/tagspaces-ws')
+ ) {
installCmd = 'npm run-script install-ext-web';
}
}
if (installCmd) {
- if (shell.exec(installCmd).code !== 0) {
+ console.log(childProcess.execSync(installCmd).toString());
+ /*if (shell.exec(installCmd).code !== 0) {
shell.echo(
'Error: Install ' + process.env.PD_PLATFORM + ' platform failed'
);
shell.exit(1);
- }
+ }*/
}