Skip to content

Commit

Permalink
Merge pull request #5 from magiclabs/trystendsmyth-update-packages-li…
Browse files Browse the repository at this point in the history
…nting

feat: update name, packages, and linting
  • Loading branch information
trystendsmyth authored Aug 20, 2024
2 parents c34d1b3 + b6c6459 commit 720d2bd
Show file tree
Hide file tree
Showing 36 changed files with 2,064 additions and 1,010 deletions.
39 changes: 18 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
module.exports = {
root: true,

extends: ['@ikscodes/eslint-config'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'airbnb-typescript',
'plugin:@typescript-eslint/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
],

parser: '@typescript-eslint/parser',

parserOptions: {
project: ['./tsconfig.json', './scripts/tsconfig.json']
project: ['./tsconfig.json'],
},

rules: {
// Core ESLint rules
'no-alert': 0,
'no-empty': 0,
'consistent-return': 0,
'class-methods-use-this': 0,
'no-useless-constructor': 0,
plugins: ['react', 'react-hooks', '@typescript-eslint', 'jsx-a11y', 'prettier'],

rules: {
// Import rules
'import/extensions': 0,
'import/no-extraneous-dependencies': 0,

// TypeScript rules
'@typescript-eslint/await-thenable': 0,
'@typescript-eslint/no-useless-constructor': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-floating-promises': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-namespace': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/restrict-template-expressions': 0,
},

settings: {
'import/resolver': {
typescript: {
project: ['./tsconfig.json', './scripts/tsconfig.json'],
project: ['./tsconfig.json'],
},
},
},
}
};
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ labels: 🐛 Bug Report, 🔍 Needs Triage

- [ ] Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
- [ ] Are you running the latest SDK version?
- [ ] Are you reporting to the correct repository (`make-magic`)?
- [ ] Are you reporting to the correct repository (`make-magic-app`)?

### 🐛 Description

Expand Down Expand Up @@ -37,7 +37,7 @@ labels: 🐛 Bug Report, 🔍 Needs Triage

| Software | Version(s) |
| ------------------- | ---------- |
| `make-magic` |
| `make-magic-app` |
| Node |
| `yarn` |
| Operating System |
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ labels: ✨Feature Request
### ✅ Prerequisites

- [ ] Did you perform a cursory search of open issues? Is this feature already requested elsewhere?
- [ ] Are you reporting to the correct repository (`make-magic`)?
- [ ] Are you reporting to the correct repository (`make-magic-app`)?

### ✨ Feature Request

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- 'master'
- 'main'
- 'staging'

env:
Expand All @@ -27,7 +26,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'yarn'

- name: Install dependencies
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ on:
push:
branches:
- "master"
- "main"
pull_request:

jobs:
lint:
runs-on: ubuntu-20.04
name: Run linter and package audit
container:
image: node:16-slim
image: node:20-slim
steps:
- uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'yarn'
- run: |
yarn -v
Expand All @@ -38,14 +37,14 @@ jobs:
runs-on: ubuntu-20.04
name: Run tests
container:
image: node:16-slim
image: node:20-slim
steps:
- uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'yarn'
- run: |
yarn -v
Expand Down
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 120,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false
}
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 🪄 `make-magic`
# 🪄 `make-magic-app`

> A tool for quickly scaffolding an app with Magic baked-in!
Expand All @@ -12,19 +12,19 @@
Getting started with the interactive scaffolding tool is easy. Just run the following command in your preferred shell:

```zsh
npx make-magic
npx make-magic-app
```

Follow the interactive prompts to customize your project. Done! ✨

### Programmatic API

`make-magic` also supports a programmatic API, so you can generate boilerplate codes with Magic built-in from your own NodeJS scripts.
`make-magic-app` also supports a programmatic API, so you can generate boilerplate codes with Magic built-in from your own NodeJS scripts.

```ts
import makeMagic from 'make-magic';
import makeMagicApp from 'make-magic-app';

await makeMagic({
await makeMagicApp({
template: 'hello-world', // Same as --template, -t
projectName: 'my-app', // Same as --project-name, -p
branch: 'master', // Same as --branch, -b
Expand All @@ -37,6 +37,6 @@ await makeMagic({
})
```

