Commit 0ff19e94 by Ryan McKinley Committed by GitHub

Toolkit: create manifest files for plugins (#22056)

parent 679acd30
...@@ -5,6 +5,7 @@ import chalk from 'chalk'; ...@@ -5,6 +5,7 @@ import chalk from 'chalk';
import { startTask } from './tasks/core.start'; import { startTask } from './tasks/core.start';
import { changelogTask } from './tasks/changelog'; import { changelogTask } from './tasks/changelog';
import { cherryPickTask } from './tasks/cherrypick'; import { cherryPickTask } from './tasks/cherrypick';
import { manifestTask } from './tasks/manifest';
import { precommitTask } from './tasks/precommit'; import { precommitTask } from './tasks/precommit';
import { templateTask } from './tasks/template'; import { templateTask } from './tasks/template';
import { pluginBuildTask } from './tasks/plugin.build'; import { pluginBuildTask } from './tasks/plugin.build';
...@@ -213,6 +214,14 @@ export const run = (includeInternalScripts = false) => { ...@@ -213,6 +214,14 @@ export const run = (includeInternalScripts = false) => {
}); });
}); });
// Test the manifest creation
program
.command('manifest')
.description('create a manifest file in the cwd')
.action(async cmd => {
await execTask(manifestTask)({ folder: process.cwd() });
});
program.on('command:*', () => { program.on('command:*', () => {
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' ')); console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
process.exit(1); process.exit(1);
......
import { getFilePaths } from './manifest';
describe('Manifest', () => {
it('should collect file paths', () => {
const info = getFilePaths(__dirname);
expect(info).toMatchInlineSnapshot(`
Array [
"changelog.ts",
"cherrypick.ts",
"closeMilestone.ts",
"core.start.ts",
"manifest.test.ts",
"manifest.ts",
"nodeVersionChecker.ts",
"package.build.ts",
"plugin/bundle.ts",
"plugin/create.ts",
"plugin/tests.ts",
"plugin.build.ts",
"plugin.ci.ts",
"plugin.create.ts",
"plugin.dev.ts",
"plugin.tests.ts",
"precommit.ts",
"searchTestDataSetup.ts",
"task.ts",
"template.ts",
"toolkit.build.ts",
]
`);
});
});
import { Task, TaskRunner } from './task';
import fs from 'fs';
import path from 'path';
import execa from 'execa';
interface ManifestOptions {
folder: string;
}
export function getFilePaths(root: string, work?: string, acc?: string[]): string[] {
if (!acc) {
acc = [];
}
let abs = work ?? root;
const files = fs.readdirSync(abs);
files.forEach(file => {
const f = path.join(abs, file);
const stat = fs.statSync(f);
if (stat.isDirectory()) {
acc = getFilePaths(root, f, acc);
} else {
acc!.push(f.substring(root.length + 1).replace('\\', '/'));
}
});
return acc;
}
const manifestRunner: TaskRunner<ManifestOptions> = async ({ folder }) => {
const filename = 'MANIFEST.txt';
const files = getFilePaths(folder).filter(f => f !== filename);
const originalDir = __dirname;
process.chdir(folder);
const out = await execa('sha1sum', files);
// Write the process output
fs.writeFileSync(path.join(folder, filename), out.stdout);
// TODO:
// gpg --output doc.sig --sign doc
// Go back to where you were
process.chdir(originalDir);
console.log('Wrote manifest: ', filename);
};
export const manifestTask = new Task<ManifestOptions>('Build Manifest', manifestRunner);
...@@ -23,6 +23,8 @@ import { agregateWorkflowInfo, agregateCoverageInfo, agregateTestInfo } from '.. ...@@ -23,6 +23,8 @@ import { agregateWorkflowInfo, agregateCoverageInfo, agregateTestInfo } from '..
import { PluginPackageDetails, PluginBuildReport, TestResultsInfo } from '../../plugins/types'; import { PluginPackageDetails, PluginBuildReport, TestResultsInfo } from '../../plugins/types';
import { runEndToEndTests } from '../../plugins/e2e/launcher'; import { runEndToEndTests } from '../../plugins/e2e/launcher';
import { getEndToEndSettings } from '../../plugins/index'; import { getEndToEndSettings } from '../../plugins/index';
import { manifestTask } from './manifest';
import { execTask } from '../utils/execTask';
export interface PluginCIOptions { export interface PluginCIOptions {
backend?: boolean; backend?: boolean;
...@@ -162,6 +164,9 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => { ...@@ -162,6 +164,9 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
} }
}); });
// Write a manifest.txt file in the dist folder
await execTask(manifestTask)({ folder: distContentDir });
console.log('Building ZIP'); console.log('Building ZIP');
let zipName = pluginInfo.id + '-' + pluginInfo.info.version + '.zip'; let zipName = pluginInfo.id + '-' + pluginInfo.info.version + '.zip';
let zipFile = path.resolve(packagesDir, zipName); let zipFile = path.resolve(packagesDir, zipName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment