Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #113 from magiclabs/feat/27-rearchitecture
Browse files Browse the repository at this point in the history
Feat/27 rearchitecture
  • Loading branch information
jamesrp13 authored Oct 18, 2023
2 parents a967c7b + 633ff57 commit 3ea9599
Show file tree
Hide file tree
Showing 53 changed files with 1,519 additions and 1,105 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# v4.4.1 (Wed Sep 27 2023)

#### 🚀 Enhancement

- Remove Universal option from prompts (it remains available in flags)

# v4.4.0 (Wed Sep 27 2023)

#### 🚀 Enhancement

- Updates the UI design of the templates

#### Authors: 2

- James ([@jamesrp13](https://github.com/jamesrp13))
- Aditya Kulkarni ([@AdityaKulkarni](https://github.com/AdityaKulkarni))

---

# v4.3.1 (Fri Sep 15 2023)

#### 🚀 Enhancement
Expand Down
3 changes: 1 addition & 2 deletions compiled/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
"react-is",
"tar",
"wrap-ansi",
"yargs-parser",
"zombi"
"yargs-parser"
]
24 changes: 0 additions & 24 deletions compiled/zombi/LICENSE

This file was deleted.

24 changes: 0 additions & 24 deletions compiled/zombi/index.js

This file was deleted.

1 change: 0 additions & 1 deletion compiled/zombi/package.json

This file was deleted.

65 changes: 58 additions & 7 deletions core/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs';
import chalk from 'chalk';
import { ZombiError, ZombiErrorCode } from 'zombi';
import got from 'got';
import { createApp } from './create-app';
import { printHelp } from './help-text';
import { resolveToRoot } from './utils/path-helpers';
import { CreateMagicAppError } from './utils/errors-warnings';
import { CreateMagicAppError, CreateMagicAppErrorCode } from './utils/errors-warnings';
import { parseFlags } from './flags';
import { globalOptions } from './global-options';
import { shutdown, useGracefulShutdown } from './utils/shutdown';
Expand All @@ -13,7 +13,43 @@ import { modifyUsageConsent, initializeUsageConfigIfneeded } from './utils/usage
import { loadConfig } from './config';
import suppressWarnings from './utils/suppress-experimental-warnings';

function sayHello() {
export const ConsoleMessages = {
bootstrapSuccess: (projectName: string, destination: string) => {
console.log(); // Aesthetics!

const magic = chalk`{rgb(92,101,246) M}{rgb(127,103,246) ag}{rgb(168,140,248) ic}`;

const msg = [
'✨\n',
chalk`{bold {green Success!} You've bootstrapped a ${magic} app with {rgb(0,255,255) ${projectName}}!}`,
chalk`Created {bold.rgb(0,255,255) ${projectName}} at {bold.rgb(0,255,255) ${destination}}`,
];

return msg.join('\n');
},

postRenderCommands: (installCmd: string | undefined, startCmd: string | undefined, projectName: string) => {
console.log(); // Aesthetics!

const msg = [
(installCmd || startCmd) && chalk`Inside your app directory, you can run several commands:\n`,

installCmd && chalk` {rgb(0,255,255) ${installCmd}}`,
installCmd && chalk` Install dependencies.\n`,

startCmd && chalk` {rgb(0,255,255) ${startCmd}}`,
startCmd && chalk` Starts the app with a local development server.\n`,

startCmd && chalk`Type the following to restart your newly-created app:\n`,
startCmd && chalk` {rgb(0,255,255) cd} ${projectName}`,
startCmd && chalk` {rgb(0,255,255) ${startCmd}}`,
].filter(Boolean);

return msg.join('\n');
},
};

async function sayHello() {
console.log(chalk`\n
{rgb(92,101,246) █▀▀ █}{rgb(127,103,246) ▀█ █▀▀} {rgb(133,139,247) ▄▀█ ▀█▀} {rgb(168,140,248) █▀▀}
{rgb(92,101,246) █▄▄ █}{rgb(127,103,246) ▀▄ ██▄} {rgb(133,139,247) █▀█ █ } {rgb(168,140,248) ██▄}
Expand All @@ -25,7 +61,16 @@ function sayHello() {
{rgb(92,101,246) █▀█ █}{rgb(127,103,246) ▀▀ █▀▀}
`);

console.log(chalk`\n {dim v${getMakeMagicVersion()}}\n\n`);
const currentVersion = getMakeMagicVersion();
const latestVersion = await getLatestMakeMagicVersion();
if (currentVersion !== latestVersion) {
console.log(
chalk`{rgb(92,101,246) A new version of {bold make-magic} is available! {rgb(0,255,255) ${currentVersion}} → {rgb(0,255,255) ${latestVersion}}}`,
);
console.log(chalk`{rgb(92,101,246) Run {rgb(0,255,255) npm i -g make-magic} to update!}\n\n`);
} else {
console.log(chalk`\n {dim v${getMakeMagicVersion()}}\n\n`);
}
}

(async () => {
Expand All @@ -44,7 +89,7 @@ function sayHello() {
}

if (help) {
sayHello();
await sayHello();
printHelp(globalOptions, template);
shutdown(0);
}
Expand All @@ -59,7 +104,7 @@ function sayHello() {
shutdown(0);
}

sayHello();
await sayHello();

if (collectUsageData && config?.id) {
SharedAnalytics.identifyUser(config.id);
Expand All @@ -69,7 +114,7 @@ function sayHello() {
await createApp({ projectName, template, branch, network });
})().catch((err) => {
SharedAnalytics.logEvent('cli-tool-error', { error: err });
if (err instanceof ZombiError && err.code === ZombiErrorCode.USER_CANCELED_PROMPT) {
if (err instanceof CreateMagicAppError && err.code === CreateMagicAppErrorCode.USER_CANCELED_PROMPT) {
// Skip logging errors about users canceling input, just exit!
shutdown(1);
}
Expand All @@ -87,3 +132,9 @@ function sayHello() {
function getMakeMagicVersion() {
return JSON.parse(fs.readFileSync(resolveToRoot('package.json')).toString('utf8')).version;
}

async function getLatestMakeMagicVersion() {
const latest = await got.get('https://registry.npmjs.org/make-magic/latest');

return JSON.parse(latest.body).version;
}
Loading

0 comments on commit 3ea9599

Please sign in to comment.