Remove Grunt in favor of ts/scripts
This commit is contained in:
parent
4e947211b2
commit
e74376b997
92 changed files with 1137 additions and 1661 deletions
16
ts/scripts/.eslintrc.js
Normal file
16
ts/scripts/.eslintrc.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
module.exports = {
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
|
||||
// We still get the value of this rule, it just allows for dev deps
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
devDependencies: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
54
ts/scripts/copy-and-concat.ts
Normal file
54
ts/scripts/copy-and-concat.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { basename, join } from 'path';
|
||||
import { copyFileSync, readFileSync, writeFileSync } from 'fs';
|
||||
|
||||
// Concat
|
||||
|
||||
console.log('Concatenating...');
|
||||
|
||||
const BASE_BOWER = join(__dirname, '../../components');
|
||||
const BASE_NODE = join(__dirname, '../../node_modules');
|
||||
const CONCAT_TARGET = join(__dirname, '../../js/components.js');
|
||||
const CONCAT_SOURCES = [
|
||||
join(BASE_NODE, 'jquery/dist/jquery.js'),
|
||||
join(BASE_NODE, 'mustache/mustache.js'),
|
||||
join(BASE_NODE, 'underscore/underscore.js'),
|
||||
join(BASE_BOWER, 'qrcode/qrcode.js'),
|
||||
join(BASE_BOWER, 'webaudiorecorder/lib/WebAudioRecorder.js'),
|
||||
];
|
||||
|
||||
let concat = '// concatenated components.js';
|
||||
CONCAT_SOURCES.forEach(source => {
|
||||
const contents = readFileSync(source, 'utf8');
|
||||
const name = basename(source);
|
||||
|
||||
console.log(`Concatenating ${source}`);
|
||||
concat += `\n\n// ${name}\n${contents}`;
|
||||
});
|
||||
|
||||
console.log(`Writing to ${CONCAT_TARGET}`);
|
||||
writeFileSync(CONCAT_TARGET, concat);
|
||||
|
||||
// Copy
|
||||
|
||||
console.log();
|
||||
console.log('Copying...');
|
||||
|
||||
const BASE_JS = join(__dirname, '../../js');
|
||||
const COPY_SOURCES = [
|
||||
{
|
||||
src: join(BASE_BOWER, 'mp3lameencoder/lib/Mp3LameEncoder.js'),
|
||||
dest: join(BASE_JS, 'Mp3LameEncoder.min.js'),
|
||||
},
|
||||
{
|
||||
src: join(BASE_BOWER, 'webaudiorecorder/lib/WebAudioRecorderMp3.js'),
|
||||
dest: join(BASE_JS, 'WebAudioRecorderMp3.js'),
|
||||
},
|
||||
];
|
||||
|
||||
for (const { src, dest } of COPY_SOURCES) {
|
||||
console.log(`Copying ${src} to ${dest}`);
|
||||
copyFileSync(src, dest);
|
||||
}
|
26
ts/scripts/get-expire-time.ts
Normal file
26
ts/scripts/get-expire-time.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { join } from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import { writeFileSync } from 'fs';
|
||||
|
||||
import { DAY } from '../util/durations';
|
||||
|
||||
const unixTimestamp = parseInt(
|
||||
execSync('git show -s --format=%ct').toString('utf8'),
|
||||
10
|
||||
);
|
||||
const buildCreation = unixTimestamp * 1000;
|
||||
|
||||
const buildExpiration = buildCreation + DAY * 90;
|
||||
|
||||
const localProductionPath = join(
|
||||
__dirname,
|
||||
'../../config/local-production.json'
|
||||
);
|
||||
const localProductionConfig = { buildCreation, buildExpiration };
|
||||
writeFileSync(
|
||||
localProductionPath,
|
||||
`${JSON.stringify(localProductionConfig)}\n`
|
||||
);
|
53
ts/scripts/get-strings.ts
Normal file
53
ts/scripts/get-strings.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { join, resolve } from 'path';
|
||||
import { existsSync, readdirSync, writeFileSync } from 'fs';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
import { readJsonSync } from 'fs-extra';
|
||||
import type { LocaleMessagesType } from '../types/I18N';
|
||||
|
||||
console.log('Getting latest strings!');
|
||||
|
||||
console.log();
|
||||
console.log('Getting strings, allow for new ones over 80% translated');
|
||||
execSync('tx pull --all --use-git-timestamps --minimum-perc=80', {
|
||||
stdio: [null, process.stdout, process.stderr],
|
||||
});
|
||||
|
||||
console.log();
|
||||
console.log('Getting strings, updating everything previously missed');
|
||||
execSync('tx pull --use-git-timestamps', {
|
||||
stdio: [null, process.stdout, process.stderr],
|
||||
});
|
||||
|
||||
const BASE_DIR = join(__dirname, '../../_locales');
|
||||
const en: LocaleMessagesType = readJsonSync(
|
||||
join(BASE_DIR, '/en/messages.json')
|
||||
);
|
||||
const locales = readdirSync(join(BASE_DIR, ''));
|
||||
|
||||
console.log();
|
||||
console.log('Re-adding placeholders to non-en locales');
|
||||
locales.forEach((locale: string) => {
|
||||
if (locale === 'en') {
|
||||
return;
|
||||
}
|
||||
const target = resolve(join(BASE_DIR, locale, 'messages.json'));
|
||||
if (!existsSync(target)) {
|
||||
throw new Error(`File not found for ${locale}: ${target}`);
|
||||
}
|
||||
|
||||
const messages: LocaleMessagesType = readJsonSync(target);
|
||||
Object.keys(messages).forEach(key => {
|
||||
if (!en[key]) {
|
||||
return;
|
||||
}
|
||||
|
||||
messages[key].placeholders = en[key].placeholders;
|
||||
});
|
||||
|
||||
console.log(`Writing ${target}`);
|
||||
writeFileSync(target, `${JSON.stringify(messages, null, 4)}\n`);
|
||||
});
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
|
|
|
@ -7,6 +7,12 @@ export type LocaleMessagesType = {
|
|||
[key: string]: {
|
||||
message: string;
|
||||
description?: string;
|
||||
placeholders?: {
|
||||
[name: string]: {
|
||||
content: string;
|
||||
example: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
[
|
||||
{
|
||||
"rule": "jQuery-after(",
|
||||
"path": "components/indexeddb-backbonejs-adapter/backbone-indexeddb.js",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-13T21:24:40.667Z",
|
||||
"line": " migration.after(function () {"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-before(",
|
||||
"path": "components/indexeddb-backbonejs-adapter/backbone-indexeddb.js",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-13T21:24:40.667Z",
|
||||
"line": " migration.before(function () {"
|
||||
},
|
||||
{
|
||||
"rule": "eval",
|
||||
"path": "components/mp3lameencoder/lib/Mp3LameEncoder.js",
|
||||
|
@ -599,6 +585,101 @@
|
|||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-19T18:13:29.628Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertAfter(",
|
||||
"path": "node_modules/async/dist/async.js",
|
||||
"line": " if (this.tail) this.insertAfter(this.tail, node);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertBefore(",
|
||||
"path": "node_modules/async/dist/async.js",
|
||||
"line": " if (this.head) this.insertBefore(this.head, node);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertBefore(",
|
||||
"path": "node_modules/async/dist/async.js",
|
||||
"line": " q._tasks.insertBefore(nextNode, item);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/async/dist/async.js",
|
||||
"line": "function wrap(defer) {",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/async/dist/async.js",
|
||||
"line": "var setImmediate$1 = wrap(_defer);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/async/dist/async.js",
|
||||
"line": "var nextTick = wrap(_defer$1);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-$(",
|
||||
"path": "node_modules/async/dist/async.min.js",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertAfter(",
|
||||
"path": "node_modules/async/dist/async.min.js",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertBefore(",
|
||||
"path": "node_modules/async/dist/async.min.js",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertAfter(",
|
||||
"path": "node_modules/async/internal/DoublyLinkedList.js",
|
||||
"line": " if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertBefore(",
|
||||
"path": "node_modules/async/internal/DoublyLinkedList.js",
|
||||
"line": " if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/async/internal/setImmediate.js",
|
||||
"line": "function wrap(defer) {",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/async/internal/setImmediate.js",
|
||||
"line": "exports.default = wrap(_defer);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-insertBefore(",
|
||||
"path": "node_modules/async/priorityQueue.js",
|
||||
"line": " q._tasks.insertBefore(nextNode, item);",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-12-11T02:14:15.457Z"
|
||||
},
|
||||
{
|
||||
"rule": "DOM-innerHTML",
|
||||
"path": "node_modules/axe-core/axe.js",
|
||||
|
@ -6618,26 +6699,6 @@
|
|||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-19T21:59:32.770Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/underscore.string/dist/underscore.string.js",
|
||||
"line": "module.exports = function wrap(str, options){",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-19T18:13:29.628Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/underscore.string/dist/underscore.string.min.js",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-05-06T21:37:22.288Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-wrap(",
|
||||
"path": "node_modules/underscore.string/wrap.js",
|
||||
"line": "module.exports = function wrap(str, options){",
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-09-19T18:13:29.628Z"
|
||||
},
|
||||
{
|
||||
"rule": "jQuery-after(",
|
||||
"path": "node_modules/underscore/amd/after.js",
|
||||
|
|
|
@ -38,7 +38,6 @@ const FILES_TO_IGNORE = new Set(
|
|||
[
|
||||
'.github/ISSUE_TEMPLATE/bug_report.md',
|
||||
'.github/PULL_REQUEST_TEMPLATE.md',
|
||||
'components/indexeddb-backbonejs-adapter/backbone-indexeddb.js',
|
||||
'components/mp3lameencoder/lib/Mp3LameEncoder.js',
|
||||
'components/qrcode/qrcode.js',
|
||||
'components/recorderjs/recorder.js',
|
||||
|
|
|
@ -170,14 +170,6 @@ const excludedFilesRegexp = RegExp(
|
|||
'^node_modules/gauge/.+',
|
||||
'^node_modules/global-agent/.+',
|
||||
'^node_modules/globule/.+',
|
||||
'^node_modules/grunt-cli/.+',
|
||||
'^node_modules/grunt-contrib-concat/.+',
|
||||
'^node_modules/grunt-contrib-watch/.+',
|
||||
'^node_modules/grunt-gitinfo/.+',
|
||||
'^node_modules/grunt-legacy-log-utils/.+',
|
||||
'^node_modules/grunt-legacy-log/.+',
|
||||
'^node_modules/grunt-legacy-util/.+',
|
||||
'^node_modules/grunt/.+',
|
||||
'^node_modules/handle-thing/.+',
|
||||
'^node_modules/handlebars/.+', // Used by nyc#istanbul-reports
|
||||
'^node_modules/har-validator/.+',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue