@manuth/generator-wsc-package
Version:
A Generator for WoltLab Suite Core Packages.
97 lines • 3.9 kB
JavaScript
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 { ScriptMapping, TSProjectPackageFileMapping, TSProjectSettingKey } from "@manuth/generator-ts-project";
import { WoltLabSettingKey } from "../../../Settings/WoltLabSettingKey.js";
import { WoltLabDependencyCollection } from "./WoltLabDependencyCollection.js";
/**
* Provides the functionality to create a `package.json`-file for woltlab-components.
*
* @template TSettings
* The type of the generator-settings.
*
* @template TOptions
* The type of the generator-options.
*/
export class WoltLabNodePackageFileMapping extends TSProjectPackageFileMapping {
/**
* Initializes a new instance of the {@link WoltLabNodePackageFileMapping `WoltLabNodePackageFileMapping<TSettings, TOptions>`} class.
*
* @param generator
* The generator of the file-mapping.
*/
constructor(generator) {
super(generator);
}
/**
* @inheritdoc
*
* @returns
* The loaded package.
*/
LoadPackage() {
const _super = Object.create(null, {
LoadPackage: { get: () => super.LoadPackage }
});
var _a, _b;
var _c, _d;
return __awaiter(this, void 0, void 0, function* () {
let result = yield _super.LoadPackage.call(this);
result.Main = undefined;
result.Types = undefined;
(_a = (_c = result.Author).Name) !== null && _a !== void 0 ? _a : (_c.Name = this.Generator.Settings[WoltLabSettingKey.Author]);
(_b = (_d = result.Author).URL) !== null && _b !== void 0 ? _b : (_d.URL = this.Generator.Settings[WoltLabSettingKey.HomePage]);
result.PublishConfig = {};
result.Files = [];
result.Register(new WoltLabDependencyCollection(this.Generator.Settings[TSProjectSettingKey.ESModule]), true);
result.DevelopmentDependencies.Remove("mocha");
result.DevelopmentDependencies.Remove("@types/mocha");
result.DevelopmentDependencies.Remove("source-map-support");
return result;
});
}
/**
* @inheritdoc
*/
get TypeScriptScripts() {
return super.TypeScriptScripts.filter((script) => {
return ![
"rebuild",
"build",
"watch",
"clean"
].includes(new ScriptMapping(this.Generator, this.ScriptSource, script).Destination);
});
}
/**
* @inheritdoc
*/
get MiscScripts() {
let baseScripts = super.MiscScripts.filter((script) => {
return ![
"prepare",
"test"
].includes(new ScriptMapping(this.Generator, this.ScriptSource, script).Destination);
});
return [
...baseScripts,
{
Destination: "package",
Processor: () => {
let executableName = "ts-node";
if (this.Generator.Settings[TSProjectSettingKey.ESModule]) {
executableName += "-esm";
}
return `${executableName} ./src/index.ts`;
}
}
];
}
}
//# sourceMappingURL=WoltLabNodePackageFileMapping.js.map