See `npx make-magic --help` for information about the available options. In general, most CLI flags map to camel-cased properties in the configuration given to `makeMagic({ ... })`.
See `npx make-magic-app --help` for information about the available options. In general, most CLI flags map to camel-cased properties in the configuration given to `makeMagicApp({ ... })`.

For more information, you can print help text including template-specific options using `npx make-magic --help --template [i.e.: hello-world]`
For more information, you can print help text including template-specific options using `npx make-magic-app --help --template [i.e.: hello-world]`
2 changes: 1 addition & 1 deletion compiled/chalk/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/execa/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/got/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/tar/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/tar/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"tar","version":"6.1.15","main":"index.js","author":"GitHub Inc.","license":"ISC"}
{"name":"tar","version":"6.2.1","main":"index.js","author":"GitHub Inc.","license":"ISC"}
2 changes: 1 addition & 1 deletion compiled/wrap-ansi/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/yargs-parser/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/yargs-parser/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"yargs-parser","version":"20.2.9","main":"index.js","author":"Ben Coe <[email protected]>","license":"ISC"}
{"name":"yargs-parser","version":"21.1.1","main":"index.js","author":"Ben Coe <[email protected]>","license":"ISC"}
14 changes: 8 additions & 6 deletions core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import fs from 'fs';
export const REPO_ROOT = path.resolve(__dirname, '../../');

export const GITHUB_BASE_URL = 'https://github.com';
export const DEFAULT_CREATE_MAGIC_APP_REPO = 'magiclabs/create-magic-app';
export const BINARY = 'make-magic';
export const DEFAULT_CREATE_MAGIC_APP_REPO = 'magiclabs/make-magic-app';
export const BINARY = 'make-magic-app';

export interface CliConfig {
shouldTrackUsageData: boolean;
Expand All @@ -20,22 +20,24 @@ export const saveConfig = (config: Partial<CliConfig>) => {
try {
configCache = config;
const homedir = os.homedir();
const configDir = path.resolve(homedir, '.make-magic');
const configDir = path.resolve(homedir, '.make-magic-app');
if (!fs.existsSync(configDir)) {
fs.mkdirSync(configDir);
}
const configUrl = path.resolve(homedir, '.make-magic/config');
const configUrl = path.resolve(homedir, '.make-magic-app/config');
const configString = JSON.stringify(config);
fs.writeFileSync(configUrl, configString);
} catch (err) {}
} catch (err) {
console.error(err);
}
};

export const loadConfig = (): Partial<CliConfig> | undefined => {
try {
if (configCache) return configCache;

const homedir = os.homedir();
const configUrl = path.resolve(homedir, '.make-magic/config');
const configUrl = path.resolve(homedir, '.make-magic-app/config');
const configString = fs.readFileSync(configUrl, 'utf8');
const config = JSON.parse(configString);
configCache = config;
Expand Down
9 changes: 2 additions & 7 deletions core/create-app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/no-dynamic-require */
/* eslint-disable global-require */
/* eslint-disable no-param-reassign */

import fs from 'fs';
import { URL } from 'url';
import path from 'path';
Expand All @@ -14,7 +9,7 @@ import { BlockchainNetworkPrompt } from 'scaffolds/prompts';
import { downloadAndExtractRepo, getRepoInfo } from './utils/repo';
import { makeDir } from './utils/make-dir';
import { DEFAULT_CREATE_MAGIC_APP_REPO, GITHUB_BASE_URL } from './config';
import { getAbsoluteTemplatePath, getRelativeTemplatePath, resolveToDist, resolveToRoot } from './utils/path-helpers';
import { getAbsoluteTemplatePath, getRelativeTemplatePath, resolveToDist } from './utils/path-helpers';
import { createProjectDirIfDoesntExists, getScaffoldDefinition } from './utils/scaffold-helpers';
import { printWarning } from './utils/errors-warnings';
import { parseFlags } from './flags';
Expand All @@ -28,7 +23,7 @@ import { ConsoleMessages } from './cli';

export interface CreateMagicAppData extends BlockchainNetworkPrompt.Data {
/**
* The `make-magic` project branch to source templates from.
* The `make-magic-app` project branch to source templates from.
*/
branch: string;

Expand Down
22 changes: 11 additions & 11 deletions core/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export type ValueType = string | string[] | number | number[] | boolean;
type FlagType<T extends ValueType = ValueType> = T extends string
? StringConstructor
: T extends string[]
? [StringConstructor]
: T extends number
? NumberConstructor
: T extends number[]
? [NumberConstructor]
: T extends boolean
? BooleanConstructor
: StringConstructor | NumberConstructor | BooleanConstructor;
? [StringConstructor]
: T extends number
? NumberConstructor
: T extends number[]
? [NumberConstructor]
: T extends boolean
? BooleanConstructor
: StringConstructor | NumberConstructor | BooleanConstructor;

/**
* Configuration to modify the behavior of flag-based template data inputs.
Expand All @@ -36,7 +36,7 @@ type BaseFlag<T extends ValueType = ValueType> = {

/**
* A help-text description for this flag. This will be printed along with
* global `make-magic` documentation when the respective template is used
* global `make-magic-app` documentation when the respective template is used
* alongside the standard `--help` flag.
*/
readonly description: string;
Expand Down Expand Up @@ -75,8 +75,8 @@ export type Flags<T extends Record<string, ValueType | null | undefined> = Recor
[P in keyof Required<T>]: undefined extends T[P]
? BaseFlag<NonNullable<T[P]>>
: null extends T[P]
? BaseFlag<NonNullable<T[P]>>
: BaseFlagWithRequiredDefault<NonNullable<T[P]>>;
? BaseFlag<NonNullable<T[P]>>
: BaseFlagWithRequiredDefault<NonNullable<T[P]>>;
};

export type TypedFlags<F extends Flags> = F extends Flags<infer R> ? R : unknown;
Expand Down
7 changes: 4 additions & 3 deletions core/help-text.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-param-reassign */
/* eslint-disable consistent-return */

import { c } from 'tar';
import chalk from 'chalk';
import decamelize from 'decamelize';
import wrapAnsi from 'wrap-ansi';
Expand Down Expand Up @@ -51,7 +50,9 @@ export function printHelp(globalOptions: Flags, scaffoldName?: string) {
content: createOptionsTable(flags),
}),
);
} catch {}
} catch (err) {
console.error(err);
}

