first commit

This commit is contained in:
2024-01-19 11:09:11 +01:00
commit b18af7a943
29473 changed files with 4500547 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import { workspaces } from '@angular-devkit/core';
import { Rule } from '@angular-devkit/schematics';
import { Schema } from './schema';
export default function (options: Schema): Rule;
export declare function getProjectTargetOptions(project: workspaces.ProjectDefinition, buildTarget: string): Record<string, import("@angular-devkit/core").JsonValue | undefined>;

View File

@@ -0,0 +1,90 @@
"use strict";
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectTargetOptions = void 0;
const schematics_1 = require("@angular-devkit/schematics");
const tasks_1 = require("@angular-devkit/schematics/tasks");
const typescript_1 = require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript");
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
const change_1 = require("@schematics/angular/utility/change");
const dependencies_1 = require("@schematics/angular/utility/dependencies");
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
const util_1 = require("@schematics/angular/utility/standalone/util");
const workspace_1 = require("@schematics/angular/utility/workspace");
const versions_1 = require("./versions");
function default_1(options) {
return (0, schematics_1.chain)([
(tree, context) => {
(0, dependencies_1.addPackageJsonDependency)(tree, {
type: dependencies_1.NodeDependencyType.Default,
name: '@fortawesome/fontawesome-svg-core',
version: options.version === '6' ? versions_1.iconPackVersion : versions_1.v5.svgCoreVersion,
});
(0, dependencies_1.addPackageJsonDependency)(tree, {
type: dependencies_1.NodeDependencyType.Default,
name: '@fortawesome/angular-fontawesome',
version: versions_1.angularFontawesomeVersion,
});
const iconPackages = options.iconPackages != null ? options.iconPackages : ['free-solid'];
for (const pack of iconPackages) {
(0, dependencies_1.addPackageJsonDependency)(tree, {
type: dependencies_1.NodeDependencyType.Default,
name: `@fortawesome/${pack}-svg-icons`,
version: options.version === '6' ? versions_1.iconPackVersion : versions_1.v5.iconPackVersion,
});
}
context.addTask(new tasks_1.NodePackageInstallTask());
return tree;
},
addModule(options),
]);
}
exports.default = default_1;
function addModule(options) {
return (host) => __awaiter(this, void 0, void 0, function* () {
const workspace = yield (0, workspace_1.getWorkspace)(host);
const projectName = options.project;
const project = workspace.projects.get(projectName);
if (project == null) {
throw new schematics_1.SchematicsException(`Project with name ${projectName} does not exist.`);
}
const mainPath = yield (0, util_1.getMainFilePath)(host, projectName);
if (!(0, ng_ast_utils_1.isStandaloneApp)(host, mainPath)) {
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
const moduleSource = getSourceFile(host, modulePath);
const changes = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, 'FontAwesomeModule', '@fortawesome/angular-fontawesome');
const recorder = host.beginUpdate(modulePath);
changes.forEach((change) => {
if (change instanceof change_1.InsertChange) {
recorder.insertLeft(change.pos, change.toAdd);
}
});
host.commitUpdate(recorder);
}
});
}
function getSourceFile(host, path) {
const buffer = host.read(path);
if (!buffer) {
throw new schematics_1.SchematicsException(`Could not find ${path}.`);
}
const content = buffer.toString('utf-8');
return (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.Latest, true);
}
function getProjectTargetOptions(project, buildTarget) {
const buildTargetObject = project.targets.get(buildTarget);
if (buildTargetObject && buildTargetObject.options) {
return buildTargetObject.options;
}
throw new schematics_1.SchematicsException(`Cannot determine project target configuration for: ${buildTarget}.`);
}
exports.getProjectTargetOptions = getProjectTargetOptions;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/schematics/src/ng-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AAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,gCAAmB,CAAC,kBAAkB,IAAI,GAAG,CAAC,CAAC;KAC1D;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,IAAA,6BAAgB,EAAC,IAAI,EAAE,OAAO,EAAE,yBAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,SAAgB,uBAAuB,CAAC,OAAqC,EAAE,WAAmB;IAChG,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3D,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,OAAO,EAAE;QAClD,OAAO,iBAAiB,CAAC,OAAO,CAAC;KAClC;IAED,MAAM,IAAI,gCAAmB,CAAC,sDAAsD,WAAW,GAAG,CAAC,CAAC;AACtG,CAAC;AAPD,0DAOC"}

