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

Staging #116

Merged
merged 21 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# v4.4.2 (Wed Sep 27 2023)

#### 🚀 Enhancement

- Removes dependency on Zombi
- Fixes issue caused by web3.js update

#### Authors: 2

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

---

# 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
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