// Usage examples
helpSections.push(
Expand Down Expand Up @@ -101,7 +102,7 @@ function createOptionsTable(flags: Record<string, string | Flag>) {
const maxWidth = 80 - gap;
const argColumnWidth = Math.max(...rows.map(([arg]) => arg.length));

const helpTexts = rows.map(([_, helpText]) => formatDescription(helpText, maxWidth, argColumnWidth + gap));
const helpTexts = rows.map(([, helpText]) => formatDescription(helpText, maxWidth, argColumnWidth + gap));

return rows.map(([arg], i) => [arg, helpTexts[i]].join(' '.repeat(argColumnWidth - arg.length + gap))).join('\n\n');
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createApp, CreateMagicAppConfig } from './create-app';
*
* @see https://magic.link/
*/
export default async function makeMagic(options: CreateMagicAppConfig = {}) {
export default async function makeMagicApp(options: CreateMagicAppConfig = {}) {
const { projectName = 'my-app', template = 'hello-world', branch = 'master', data = {} } = options;
await createApp({ projectName, template, branch, data });
}
3 changes: 3 additions & 0 deletions core/types/BaseScaffold.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export default abstract class BaseScaffold {
public abstract templateName: string;

public abstract source: string | string[];

public abstract installationCommand: ExecaCommand;

public abstract startCommand: ExecaCommand;
}

Expand Down
7 changes: 5 additions & 2 deletions core/utils/errors-warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ export enum CreateMagicAppErrorCode {
}

/**
* Base class representing `make-magic` errors.
* Base class representing `make-magic-app` errors.
*/
export class CreateMagicAppError<Code extends CreateMagicAppErrorCode = CreateMagicAppErrorCode> extends Error {
constructor(public readonly code: Code, message?: string) {
constructor(
public readonly code: Code,
message?: string,
) {
super(chalk`{red Error:} ${message}`);
}
}
Expand Down
2 changes: 2 additions & 0 deletions core/utils/renderScaffold.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-loop-func */

import path from 'path';
import fs from 'fs';
import BaseScaffold from 'core/types/BaseScaffold';
Expand Down
2 changes: 1 addition & 1 deletion core/utils/repo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable consistent-return */
/* eslint-disable @typescript-eslint/naming-convention */

/**
* The utilities in this file are based on the
Expand Down
Loading

0 comments on commit 720d2bd

Please sign in to comment.