diff --git a/src/app.ts b/src/app.ts index c0a22635..426c75fc 100644 --- a/src/app.ts +++ b/src/app.ts @@ -4,7 +4,6 @@ import semver from 'semver'; import { createProject, runDepsInstall } from './make'; import { promptAndGetConfig, } from './user-input'; import * as show from './messages'; -import { trackUsage } from './tracking'; (async function () { @@ -21,7 +20,6 @@ import { trackUsage } from './tracking'; projectName, contract, frontend, - components, install, }, projectPath, @@ -34,7 +32,6 @@ import { trackUsage } from './tracking'; createSuccess = await createProject({ contract, frontend, - components, templatesDir: path.resolve(__dirname, '../templates'), projectPath, }); diff --git a/src/make.ts b/src/make.ts index da65e38c..f62e61cd 100644 --- a/src/make.ts +++ b/src/make.ts @@ -5,11 +5,11 @@ import fs from 'fs'; import { ncp } from 'ncp'; import path from 'path'; -export async function createProject({ contract, frontend, components, projectPath, templatesDir }: CreateContractParams & CreateGatewayParams): Promise { +export async function createProject({ contract, frontend, projectPath, templatesDir }: CreateContractParams & CreateGatewayParams): Promise { if (contract !== 'none') { await createContract({ contract, projectPath, templatesDir }); } else { - await createGateway({ frontend, components, projectPath, templatesDir }); + await createGateway({ frontend, projectPath, templatesDir }); } return true; @@ -23,15 +23,10 @@ async function createContract({ contract, projectPath, templatesDir }: CreateCon } -async function createGateway({ frontend, components, projectPath, templatesDir }: CreateGatewayParams) { +async function createGateway({ frontend, projectPath, templatesDir }: CreateGatewayParams) { const sourceFrontendDir = path.resolve(`${templatesDir}/frontend/${frontend}`); fs.mkdirSync(projectPath, { recursive: true }); await copyDir(sourceFrontendDir, projectPath); - - if (components) { - const sourceComponentsDir = path.resolve(`${templatesDir}/frontend/components/${frontend}`); - await copyDir(sourceComponentsDir, projectPath); - } } // Wrap `ncp` tool to wait for the copy to finish when using `await` diff --git a/src/messages.ts b/src/messages.ts index 46e63950..4865c7df 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -1,5 +1,5 @@ import chalk from 'chalk'; -import { trackingMessage, trackUsage } from './tracking'; +import { trackingMessage } from './tracking'; import { Contract, Frontend, FrontendMessage, ProjectName } from './types'; if (process.env.NEAR_NO_COLOR) { @@ -14,7 +14,7 @@ export const welcome = () => 👋 {bold {green Welcome to Near!}} Learn more: https://docs.near.org/ 🔧 Let's get your project ready. {blue ======================================================} -(${trackingMessage})`); +(${trackingMessage})\n`); export const setupFailed = () => show(chalk`{bold {red ==========================================}} diff --git a/src/tracking.ts b/src/tracking.ts index f6b46de0..b93a5f10 100644 --- a/src/tracking.ts +++ b/src/tracking.ts @@ -6,10 +6,10 @@ const MIXPANEL_TOKEN = '24177ef1ec09ffea5cb6f68909c66a61'; const tracker = mixpanel.init(MIXPANEL_TOKEN); -export const trackingMessage = chalk`Near collects anonymous information on the commands used. No personal information that could identify you is shared`; +export const trackingMessage = chalk.italic('Near collects anonymous information on the commands used. No personal information that could identify you is shared'); // TODO: track different failures & install usage -export const trackUsage = async (frontend: Frontend, components: boolean, contract: Contract) => { +export const trackUsage = async (frontend: Frontend, contract: Contract) => { // prevents logging from CI if (process.env.NEAR_ENV === 'ci' || process.env.NODE_ENV === 'ci') { console.log('Mixpanel logging is skipped in CI env'); @@ -18,7 +18,6 @@ export const trackUsage = async (frontend: Frontend, components: boolean, contra try { const mixPanelProperties = { frontend, - components, contract, os: process.platform, nodeVersion: process.versions.node, diff --git a/src/types.ts b/src/types.ts index 424d0ae4..51fda33e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,7 +12,6 @@ export type ProjectName = string; export interface UserConfig { contract: Contract; frontend: Frontend; - components: boolean; projectName: ProjectName; install: boolean; error: (() => void) | undefined; @@ -26,7 +25,6 @@ export type CreateContractParams = { export type CreateGatewayParams = { frontend: Frontend, - components: boolean, projectPath: string, templatesDir: string, } diff --git a/src/user-input.ts b/src/user-input.ts index 9454bede..39e9136b 100644 --- a/src/user-input.ts +++ b/src/user-input.ts @@ -19,7 +19,6 @@ export async function getUserArgs(): Promise { .argument('[projectName]') .option('--frontend [next-page|next-app|none]') .option('--contract [ts|rs|none]') - .option('--components') .option('--install') .addHelpText('after', 'You can create a frontend or a contract with tests'); @@ -27,8 +26,8 @@ export async function getUserArgs(): Promise { const options = program.opts(); const [projectName] = program.args; - const { contract, frontend, install, components } = options; - return { contract, frontend, components, projectName, install, error: undefined }; + const { contract, frontend, install } = options; + return { contract, frontend, projectName, install, error: undefined }; } type Choices = { title: string, description?: string, value: T }[]; @@ -49,11 +48,6 @@ const frontendChoices: Choices = [ { title: 'NextJS (App Router)', description: 'A web-app built using Next.js new App Router', value: 'next-app' }, ]; -const componentChoices: Choices = [ - { title: 'No', value: false }, - { title: 'Yes', value: true }, -]; - const appPrompt: PromptObject = { type: 'select', name: 'app', @@ -68,13 +62,6 @@ const frontendPrompt: PromptObject = { choices: frontendChoices, }; -const componentsPrompt: PromptObject = { - type: 'select', - name: 'components', - message: 'Are you planning in using on-chain NEAR Components (aka BOS Components)?', - choices: componentChoices, -}; - const contractPrompt: PromptObject[] = [ { type: 'select', @@ -109,12 +96,12 @@ export async function getUserAnswers(): Promise { if (app === 'gateway') { // If gateway, ask for the framework to use - const { frontend, components, projectName, install } = await promptUser([frontendPrompt, componentsPrompt, namePrompts, npmPrompt]); - return { frontend, components, contract: 'none', projectName, install, error: undefined }; + const { frontend, projectName, install } = await promptUser([frontendPrompt, namePrompts, npmPrompt]); + return { frontend, contract: 'none', projectName, install, error: undefined }; } else { // If platform is Window, return the error if (process.platform === 'win32') { - return { frontend: 'none', components: false, contract: 'none', projectName: '', install: false, error: show.windowsWarning }; + return { frontend: 'none', contract: 'none', projectName: '', install: false, error: show.windowsWarning }; } // If contract, ask for the language for the contract @@ -122,7 +109,7 @@ export async function getUserAnswers(): Promise { const { projectName } = await promptUser(namePrompts); const install = contract === 'ts' ? (await promptUser(npmPrompt)).install as boolean : false; - return { frontend: 'none', components: false, contract, projectName, install, error: undefined }; + return { frontend: 'none', contract, projectName, install, error: undefined }; } } @@ -138,7 +125,7 @@ export async function promptAndGetConfig(): Promise<{ config: UserConfig, projec } if (args.error) { - trackUsage('none', false, 'none'); + trackUsage('none', 'none'); return args.error(); } @@ -149,8 +136,8 @@ export async function promptAndGetConfig(): Promise<{ config: UserConfig, projec if (!validateUserArgs(args)) return; // track user input - const { frontend, components, contract } = args; - trackUsage(frontend, components, contract); + const { frontend, contract } = args; + trackUsage(frontend, contract); let path = projectPath(args.projectName);