Skip to content

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

chore: cleaning codebase

Ilian Sapundshiev62a45c44fdc2
diff --git a/.erb/scripts/notarize.js b/.erb/scripts/notarize.js
deleted file mode 100644
index 8c0fe26f2..000000000
--- a/.erb/scripts/notarize.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const { notarize } = require('@electron/notarize');
-
-exports.default = async function notarizeMacos(context) {
- const { electronPlatformName, appOutDir } = context;
- if (electronPlatformName !== 'darwin') {
- return;
- }
-
- // if (process.env.CI !== 'true') {
- // console.warn('Skipping notarizing step. Packaging is not running in CI');
- // return;
- // }
-
- if (
- !(
- 'APPLE_ID' in process.env &&
- 'APPLE_APP_SPECIFIC_PASSWORD' in process.env &&
- 'APPLE_TEAMID' in process.env
- )
- ) {
- console.warn(
- 'Skipping notarizing step. APPLE_ID, APPEL_TEAMID and APPLE_APP_SPECIFIC_PASSWORD env variables must be set',
- );
- return;
- }
-
- const appName = context.packager.appInfo.productFilename;
- const appId = context.packager.info._configuration.appId;
- const appPath = `${appOutDir}/${appName}.app`;
-
- console.warn(JSON.stringify(process.env.APPLE_ID) + ' ' + appId);
- console.warn('Output: ' + appOutDir);
- console.warn('AppPath: ' + appPath);
-
- await notarize({
- appBundleId: appId,
- appPath: appPath,
- appleId: process.env.APPLE_ID,
- teamId: process.env.APPLE_TEAMID,
- appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD,
- });
-};
diff --git a/scripts/afterSign.js b/scripts/afterSign.js
deleted file mode 100644
index d8e6de7c6..000000000
--- a/scripts/afterSign.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// "afterSign": "./afterSignHook.js",
-
-require('dotenv').config();
-// console.log(process.env);
-const fs = require('fs');
-const path = require('path');
-var electron_notarize = require('electron-notarize');
-
-module.exports = async function (params) {
- if (process.platform !== 'darwin') {
- return;
- }
-
- console.log('afterSign hook triggered', params);
-
- let appId = 'org.tagspaces.desktopapp';
-
- let appPath = path.join(
- params.appOutDir,
- `${params.packager.appInfo.productFilename}.app`,
- );
- if (!fs.existsSync(appPath)) {
- console.log('skip');
- return;
- }
-
- console.log(`Notarizing ${appId} found at ${appPath}`);
-
- try {
- await electron_notarize.notarize({
- appBundleId: appId,
- appPath: appPath,
- appleId: process.env.APPLE_ID,
- appleIdPassword: process.env.APPLE_ID_PASSWORD,
- });
- } catch (error) {
- console.error(error);
- }
-
- console.log(`Done notarizing ${appId}`);
-};
diff --git a/scripts/app-package-gen.js b/scripts/app-package-gen.js
deleted file mode 100644
index 62dfa457b..000000000
--- a/scripts/app-package-gen.js
+++ /dev/null
@@ -1,35 +0,0 @@
-#! /usr/bin/env node
-/**
- * @deprecated (replaced by @tagspaces/dynamic-packages-loading)
- * write the package.json file from package-template.json
- */
-/*const fs = require('fs-extra');
-const path = require('path');
-const pkg = require('../app/package.json');
-const pkgTemplate = require('../app/package-template.json');
-
-let platform = 'node';
-
-if (process.env.PD_PLATFORM) {
- platform = process.env.PD_PLATFORM;
-}
-
-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);
-}
-
-const dep = platform + 'Dependencies';
-
-const dependencies = pkgTemplate[dep];
-
-if (dependencies && Object.keys(dependencies).length) {
- console.log('Installing dependencies for ' + platform);
- fs.writeFileSync(
- 'package.json',
- JSON.stringify({ ...pkg, dependencies }, null, 2),
- );
-} else {
- console.log('No specific dependencies on this platform: ' + platform);
- fs.removeSync(path.join(__dirname, '..', 'app', 'node_modules'));
-}*/
diff --git a/scripts/app-package-install-npm.js b/scripts/app-package-install-npm.js
deleted file mode 100644
index 70f1570d9..000000000
--- a/scripts/app-package-install-npm.js
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-#! /usr/bin/env node
-
-const fs = require('fs-extra');
-const path = require('path');
-const npm = require('npm');
-const pkg = require('../app/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,
- '..',
- 'app',
- '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) {
- // TODO Temp fix tagspaces-extension is not npm package with version
- npmInstall = true;
- }
- }
- }
- }
- if (platform === 'web') {
- npmInstall = true;
- fs.removeSync(path.join(__dirname, '..', 'app', '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);
- }
- fs.removeSync(
- path.join(
- __dirname,
- '..',
- 'app',
- 'node_modules',
- '@tagspaces',
- 'extensions',
- 'md-editor',
- 'node_modules',
- ),
- );
- fs.removeSync(
- path.join(
- __dirname,
- '..',
- 'app',
- 'node_modules',
- '@tagspaces',
- 'extensions',
- 'md-editor',
- 'src',
- ),
- );
- /!* 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/scripts/setup-tests.js b/scripts/setup-tests.js
index cc8a1eec7..c6d34b958 100644
--- a/scripts/setup-tests.js
+++ b/scripts/setup-tests.js
@@ -5,73 +5,3 @@ fs.outputFileSync(
pathLib.join(__dirname, '../release/app/.env'),
'KEY=e2eTestKey',
);
-
-/* const sh = require('shelljs');
-const path = require('path');
-// const fs = require('fs-extra');
-
-if (!sh.which('git')) {
- sh.echo('Sorry, this script requires git');
- sh.exit(1);
-}
-
-if (!sh.which('yarn')) {
- sh.echo('Sorry, this script requires yarn');
- sh.exit(1);
-}
-
-const extensionDir = path.resolve(__dirname, '../tests');
-if (!sh.test('-d', extensionDir)) {
- sh.mkdir(extensionDir);
-}
-
-sh.cd(extensionDir); */
-
-/**
- * @Deprecated use github action script for setup instead
- */
-/*
-const extensionBranch = 'master';
-const extensionList = [
- {
- path: 'testdata',
- url: 'https://github.com/tagspaces/testdata'
- }
-];
-
-extensionList.forEach(extension => {
- if (sh.test('-d', extension.path)) {
- sh.cd(extension.path);
- sh.exec('git checkout ' + extensionBranch);
- sh.exec('git pull');
- } else {
- sh.exec('git clone -b ' + extensionBranch + ' ' + extension.url);
- sh.cd(extension.path);
- }
- sh.cd('..');
-});
-
-// Download
-const winUrl = 'https://dl.min.io/server/minio/release/windows-amd64/minio.exe';
-const linuxUrl = 'https://dl.min.io/server/minio/release/linux-amd64/minio';
-const macUrl = 'https://dl.min.io/server/minio/release/darwin-amd64/minio';
-const isWin = /^win/.test(process.platform);
-const isMac = /^darwin/.test(process.platform);
-const isLinux = /^linux/.test(process.platform);
-const url = isWin ? winUrl : isMac ? macUrl : isLinux ? linuxUrl : undefined;
-
-const outDir = path.resolve(__dirname, '../tests/bin');
-if (!sh.test('-d', outDir)) {
- sh.mkdir(outDir);
- sh.cd(outDir);
- sh.exec('curl -O -J ' + url);
- if (!isWin) {
- sh.exec('chmod -R +x .');
- }
-}
-*/
-/* const outFile = path.join(outDir, 'minio.exe');
-if (!fs.existsSync(outFile)) {
- //! sh.test('-d', 'bin') ||
- sh.exec('curl -O -J ' + outFile + ' ' + url);
-} */
diff --git a/scripts/startS3server.js b/scripts/startS3server.js
index d4f4513d1..f73506800 100644
--- a/scripts/startS3server.js
+++ b/scripts/startS3server.js
@@ -1,8 +1,7 @@
-import { runS3Server } from '../tests/setup-functions';
-import { uploadTestDirectory } from '../tests/s3rver/S3DataRefresh';
import path from 'path';
-//import { deleteTestData } from '../tests/e2e/hook';
-//deleteTestData() .then(() =>
+import { uploadTestDirectory } from '../tests/s3rver/S3DataRefresh';
+import { runS3Server } from '../tests/setup-functions';
+
runS3Server('testdata1')
.then((instance) =>
uploadTestDirectory(path.resolve(__dirname, '..', 'tests', 'testdata')),