New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

shenanigans-manager

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shenanigans-manager - npm Package Compare versions

Comparing version

to
0.2.27

setup/default/.github/ISSUE_TEMPLATE.md

2

package.json
{
"name": "shenanigans-manager",
"version": "0.2.26",
"version": "0.2.27",
"description": "Manages large-scale operations on FullScreenShenanigans project.",

@@ -5,0 +5,0 @@ "bin": {

{
"scripts": {
"setup:copy": "npm run test:setup:copy:maps",
"setup:copy": "npm run setup:copy:maps",
"setup:copy:maps": "run-for-every-file --src \"node_modules/shenanigans-manager/setup/maps/\" --file \"**/*\" --run \"mustache package.json {{src-file}} ./src/{{file}}\" --dest \".\""
}
}
{
"browser": "./src/index.js",
"devDependencies": {
"@types/chai": "^4.1.2",
"@types/chai": "^4.1.2",
"@types/lolex": "^2.1.2",
"@types/mocha": "^5.0.0",
"@types/sinon": "^4.3.0",
"@types/sinon": "^4.3.1",
"@types/sinon-chai": "^2.7.29",

@@ -12,2 +12,3 @@ "chai": "^4.1.2",

"glob": "^7.1.2",
"istanbul": "^0.4.5",
"lolex": "^2.3.2",

@@ -20,11 +21,11 @@ "mkdirp": "^0.5.1",

"shenanigans-manager": "^0.2.26",
"sinon": "^4.4.8",
"sinon": "^4.5.0",
"sinon-chai": "^3.0.0",
"tslint": "5.9.1",
"tsutils": "^2.22.2",
"tsutils": "^2.26.1",
"typedoc": "^0.11.1",
"typescript": "^2.7.2",
"typescript": "^2.8.1",
"watch": "^1.0.2",
"webpack": "^4.2.0",
"webpack-cli": "^2.0.13"
"webpack": "^4.5.0",
"webpack-cli": "^2.0.14"
},

@@ -46,2 +47,7 @@ "scripts": {

"test": "npm run test:setup && npm run test:run",
"test:coverage": "npm run test:coverage:generate-html && npm run test:coverage:instrument && npm run test:coverage:run && npm run test:coverage:report",
"test:coverage:generate-html": "shenanigans-manager generate-test-html --source instrumented",
"test:coverage:instrument": "istanbul instrument src -o instrumented",
"test:coverage:report": "istanbul report html",
"test:coverage:run": "mocha-headless-chrome --coverage coverage/coverage.json --file test/index.instrumented.html",
"test:run": "mocha-headless-chrome --file test/index.html",

@@ -55,2 +61,3 @@ "test:setup": "npm run test:setup:dir && npm run test:setup:copy && npm run test:setup:html && npm run test:setup:tsc",

"verify": "npm run src && npm run test && npm run dist && npm run docs",
"verify:coverage": "npm run src && npm run test:coverage && npm run dist && npm run docs",
"watch": "concurrently \"tsc -p . -w\" --raw \"chokidar src/**/*.test.t* --command \"\"npm run test:setup:html\"\" --silent\" --raw"

@@ -57,0 +64,0 @@ },

@@ -26,3 +26,3 @@ ## Development

### Running Tests
#### Running Tests

@@ -33,5 +33,8 @@ ```shell

Test files are alongside source files under `src/` and named `*.test.ts?`.
Tests are written in [Mocha](https://github.com/mochajs/mocha) and [Chai](https://github.com/chaijs/chai).
Their files are written using alongside source files under `src/` and named `*.test.ts?`.
Whenever you add, remove, or rename a `*.test.t*` file under `src/`, `watch` will re-run `npm run test:setup` to regenerate the list of static test files in `test/index.html`.
You can open that file in a browser to debug through the tests.
`npm run test:run` will run that setup and execute tests using [Puppeteer](https://github.com/GoogleChrome/puppeteer).
<!-- Maps -->
<!-- /Maps -->
import { IRepositoryCommandArgs } from "../command";
import { IRuntime } from "../runtime";
/**
* Arguments for a GenerateTestHtml command.
*/
export interface IGenerateTestHtmlArgs extends IRepositoryCommandArgs {
/**
* Directory to load source files from, if not src.
*/
source?: string;
}
/**
* Generates the HTML page for a repository's tests.
*/
export declare const GenerateTestHtml: (runtime: IRuntime, args: IRepositoryCommandArgs) => Promise<void>;
export declare const GenerateTestHtml: (runtime: IRuntime, args: IGenerateTestHtmlArgs) => Promise<void>;

@@ -26,6 +26,9 @@ "use strict";

const testTemplate = (yield fs.readFile(path.resolve(__dirname, "../../setup/test.html"))).toString();
const testPaths = (yield utils_1.globAsync(path.resolve(args.directory, args.repository, "src/**/*.test.ts*")))
let testPaths = (yield utils_1.globAsync(path.resolve(args.directory, args.repository, "src/**/*.test.ts*")))
.map((testPath) => testPath.replace(/\.test\.(tsx|ts)/gi, ".test.js"))
.map((testPath) => path.join("..", path.relative(path.join(args.directory, args.repository), testPath))
.replace(/\\/g, "/"));
if (args.source !== undefined) {
testPaths = testPaths.map((testPath) => testPath.replace("/src/", `/${args.source}/`));
}
const { dependencyNames, externals } = yield utils_1.getDependencyNamesAndExternalsOfPackage(basePackageLocation);

@@ -35,3 +38,6 @@ const newTestContents = mustache.render(testTemplate, Object.assign({}, basePackageContents, { dependencyNames,

testPaths }));
yield fs.writeFile(path.join(args.directory, args.repository, "test/index.html"), newTestContents);
const testFileName = args.source === undefined
? "test/index.html"
: `test/index.${args.source}.html`;
yield fs.writeFile(path.join(args.directory, args.repository, testFileName), newTestContents);
});

@@ -11,5 +11,15 @@ import * as mustache from "mustache";

/**
* Arguments for a GenerateTestHtml command.
*/
export interface IGenerateTestHtmlArgs extends IRepositoryCommandArgs {
/**
* Directory to load source files from, if not src.
*/
source?: string;
}
/**
* Generates the HTML page for a repository's tests.
*/
export const GenerateTestHtml = async (runtime: IRuntime, args: IRepositoryCommandArgs) => {
export const GenerateTestHtml = async (runtime: IRuntime, args: IGenerateTestHtmlArgs) => {
defaultPathArgs(args, "directory", "repository");

@@ -23,3 +33,3 @@

const testTemplate = (await fs.readFile(path.resolve(__dirname, "../../setup/test.html"))).toString();
const testPaths = (await globAsync(path.resolve(args.directory, args.repository, "src/**/*.test.ts*")))
let testPaths = (await globAsync(path.resolve(args.directory, args.repository, "src/**/*.test.ts*")))
.map((testPath) => testPath.replace(/\.test\.(tsx|ts)/gi, ".test.js"))

@@ -29,2 +39,6 @@ .map((testPath) => path.join("..", path.relative(path.join(args.directory, args.repository), testPath))

if (args.source !== undefined) {
testPaths = testPaths.map((testPath: string): string => testPath.replace("/src/", `/${args.source}/`));
}
const { dependencyNames, externals } = await getDependencyNamesAndExternalsOfPackage(basePackageLocation);

@@ -41,5 +55,9 @@

const testFileName = args.source === undefined
? "test/index.html"
: `test/index.${args.source}.html`;
await fs.writeFile(
path.join(args.directory, args.repository, "test/index.html"),
path.join(args.directory, args.repository, testFileName),
newTestContents);
};
import { IRepositoryCommandArgs } from "../command";
import { IRuntime } from "../runtime";
export declare const replaceBetween: (readmeContents: string, sectionFile: string, settings: {}) => Promise<string>;
export declare const replaceBetween: (readmeContents: string, section: string, settings: {}) => Promise<string>;
/**

@@ -5,0 +5,0 @@ * Updates a repository's README.md.

@@ -18,15 +18,25 @@ "use strict";

const templateDir = "./node_modules/shenanigans-manager/setup/readme/";
exports.replaceBetween = (readmeContents, sectionFile, settings) => __awaiter(this, void 0, void 0, function* () {
const section = sectionFile.replace(".md", "");
const starter = `<!-- {{${section}}} -->`;
const ender = `<!-- {{/${section}}} -->`;
const getReadmeSections = (packageContents) => {
const sections = ["Top", "Development"];
if (packageContents.shenanigans.maps) {
sections.push("Maps");
}
return sections;
};
exports.replaceBetween = (readmeContents, section, settings) => __awaiter(this, void 0, void 0, function* () {
const starter = `<!-- ${section} -->`;
const ender = `<!-- /${section} -->`;
const start = readmeContents.indexOf(starter) + starter.length;
const end = readmeContents.indexOf(ender);
const templateLocation = path.join(templateDir, sectionFile);
const templateLocation = path.join(templateDir, `${section}.md`);
const template = (yield fs.readFile(templateLocation)).toString().trim();
let rendered = mustache.render(template, settings).trim();
if (rendered.length !== 0) {
rendered = `${os.EOL}${rendered}${os.EOL}`;
}
return [
readmeContents.substring(0, start),
mustache.render(template, settings),
readmeContents.substring(end),
].join(os.EOL);
readmeContents.substring(0, start).trim(),
rendered,
readmeContents.substring(end).trim(),
].join("").trim() + os.EOL;
});

@@ -43,4 +53,3 @@ /**

}
const [sections, packageContentsBase, readmeContentsBase] = yield Promise.all([
fs.readdir(templateDir),
const [packageContentsBase, readmeContentsBase] = yield Promise.all([
fs.readFile("package.json"),

@@ -50,2 +59,3 @@ fs.readFile(readmeLocation),

const packageContents = JSON.parse(packageContentsBase.toString());
const sections = getReadmeSections(packageContents);
let readmeContents = readmeContentsBase.toString();

@@ -52,0 +62,0 @@ for (const section of sections) {

@@ -12,18 +12,32 @@ import chalk from "chalk";

export const replaceBetween = async (readmeContents: string, sectionFile: string, settings: {}): Promise<string> => {
const section = sectionFile.replace(".md", "");
const starter = `<!-- {{${section}}} -->`;
const ender = `<!-- {{/${section}}} -->`;
const getReadmeSections = (packageContents: IShenanigansPackage): string[] => {
const sections = ["Top", "Development"];
if (packageContents.shenanigans.maps) {
sections.push("Maps");
}
return sections;
};
export const replaceBetween = async (readmeContents: string, section: string, settings: {}): Promise<string> => {
const starter = `<!-- ${section} -->`;
const ender = `<!-- /${section} -->`;
const start = readmeContents.indexOf(starter) + starter.length;
const end = readmeContents.indexOf(ender);
const templateLocation = path.join(templateDir, sectionFile);
const templateLocation = path.join(templateDir, `${section}.md`);
const template = (await fs.readFile(templateLocation)).toString().trim();
let rendered = mustache.render(template, settings).trim();
if (rendered.length !== 0) {
rendered = `${os.EOL}${rendered}${os.EOL}`;
}
return [
readmeContents.substring(0, start),
mustache.render(template, settings),
readmeContents.substring(end),
].join(os.EOL);
readmeContents.substring(0, start).trim(),
rendered,
readmeContents.substring(end).trim(),
].join("").trim() + os.EOL;
};

@@ -44,8 +58,8 @@

const [sections, packageContentsBase, readmeContentsBase] = await Promise.all([
fs.readdir(templateDir),
const [packageContentsBase, readmeContentsBase] = await Promise.all([
fs.readFile("package.json"),
fs.readFile(readmeLocation),
]);
const packageContents = JSON.parse(packageContentsBase.toString());
const packageContents: IShenanigansPackage = JSON.parse(packageContentsBase.toString());
const sections = getReadmeSections(packageContents);
let readmeContents = readmeContentsBase.toString();

@@ -52,0 +66,0 @@

Sorry, the diff of this file is not supported yet