Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/server/declarations/tmp.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions app/server/lib/ActiveDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ import * as moment from 'moment-timezone';
import fetch from 'node-fetch';
import stream from 'node:stream';
import path from 'path';
import tmp from 'tmp';

import {ActionHistory} from './ActionHistory';
import {ActionHistoryImpl} from './ActionHistoryImpl';
Expand All @@ -172,8 +171,6 @@ import sum = require('lodash/sum');
import throttle = require('lodash/throttle');
import without = require('lodash/without');

bluebird.promisifyAll(tmp);

const MAX_RECENT_ACTIONS = 100;

const DEFAULT_TIMEZONE = (process.versions as any).electron ? moment.tz.guess() : "UTC";
Expand Down
8 changes: 2 additions & 6 deletions app/server/lib/DocPluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ import { GristServer } from 'app/server/lib/GristServer';
import log from 'app/server/lib/log';
import { SafePythonComponent } from 'app/server/lib/SafePythonComponent';
import { UnsafeNodeComponent } from 'app/server/lib/UnsafeNodeComponent';
import { promisifyAll } from 'bluebird';
import * as fse from 'fs-extra';
import * as path from 'path';
import tmp from 'tmp';


promisifyAll(tmp);
import * as tmp from 'tmp-promise';

/**
* Implements GristDocAPI interface.
Expand Down Expand Up @@ -196,7 +192,7 @@ export class DocPluginManager {
}

private async _initialize(): Promise<void> {
this._tmpDir = await tmp.dirAsync({ prefix: 'grist-tmp-', unsafeCleanup: true });
this._tmpDir = (await tmp.dir({ prefix: 'grist-tmp-', unsafeCleanup: true })).path;
for (const plugin of this._localPlugins) {
try {
// todo: once Comm has been replaced by grain-rpc, pluginInstance.rpc should forward '*' to client
Expand Down
2 changes: 1 addition & 1 deletion app/server/lib/Requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class DocRequests {
// and only as long as needed to finish calculating all formulas.
// When _numPending reaches 0 again, _cacheDir is deleted.
private _numPending: number = 0;
private _cacheDir: tmp.SynchrounousResult | null = null;
private _cacheDir: tmp.DirResult | null = null;

constructor(private readonly _activeDoc: ActiveDoc) {}

Expand Down
2 changes: 1 addition & 1 deletion app/server/lib/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ interface TmpDirResult {
* Helper to create a temporary directory. It's a simple wrapper around tmp.dir, but replaces the
* cleanup callback with an asynchronous version.
*/
export async function createTmpDir(options: tmp.Options): Promise<TmpDirResult> {
export async function createTmpDir(options: tmp.DirOptions): Promise<TmpDirResult> {
const fullOptions = {prefix: 'grist-upload-', unsafeCleanup: true, ...options};

const [tmpDir, tmpCleanup]: [string, CleanupCB] = await fromCallback(
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@types/sinon": "17.0.3",
"@types/sqlite3": "3.1.6",
"@types/swagger-ui": "3.52.4",
"@types/tmp": "0.0.33",
"@types/tmp": "0.2.6",
"@types/uuid": "10.0.0",
"@types/webpack-dev-server": "4.7.2",
"@types/which": "2.0.1",
Expand Down Expand Up @@ -213,7 +213,7 @@
"slugify": "1.6.6",
"swagger-ui-dist": "5.11.0",
"tar-stream": "^3.1.7",
"tmp": "0.0.33",
"tmp": "0.2.5",
"tmp-promise": "1.0.5",
"ts-interface-checker": "1.0.2",
"typeorm": "0.3.17",
Expand Down
7 changes: 0 additions & 7 deletions stubs/app/server/tmp.d.ts

This file was deleted.

6 changes: 3 additions & 3 deletions test/server/docTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {assert} from 'chai';
import * as fse from 'fs-extra';
import {tmpdir} from 'os';
import * as path from 'path';
import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';

tmp.setGracefulCleanup();

Expand Down Expand Up @@ -168,12 +168,12 @@ export async function createDocManager(
export async function createTmpDir(): Promise<string> {
const tmpRootDir = process.env.TESTDIR || tmpdir();
await fse.mkdirs(tmpRootDir);
return fse.realpath(await tmp.dirAsync({
return (await tmp.dir({
dir: tmpRootDir,
prefix: 'grist_test_',
unsafeCleanup: true,
keep: noCleanup,
}));
})).path;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions test/server/lib/DocStorage.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const assert = require('chai').assert;
const child_process = require('child_process');
const fs = require('fs');
const tmp = require('tmp');

const Promise = require('bluebird');
Promise.promisifyAll(child_process);
Promise.promisifyAll(fs);
Promise.promisifyAll(tmp);

const {ActionHistoryImpl} = require('app/server/lib/ActionHistoryImpl');
const {DocStorage} = require('app/server/lib/DocStorage');
Expand All @@ -15,8 +13,6 @@ const marshal = require('app/common/marshal');
const {createDocTools} = require('test/server/docTools');
const testUtils = require('test/server/testUtils');

tmp.setGracefulCleanup();

describe('DocStorage', function() {

var docStorageManager;
Expand Down
14 changes: 6 additions & 8 deletions test/server/lib/DocStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {assert} from 'chai';
import * as fse from 'fs-extra';
import * as path from 'path';
import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';

import {DocStorageManager} from 'app/server/lib/DocStorageManager';
import * as docUtils from 'app/server/lib/docUtils';
Expand All @@ -16,12 +16,10 @@ describe('DocStorageManager', function() {
// Set Grist home to a temporary directory, and wipe it out on exit.
let docsRoot: string;
let docStorageManager: DocStorageManager;
before(function() {
return tmp.dirAsync({ prefix: 'grist_test_', unsafeCleanup: true })
.then(tmpDir => {
docsRoot = fse.realpathSync(tmpDir);
docStorageManager = new DocStorageManager(docsRoot);
});
before(async function() {
const tmpDir = (await tmp.dir({ prefix: 'grist_test_', unsafeCleanup: true })).path;
docsRoot = fse.realpathSync(tmpDir);
docStorageManager = new DocStorageManager(docsRoot);
});

describe('getPath', function() {
Expand Down Expand Up @@ -81,7 +79,7 @@ describe('DocStorageManager', function() {
// First create a doc, one under docsRoot, one outside; and include an attachment.
fse.writeFileSync(doc1, "this is a test");
const doc2 = tmp.fileSync({
prefix: 'DeleteTest2', postfix: '.grist', unsafeCleanup: true,
prefix: 'DeleteTest2', postfix: '.grist',
discardDescriptor: true
}).name;
// Check that items got created as we expect.
Expand Down
4 changes: 2 additions & 2 deletions test/server/lib/DocStorageMigrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as fse from 'fs-extra';
import * as path from 'path';
import * as testUtils from 'test/server/testUtils';
import {assert} from 'test/server/testUtils';
import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';

tmp.setGracefulCleanup();
const execFileAsync = promisify(child_process.execFile);
Expand All @@ -20,7 +20,7 @@ describe('DocStorageMigrations', function() {

before(async function() {
// Set Grist home to a temporary directory, and wipe it out on exit.
let tmpDir = await tmp.dirAsync({ prefix: 'grist_test_', unsafeCleanup: true });
let tmpDir = (await tmp.dir({ prefix: 'grist_test_', unsafeCleanup: true })).path;
tmpDir = await fse.realpath(tmpDir);
docStorageManager = new DocStorageManager(tmpDir);
});
Expand Down
9 changes: 5 additions & 4 deletions test/server/lib/SQLiteDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {assert} from 'chai';
import * as fse from 'fs-extra';
import {map, noop} from 'lodash';
import {join as pathJoin} from 'path';
import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';

import {delay} from 'app/common/delay';
import {OpenMode, SchemaInfo, SQLiteDB} from 'app/server/lib/SQLiteDB';
Expand All @@ -13,17 +13,18 @@ tmp.setGracefulCleanup();

describe('SQLiteDB', function() {
let tmpDir: string;
let cleanup: () => void;

// Turn off logging for this test, and restore afterwards.
testUtils.setTmpLogLevel('warn');

before(async function() {
// Create a temporary directory, and wipe it out on exit.
tmpDir = await tmp.dirAsync({ prefix: 'grist_test_SQLiteDB_', unsafeCleanup: true });
({path: tmpDir, cleanup} = await tmp.dir({ prefix: 'grist_test_SQLiteDB_', unsafeCleanup: true }));
});

after(async function() {
await fse.remove(tmpDir);
after(function() {
cleanup();
});

// Convenience helpers to make tests more concise and readable.
Expand Down
4 changes: 2 additions & 2 deletions test/server/lib/TestingHooks.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {connectTestingHooks, startTestingHooks, TestingHooksClient} from 'app/server/lib/TestingHooks';
import {assert, setTmpLogLevel} from 'test/server/testUtils';

import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';
tmp.setGracefulCleanup();

describe('TestingHooks', function() {
setTmpLogLevel('warn');

it('should start server and accept basic calls', async function() {
const tmpName: string = await tmp.tmpNameAsync({prefix: 'gristtest-'});
const tmpName: string = await tmp.tmpName({prefix: 'gristtest-'});
const server = await startTestingHooks(tmpName, 192348, null as any, null as any, []);
const stub: TestingHooksClient = await connectTestingHooks(tmpName);
try {
Expand Down
2 changes: 1 addition & 1 deletion test/server/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as path from 'path';
import * as fse from 'fs-extra';
import clone = require('lodash/clone');
import * as tmp from 'tmp-promise';
import {Options as TmpOptions} from 'tmp';
import {FileOptions as TmpOptions} from 'tmp';
import * as winston from 'winston';
import { serialize } from 'winston/lib/winston/common';

Expand Down
4 changes: 2 additions & 2 deletions test/upgradeDocumentImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import log from 'app/server/lib/log';
import * as fs from "fs";
import * as fse from "fs-extra";
import * as path from "path";
import * as tmp from "tmp";
import * as tmp from "tmp-promise";

export async function upgradeDocuments(docPaths: string[]): Promise<void> {
const docTools = createDocTools();
Expand All @@ -31,7 +31,7 @@ export async function upgradeDocuments(docPaths: string[]): Promise<void> {
}

export async function upgradeDocumentsDocStorageOnly(paths: string[]): Promise<void> {
let tmpDir = await tmp.dirAsync({ prefix: 'grist_migrate_', unsafeCleanup: true });
let tmpDir = (await tmp.dir({ prefix: 'grist_migrate_', unsafeCleanup: true })).path;
tmpDir = await fse.realpath(tmpDir);
const docStorageManager = new DocStorageManager(tmpDir);

Expand Down
36 changes: 17 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1484,10 +1484,10 @@
dependencies:
"@types/node" "*"

"@types/tmp@0.0.33":
version "0.0.33"
resolved "https://registry.npmjs.org/@types/tmp/-/tmp-0.0.33.tgz"
integrity sha1-EHPEvIJHVK49EM+riKsCN7qWTk0=
"@types/tmp@0.2.6":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.2.6.tgz#d785ee90c52d7cc020e249c948c36f7b32d1e217"
integrity sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==

"@types/tough-cookie@*":
version "4.0.2"
Expand Down Expand Up @@ -7059,8 +7059,8 @@ os-browserify@~0.3.0:

os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz"
integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==

otplib@12.0.1:
version "12.0.1"
Expand Down Expand Up @@ -7950,7 +7950,7 @@ rimraf@2:
dependencies:
glob "^7.1.3"

rimraf@^3.0.0, rimraf@^3.0.2:
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
Expand Down Expand Up @@ -8911,30 +8911,28 @@ tldts@^6.1.32:

tmp-promise@1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/tmp-promise/-/tmp-promise-1.0.5.tgz"
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-1.0.5.tgz#3208d7fa44758f86a2a4c4060f3c33fea30e8038"
integrity sha512-hOabTz9Tp49wCozFwuJe5ISrOqkECm6kzw66XTP23DuzNU7QS/KiZq5LC9Y7QSy8f1rPSLy4bKaViP0OwGI1cA==
dependencies:
bluebird "^3.5.0"
tmp "0.0.33"

tmp@0.0.33:
version "0.0.33"
resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
dependencies:
os-tmpdir "~1.0.2"

tmp@^0.2.0:
version "0.2.1"
resolved "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz"
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==
dependencies:
rimraf "^3.0.0"
tmp@0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8"
integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==

tmp@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.3.tgz#eb783cc22bc1e8bebd0671476d46ea4eb32a79ae"
integrity sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==
tmp@^0.2.0, tmp@^0.2.3:
version "0.2.4"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.4.tgz#c6db987a2ccc97f812f17137b36af2b6521b0d13"
integrity sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==

to-arraybuffer@^1.0.0:
version "1.0.1"
Expand Down
Loading