View File

@@ -0,0 +1,8 @@
export interface Schema {
/** Name of the project. */
project?: string;
/** The FontAwesome version to install. */
version?: '5' | '6';
/** The icon packages to install */
iconPackages?: ('free-solid' | 'free-regular' | 'free-brands' | 'pro-solid' | 'pro-regular' | 'pro-light' | 'pro-duotone' | 'pro-thin' | 'sharp-solid')[];
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=schema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../projects/schematics/src/ng-add/schema.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,98 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "angular-fontawesome-ng-add",
"title": "Font Awesome ng-add schematic",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"$default": {
"$source": "projectName"
}
},
"version": {
"description": "The FontAwesome version to install.",
"type": "string",
"default": "6",
"x-prompt": {
"message": "Choose Font Awesome version you would like to use:",
"type": "list",
"items": [
{
"value": "6",
"label": "Font Awesome 6"
},
{
"value": "5",
"label": "Font Awesome 5"
}
]
}
},
"iconPackages": {
"description": "The icon packages to install.",
"type": "array",
"items": {
"type": "string",
"enum": [
"free-solid",
"free-regular",
"free-brands",
"pro-solid",
"pro-regular",
"pro-light",
"pro-duotone",
"pro-thin",
"sharp-solid"
]
},
"default": ["free-solid"],
"x-prompt": {
"message": "Choose Font Awesome icon packages you would like to use:",
"type": "list",
"multiselect": true,
"items": [
{
"value": "free-solid",
"label": "Free Solid Icons"
},
{
"value": "free-regular",
"label": "Free Regular Icons"
},
{
"value": "free-brands",
"label": "Free Brands Icons"
},
{
"value": "pro-solid",
"label": "Pro Solid Icons [ Requires Pro plan: https://fontawesome.com/plans ]"
},
{
"value": "pro-regular",
"label": "Pro Regular Icons [ Requires Pro plan: https://fontawesome.com/plans ]"
},
{
"value": "pro-light",
"label": "Pro Light Icons [ Requires Pro plan: https://fontawesome.com/plans ]"
},
{
"value": "pro-duotone",
"label": "Pro Duotone Icons [ Requires Pro plan: https://fontawesome.com/plans ]"
},
{
"value": "pro-thin",
"label": "Pro Thin Icons [ Requires Pro plan: https://fontawesome.com/plans ]"
},
{
"value": "sharp-solid",
"label": "Sharp Solid Icons [ Requires Pro plan: https://fontawesome.com/plans ]"
}
]
}
}
},
"required": [],
"additionalProperties": false
}

View File

@@ -0,0 +1,6 @@
export declare const angularFontawesomeVersion = "~0.14.0";
export declare const iconPackVersion = "^6.4.2";
export declare const v5: {
svgCoreVersion: string;
iconPackVersion: string;
};

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.v5 = exports.iconPackVersion = exports.angularFontawesomeVersion = void 0;
exports.angularFontawesomeVersion = '~0.14.0';
exports.iconPackVersion = '^6.4.2';
exports.v5 = {
svgCoreVersion: '~1.2.36',
iconPackVersion: '^5.15.4',
};
//# sourceMappingURL=versions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../projects/schematics/src/ng-add/versions.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GAAG,SAAS,CAAC;AACtC,QAAA,eAAe,GAAG,QAAQ,CAAC;AAE3B,QAAA,EAAE,GAAG;IAChB,cAAc,EAAE,SAAS;IACzB,eAAe,EAAE,SAAS;CAC3B,CAAC"}