Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
DopamineDriven committed Nov 18, 2024
1 parent 67938af commit 9a1059e
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 123 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-toys-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@turbogen/turbogen": minor
---

0.4.0
90 changes: 6 additions & 84 deletions packages/turbogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,107 +19,29 @@ pnpm ddturbogen init
Run `pnpm init` in a new repo and install the package.


```bash
dopaminedriven@LAPTOP-2IH011V4:~/wcd/faderoom-github/faderoom$ pnpm install
Packages: +44
++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 44, reused 43, downloaded 1, added 44, done

devDependencies:
+ @d0paminedriven/turbogen 0.1.0

Done in 1.3s
```
![ddturbogen-install](./public/ddturbogen-install.png)


Once installed, your `package.json` file should look similar to the following

```json
{
"name": "example-repo",
"version": "1.0.0",
"description": "",
"devDependencies": {
"@d0paminedriven/turbogen": "^0.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}

```
![ddturbogen-package-json-before](./public/ddturbogen-package-json--before.png)


Now run the `pnpm ddturbogen init` command (ddturbogen = dopamine driven turbogen 🌚)
Now run the `pnpm ddturbogen init` command (ddturbogen is short for dopamine driven turbogen 🌚)

There are two prompts to answer, shown below

```bash
dopaminedriven@LAPTOP-2IH011V4:~/wcd/faderoom-github/faderoom$ pnpm ddturbogen init
~ Enter your desired workspace name (eg, acme for an `@acme/*` naming convention) faderoom
~ Which port should be used for your nextjs web application? 3001
```

![ddturbogen-init](./public/ddturbogen-init.png)


Once finished, your entire workspace is instantly generated, tooling is configured, and a web app is ready to go. Your locally installed version of pnpm is also parsed and included in your root `package.json` file

Now, your root `package.json` should look similar to the following


```json
{
"name": "@faderoom/root",
"license": "MIT",
"private": true,
"packageManager": "[email protected]",
"scripts": {
"build:web": "turbo build --filter=@faderoom/web",
"changeset": "changeset",
"clean": "git clean -xdf node_modules",
"dev": "turbo dev --parallel --continue",
"format": "prettier --write \"**/*.{ts,tsx,cts,mts,js,jsx,mjs,cjs,json,yaml,yml,css,html,md,mdx}\" --ignore-unknown --cache",
"lint": "turbo lint",
"prepare": "husky",
"typecheck": "turbo typecheck",
"clean:house": "cd apps/web && git clean -xdf node_modules .next .turbo && cd ../..tooling/eslint && git clean -xdf node_modules .turbo && cd ../prettier && git clean -xdf node_modules .turbo && cd ../typescript && git clean -xdf .turbo node_modules && cd ../jest-presets && git clean -xdf node_modules .turbo && cd ../.. && git clean -xdf node_modules pnpm-lock.yaml && pnpm install",
"generate:base64": "openssl rand -base64 64",
"generate:hex": "openssl rand -hex 64",
"npm:registry": "npm set registry https://registry.npmjs.org",
"run:web": "turbo dev --filter=@faderoom/web",
"sync:time": "sudo ntpdate time.windows.com",
"latest:pnpm": "corepack use pnpm@latest",
"update:pnpm": "curl -fsSL https://get.pnpm.io/install.sh | sh -"
},
"devDependencies": {
"@changesets/cli": "latest",
"@faderoom/eslint-config": "workspace:*",
"@faderoom/prettier-config": "workspace:*",
"@faderoom/tsconfig": "workspace:*",
"@d0paminedriven/turbogen": "latest",
"@total-typescript/ts-reset": "latest",
"@types/node": "latest",
"dotenv": "latest",
"dotenv-cli": "latest",
"dotenv-expand": "latest",
"eslint": "latest",
"husky": "latest",
"prettier": "latest",
"tsx": "latest",
"turbo": "latest",
"typescript": "latest",
"vercel": "latest"
},
"prettier": "@faderoom/prettier-config",
"engines": {
"node": ">=20",
"npm": ">=10",
"pnpm": ">=9"
}
}
```
![package-json-after](./public/ddturbogen-package-json-after.png)

### An important Final step -- run install again from the root

Expand Down
Binary file added packages/turbogen/public/ddturbogen-init.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/turbogen/public/ddturbogen-install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 1 addition & 10 deletions packages/turbogen/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ dotenv.config();

/* eslint-disable no-useless-escape */
/* eslint-disable prefer-const */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable no-extra-boolean-cast */
/* eslint-disable @typescript-eslint/prefer-for-of */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
/* eslint-disable @typescript-eslint/restrict-template-expressions */

export class ConfigHandler {
constructor(public cwd: string) {}
Expand Down Expand Up @@ -54,15 +46,14 @@ export class ConfigHandler {
// prettier-ignore
return `enable-pre-post-scripts=true
node-linker=hoisted
link-workspace-packages=true
email=
# Uncomment the following lines and provide corresponding values to point at the npm registry
# //registry.npmjs.org/:_authToken=
# //registry.npmjs.org/:_password=
# //registry.npmjs.org/:username=`;
# //registry.npmjs.org/:username=` as const;
}

