Skip to content

Instantly share code, notes, and snippets.

View trulysinclair's full-sized avatar
🏗️
Shaping my dreams into a digital form

Sinclair trulysinclair

🏗️
Shaping my dreams into a digital form
View GitHub Profile
@trulysinclair
trulysinclair / monorepo.dprint.json
Last active June 28, 2023 18:30
Dprint Configuration
{
"typescript": {
"ifStatement.useBraces": "preferNone",
"newLineKind": "lf",
"preferHanging": true,
"singleBodyPosition": "nextLine",
"useBraces": "preferNone",
"bracePosition": "sameLineUnlessHanging",
"arrowFunction.useParentheses": "force",
"arguments.preferHanging": "always",
@trulysinclair
trulysinclair / autotyper-1.0
Created June 25, 2023 03:43
Simple cheat for typing tests.
// Get the parent element by its class names
const parentElement = document.querySelector('.css-1rw37je.eu4oa1w0');
// Check if the parent element exists
if (parentElement) {
// Get all the child spans of the parent element
const childSpans = parentElement.querySelectorAll('span');
// Create an array to store the words
const wordsArray = [];
// ~/.noderalis.ts
import { ProjectConfiguration } from '@noderalis/core';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
console.log('Success!!!');
ProjectConfiguration.create({
builds: [
{
entry: async () => ProjectConfiguration.workspace('@noderalis/cli'), // C:\...\noderalis\packages\noderalis-cli\sources\index.ts
// ~/packages/noderalis-core/sources/ProjectConfiguration.ts
import { createRequire, createRequireFromPath } from 'module';
require(path.resolve(__dirname, `../../../.pnp.js`)).setup();
const requireAbs = (createRequire || createRequireFromPath)(
path.resolve(__dirname, './ProjectConfiguration.js')
);
async function requireConfig() {
const rootDir = await this.findProjectCwd(process.cwd(), true);
import { Cli } from 'clipanion';
import { Readable, Writable } from 'stream';
import { readdirSync } from 'fs';
import { join } from 'path';
export type CommandContext = {
cwd: string;
quiet: boolean;
stdin: Readable;
stdout: Writable;
// src/tools/BaseCommand.ts
import { Command } from 'clipanion';
import { CommandContext } from '..';
/**
* The BaseCommand allows us to add behind-the-scenes functionality,
* while also allowing us to now have to add Command<CommandContext>
* to every command manually.
*/
export abstract class BaseCommand extends Command<CommandContext> {
import TsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { resolve } from "path";
import { Configuration } from "webpack";
import { cpus } from "os";
const PnpPlugin = require("pnp-webpack-plugin");
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
const config: Configuration = {
entry: {
@trulysinclair
trulysinclair / pnp.config.ts
Last active June 22, 2020 23:22
This is part of my article Yarn 2 and TypeScript: Adding Webpack, https://medium.com/@thegrimsilence/yarn-2-and-typescript-adding-webpack-9dd9d24001f7.
import { Configuration } from "webpack";
import { resolve } from "path";
// Unfortunately pnpwp lacks TypeScript typings.
const PnpPlugin = require("pnp-webpack-plugin");
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
const config: Configuration = {
entry: {
app: resolve(__dirname, "path-to-your-file.js"),
@trulysinclair
trulysinclair / base.config.ts
Last active June 22, 2020 23:19
This is part of my article Yarn 2 and TypeScript: Adding Webpack, https://medium.com/@thegrimsilence/yarn-2-and-typescript-adding-webpack-9dd9d24001f7.
import { Configuration } from "webpack";
import { resolve } from "path";
/** Check if we're using development or production. */
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
/** A basic Webpack config, using some TypeScript sytactic sugar. */
const config: Configuration = {
// Here we name our entry "app", you can also add others with any non-reserved names.
entry: {
@trulysinclair
trulysinclair / package.json
Created June 22, 2020 05:54
The simple scripts needed to get webpack running.
{
"name": "webpack-starter",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "NODE_ENV=production && yarn _webpack",
"start": "node ./dist/file-example.js",
"_webpack": "webpack-cli --config ./config/webpack.config.ts"
}
}