🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

dokument

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dokument - npm Package Compare versions

Comparing version
0.1.11
to
0.2.0
+6
-0
CHANGELOG.md
# dokument
## 0.2.0
### Minor Changes
- 23eaf92: Choosing the template, tags, env, platform-specfic commands
## 0.1.11

@@ -4,0 +10,0 @@

+41
-40

@@ -1,17 +0,7 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import fs from "fs";
import * as logger from "@paperdave/logger";
import { __projectdir } from "../helper/path.js";
import * as yaml from "yaml";
import inquirer from "inquirer";
import { exec } from "../helper/exec.js";
import { runJob } from "../helper/jobs.js";
import { parseActionFile, runJob } from "../helper/jobs.js";
/**

@@ -21,32 +11,43 @@ * Initializing a new project with a template.

*/
export function init(name) {
return __awaiter(this, void 0, void 0, function* () {
if (fs.existsSync(name)) {
console.error(`There is already a folder with the name of ${name}`);
process.exit(1);
export async function init(name) {
if (fs.existsSync(name)) {
console.error(`There is already a folder with the name of ${name}`);
process.exit(1);
}
logger.info(`Initializing project "${name}"`);
const templates = fs.readdirSync(`${__projectdir}/templates`)
.filter(f => f.endsWith(".yaml"))
.map(p => `${__projectdir}/templates/${p}`)
.map(path => ({
content: parseActionFile(path),
path
}));
// Generating groups of tags
const groups = {};
templates.forEach(t => {
if (!groups[t.content.tag])
groups[t.content.tag] = [];
groups[t.content.tag].push(t.content);
});
// Questioning for the template to use
const answer = await inquirer.prompt([
{
type: "list",
choices: _ => Object.keys(groups)
.map(s => [
new inquirer.Separator(`--- ${s} ---`),
...groups[s].map(t => t.name)
])
.flat(),
name: "template",
message: _ => "Choose the template which we should use to generate your project",
}
logger.info(`Initializing project "${name}"`);
const templates = fs.readdirSync(`${__projectdir}/templates`)
.filter(f => f.endsWith(".yaml"))
.map(p => `${__projectdir}/templates/${p}`)
.map(path => ({
content: yaml.parse(fs.readFileSync(path).toString()),
path
}));
const answer = yield inquirer.prompt([
{
type: "list",
choices: _ => [...templates.map(f => f.content.name)],
name: "template",
message: _ => "Choose the template which we should use to generate your project",
}
]);
const file = templates.find(o => o.content.name === answer["template"]);
if (file === null || !file) {
console.error("Something went horribly wrong. Please open a discussion on Github.");
process.exit(1);
}
yield exec("mkdir " + name);
yield runJob(`${file.path}`, `./${name}`);
});
]);
const file = templates.find(o => o.content.name === answer["template"]);
if (file === null || !file) {
console.error("Something went horribly wrong. Please open a discussion on Github.");
process.exit(1);
}
await exec("mkdir " + name);
await runJob(`${file.path}`, `./${name}`);
}

@@ -7,3 +7,2 @@ import * as process from "process";

function getNodePackageManager() {
var _a;
const userAgent = process.env.npm_config_user_agent;

@@ -25,3 +24,3 @@ if (userAgent) {

}
const mainModulePath = (_a = process.mainModule) === null || _a === void 0 ? void 0 : _a.path;
const mainModulePath = process.mainModule?.path;
if (mainModulePath) {

@@ -28,0 +27,0 @@ if (/\/\.?pnpm\//.exec(mainModulePath))

@@ -1,10 +0,1 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { Spinner } from "@paperdave/logger";

@@ -34,2 +25,3 @@ import { __projectdir } from "./path.js";

&& obj.name !== undefined
&& obj.tag !== undefined
&& obj.required !== undefined

@@ -54,11 +46,18 @@ && Array.isArray(obj.required)

}
const ENV = Object.assign(Object.assign({}, process.env), { NODE_PACKAGE_MANAGER, NODE_INSTALL_PACKAGE: {
const ENV = {
...process.env,
NODE_PACKAGE_MANAGER,
NODE_INSTALL_PACKAGE: {
pnpm: "pnpm add",
yarn: "yarn add",
npm: "npm install",
}[NODE_PACKAGE_MANAGER], NODE_INSTALL_PACKAGE_DEV: {
}[NODE_PACKAGE_MANAGER],
NODE_INSTALL_PACKAGE_DEV: {
pnpm: "pnpm add -D",
yarn: "yarn add -D",
npm: "npm install --save-dev",
}[NODE_PACKAGE_MANAGER], NODE_SETUP_PACKAGE: `${NODE_PACKAGE_MANAGER} init -y`, PROJECT_DIR: __projectdir });
}[NODE_PACKAGE_MANAGER],
NODE_SETUP_PACKAGE: `${NODE_PACKAGE_MANAGER} init -y`,
PROJECT_DIR: __projectdir
};
/**

@@ -70,34 +69,32 @@ * This function will run a job.

*/
export function runJob(data, cwd = null) {
return __awaiter(this, void 0, void 0, function* () {
const job = parseActionFile(data);
// Checking if all required programs are available
for (const r of job.required) {
try {
yield exec(`which ${r}`, {
cwd: cwd || process.cwd(),
env: ENV
});
}
catch (_) {
console.log(`Required Program "${r}" is missing.`);
process.exit(1);
}
}
const spinner = new Spinner({
text: `Running job: "${job.name}"`,
});
for (const step of job.steps) {
spinner.update(`${step.name}: ${step.run}`);
const result = yield exec((step.run !== null ? step.run : (process.platform === "win32" ? step.win : step.unix)), {
export async function runJob(data, cwd = null) {
const job = parseActionFile(data);
// Checking if all required programs are available
for (const r of job.required) {
try {
await exec(`which ${r}`, {
cwd: cwd || process.cwd(),
env: ENV
});
if (result.stderr.length > 0) {
spinner.fail(`"${job.name}" (step: ${step.name}) failed.`);
process.exit(1);
}
}
spinner.success(`Job "${job.name}" finished.`);
catch (_) {
console.log(`Required Program "${r}" is missing.`);
process.exit(1);
}
}
const spinner = new Spinner({
text: `Running job: "${job.name}"`,
});
for (const step of job.steps) {
spinner.update(`${step.name}: ${step.run}`);
const result = await exec((step.run !== null ? step.run : (process.platform === "win32" ? step.win : step.unix)), {
cwd: cwd || process.cwd(),
env: ENV
});
if (result.stderr.length > 0) {
spinner.fail(`"${job.name}" (step: ${step.name}) failed.`);
process.exit(1);
}
}
spinner.success(`Job "${job.name}" finished.`);
}
#!/usr/bin/env node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as logger from "@paperdave/logger";
import * as cli from "./cli.js";
(function () {
return __awaiter(this, void 0, void 0, function* () {
if (!["darwin", "linux", "win32"].includes(process.platform)) {
console.error("Your operating-system is not supported. This may or may not change. Please open an issue.");
process.exit(1);
}
logger.injectLogger();
cli.initializeCLI();
});
(async function () {
if (!["darwin", "linux", "win32"].includes(process.platform)) {
console.error("Your operating-system is not supported. This may or may not change. Please open an issue.");
process.exit(1);
}
logger.injectLogger();
cli.initializeCLI();
})().then(() => {
/* */
});
{
"name": "dokument",
"main": "./src/index.ts",
"version": "0.1.11",
"version": "0.2.0",
"bin": {

@@ -6,0 +6,0 @@ "dokument": "dist/index.js"

name: Simple-Haxe
description: This setup is for a simple Haxe project. It includes a src dir, Compile.hxml and a Main.hx script.
tag: Haxe
required:

@@ -4,0 +5,0 @@ - haxe

name: Simple-TypeScript
description: This setup is for a simple TypeScript project. It includes Typescript, a Dockerfile, and a prettier config.
tag: NodeJS
required:

@@ -4,0 +5,0 @@ - $NODE_PACKAGE_MANAGER

{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path.ts to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "esnext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path.ts for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"target": "esnext",
"lib": ["esnext"],
"module": "esnext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"outDir": "dist",
"moduleResolution": "Node"
"moduleResolution": "node"
},

@@ -105,0 +13,0 @@ "exclude": [