public handleNpmrc() {
Expand Down
1 change: 0 additions & 1 deletion packages/turbogen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export type {
OpenMode,
ProcessEnv,
ProcessEnvOptions,
PromptProps,
PromptPropsBase,
ReadDirOptions,
ReadDirProps,
Expand Down
2 changes: 1 addition & 1 deletion packages/turbogen/src/services/cli/inquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class InquirerService extends ConfigHandler {
return `workspace name must begin with a lowercase letter and only use a combination of dashes (-), lowercase letters, and numbers; invalid value of "${value}"`;
}
if (
/(\\|\*|\.|\/|\~|\!|\,|\#|\@|\$|\%|\^|\&|\(|\)|\_|\{|\}|\||\`|\[|\]|\>|\<|\+|\=|\;|\:|\"|\')/g.test(
/(\\|\*|\.|\/|~|!|,|#|@|\$|%|\^|&|\(|\)|_|\{|\}|\||`|\[|\]|>|<|\+|=|;|:|"|')/g.test(
value
) === true
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ConfigHandler } from "@/config/index.js";
import { PromptPropsBase } from "@/types/index.js";

/* eslint-disable no-useless-escape */

export class WebAppScaffolder extends ConfigHandler {
constructor(
public override cwd: string,
Expand Down Expand Up @@ -787,10 +789,6 @@ export function omitFields<
` as const;
}

private get T() {
let x = "";
return x;
}
private get rootPageTsx() {
// prettier-ignore
return `import Image from "next/image";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class RootScaffolder extends ConfigHandler {
"dotenv-expand": "latest",
"eslint": "latest",
"husky": "latest",
"jiti": "latest",
"prettier": "latest",
"tsx": "latest",
"turbo": "latest",
Expand Down Expand Up @@ -133,6 +134,7 @@ export class RootScaffolder extends ConfigHandler {
"dotenv-expand": "latest",
"eslint": "latest",
"husky": "latest",
"jiti": "latest",
"prettier": "latest",
"tsx": "latest",
"turbo": "latest",
Expand Down
30 changes: 19 additions & 11 deletions packages/turbogen/src/services/scaffold/tooling/eslint-scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ export class EslintScaffolder extends ConfigHandler {
// prettier-ignore
return `/// <reference types="./types.d.ts" />
import { relative } from "node:path";
import { join, relative } from "node:path";
import eslint from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import turboPlugin from "eslint-plugin-turbo";
import tseslint from "typescript-eslint";
import { includeIgnoreFile } from "@eslint/compat";
const project = relative(process.cwd(), "tsconfig.json");
export default tseslint.config(
includeIgnoreFile(join(import.meta.dirname, "../../.gitignore")),
{
// Globally ignored files
ignores: [
Expand Down Expand Up @@ -85,14 +87,19 @@ export default tseslint.config(
"@typescript-eslint/consistent-type-imports": "off",
"no-unsafe-finally": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@next/next/no-page-custom-font": "off"
"@next/next/no-page-custom-font": "off",
// the following three rules are turned off due to existing errors eslint has when reading the source files
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-empty-function": "off"
}
},
{
linterOptions: { reportUnusedDisableDirectives: true },
languageOptions: { parserOptions: { project: project } }
languageOptions: { parserOptions: { project } }
}
);` as const;
);
` as const;
}

private get nextScaffold() {
Expand Down Expand Up @@ -162,14 +169,14 @@ export default [
"format": "prettier --check . --ignore-path ../../.gitignore",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@eslint/compat": "latest",
{
"@eslint/compat": "^1.1.1",
"@next/eslint-plugin-next": "latest",
"eslint-config-turbo": "latest",
"eslint-plugin-import": "latest",
"eslint-plugin-jsx-a11y": "latest",
"eslint-plugin-react": "latest",
"eslint-plugin-react-hooks": "rc",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-turbo": "latest",
"typescript-eslint": "latest"
},
Expand Down Expand Up @@ -258,7 +265,8 @@ declare module "eslint-plugin-turbo" {
recommended: { rules: Linter.RulesRecord };
};
export const rules: Record<string, Rule.RuleModule>;
}` as const;
}
` as const;
}

private eslintPath<const F extends string>(file: F) {
Expand Down
12 changes: 0 additions & 12 deletions packages/turbogen/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ export type PromptPropsBase = {
readonly port: string;
};

export interface PromptProps extends PromptPropsBase {
readonly cloudinaryRootFolder: string;
readonly localUrl: string;
readonly previewUrl: string;
readonly prodUrl: string;
readonly description: string;
readonly title: string;
readonly auth: "AD" | "None" | "Okta";
readonly ga: string;
readonly appDirName: string;
}

export type BufferEncodingUnion =
| "ascii"
| "utf8"
Expand Down

0 comments on commit 9a1059e

Please sign in to comment.