Skip to content

Instantly share code, notes, and snippets.

View philipjfulcher's full-sized avatar

Philip Fulcher philipjfulcher

View GitHub Profile
@philipjfulcher
philipjfulcher / gist:dcc63282253a3e0722168f2df717dd50
Created February 27, 2024 20:02
Experimental lint rule example
import {
joinPathFragments,
normalizePath,
NX_VERSION,
ProjectGraphExternalNode,
ProjectGraphProjectNode, readCachedProjectGraph,
workspaceRoot
} from '@nx/devkit';
import { isRelativePath } from 'nx/src/utils/fileutils';
import { ESLintUtils } from '@typescript-eslint/utils';
import { createProjectGraphAsync } from '@nx/devkit';
import { execSync } from 'node:child_process';
export async function churnGenerator(
) {
const graph = await createProjectGraphAsync();
const projects: Record<string, { ancestors: number; affected: number }> = {};
console.log('Calculating ancestors');
for (const project in graph.dependencies) {
@philipjfulcher
philipjfulcher / generator-with-lint.ts
Last active November 4, 2021 16:50
generator-with-lint
import {
Tree,
formatFiles,
generateFiles,
joinPathFragments,
} from '@nrwl/devkit';
import { libraryGenerator } from '@nrwl/workspace/generators';
import { execSync } from 'child_process';
export default async function (tree: Tree, schema: any) {
@philipjfulcher
philipjfulcher / find-npm-dependents.ts
Last active September 17, 2021 19:07
Nx Dep Graph script examples
import * as yargs from 'yargs';
import { createProjectGraphAsync } from '@nrwl/workspace/src/core/project-graph';
async function main() {
const graph = await createProjectGraphAsync();
const libToFind = yargs.argv._[0];
console.log(`These projects depend on ${libToFind}`);
Object.values(graph.dependencies).forEach((deps) => {
ERROR Error: Document file not found at 'api/forms/ControlContainer'
Angular 20
getFileNotFoundDoc
fetchDocument
error
_error
error
_error
error
@philipjfulcher
philipjfulcher / package.json
Last active May 15, 2020 15:00
package.json
{
"name": "nx-migrate-angularjs",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"nx": "nx",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
@philipjfulcher
philipjfulcher / ap.po.ts
Last active June 12, 2020 15:29
Example po file for Protractor test for AngularJS in nx
//ap.po.ts
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo(): Promise<unknown> {
return browser.get(browser.baseUrl) as Promise<unknown>;
}
getTitleText(): Promise<string> {
@philipjfulcher
philipjfulcher / app.e2e-spec.ts
Last active June 12, 2020 15:30
Example Proteactor test for AngularJS in nx
// app.e2e-spec.ts
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
@philipjfulcher
philipjfulcher / comment.component.spec.js
Created April 17, 2020 20:12
Example AngularJS unit test
import articleModule from './index';
beforeEach(() => {
// Create the module where our functionality can attach to
angular.mock.module('ui.router');
angular.mock.module(articleModule.name);
});
let component;
@philipjfulcher
philipjfulcher / karma.config.js
Created April 17, 2020 20:10
Example Karma config for AngularJS in nx
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
// reuse webpack config
const webpack = require('./webpack.config');
const getBaseKarmaConfig = require('../../karma.conf');
module.exports = function(config) {
const baseConfig = getBaseKarmaConfig();
config.set({
...baseConfig,