From cd6cae81f42724d1f0ecccbe53096d71c555d3e2 Mon Sep 17 00:00:00 2001 From: garikbesson Date: Wed, 11 Sep 2024 20:20:57 +0200 Subject: [PATCH 1/5] removed components, small style fixes --- src/app.ts | 3 --- src/make.ts | 11 +++-------- src/messages.ts | 4 ++-- src/tracking.ts | 5 ++--- src/types.ts | 2 -- src/user-input.ts | 31 +++++++++---------------------- 6 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/app.ts b/src/app.ts index c0a22635b..426c75fcd 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 da65e38c2..f62e61cdb 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 46e639505..4865c7df2 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 f6b46de0f..b93a5f105 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 424d0ae49..51fda33e1 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 9454beded..39e9136b2 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); From ee4e60a7de9ceda6eb2ab6de5f66b2232ac52de8 Mon Sep 17 00:00:00 2001 From: garikbesson Date: Thu, 26 Sep 2024 19:23:09 +0200 Subject: [PATCH 2/5] migrated tracking to posthog --- package.json | 5 +- src/messages.ts | 10 +-- src/tracking.ts | 49 ++++++++---- src/types.ts | 17 +++- src/user-input.ts | 4 +- .../contracts/{ts => javascript}/README.md | 0 .../contracts/{ts => javascript}/package.json | 0 .../sandbox-test/main.ava.js | 0 .../{ts => javascript}/src/contract.ts | 0 .../{ts => javascript}/tsconfig.json | 0 .../contracts/{ts => javascript}/yarn.lock | 0 templates/contracts/{rs => rust}/Cargo.lock | 0 templates/contracts/{rs => rust}/Cargo.toml | 0 templates/contracts/{rs => rust}/README.md | 0 .../{rs => rust}/rust-toolchain.toml | 0 templates/contracts/{rs => rust}/src/lib.rs | 0 .../{rs => rust}/tests/test_basics.rs | 0 yarn.lock | 77 +++++++++++++------ 18 files changed, 114 insertions(+), 48 deletions(-) rename templates/contracts/{ts => javascript}/README.md (100%) rename templates/contracts/{ts => javascript}/package.json (100%) rename templates/contracts/{ts => javascript}/sandbox-test/main.ava.js (100%) rename templates/contracts/{ts => javascript}/src/contract.ts (100%) rename templates/contracts/{ts => javascript}/tsconfig.json (100%) rename templates/contracts/{ts => javascript}/yarn.lock (100%) rename templates/contracts/{rs => rust}/Cargo.lock (100%) rename templates/contracts/{rs => rust}/Cargo.toml (100%) rename templates/contracts/{rs => rust}/README.md (100%) rename templates/contracts/{rs => rust}/rust-toolchain.toml (100%) rename templates/contracts/{rs => rust}/src/lib.rs (100%) rename templates/contracts/{rs => rust}/tests/test_basics.rs (100%) diff --git a/package.json b/package.json index e9e750fd7..53c192cff 100644 --- a/package.json +++ b/package.json @@ -27,16 +27,15 @@ "chalk": "^4.1.2", "commander": "^11.0.0", "cross-spawn": "^7.0.3", - "mixpanel": "^0.18.0", "ncp": "^2.0.0", "prompts": "^2.4.2", "semver": "^7.5.3" }, "devDependencies": { - "@babel/eslint-parser": "^7.22.5", "@babel/core": "^7.23.2", - "@babel/plugin-transform-react-jsx": "^7.22.15", + "@babel/eslint-parser": "^7.22.5", "@babel/plugin-syntax-flow": "^7.22.5", + "@babel/plugin-transform-react-jsx": "^7.22.15", "@commitlint/cli": "^17.6.6", "@commitlint/config-conventional": "^17.6.6", "@release-it/conventional-changelog": "^5.1.1", diff --git a/src/messages.ts b/src/messages.ts index 4865c7df2..c09c3a7f4 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -27,7 +27,7 @@ export const successContractToText = (contract: Contract) => contract === 'none' ? '' : chalk`a smart contract in {bold ${ - contract === 'rs' ? 'Rust' : 'Typescript' + contract === 'rust' ? 'Rust' : 'Typescript' }}`; const frontendTemplates: FrontendMessage = { @@ -52,7 +52,7 @@ export const setupSuccess = ( contract )}${successFrontendToText(frontend)}. ${ - contract === 'rs' + contract === 'rust' ? chalk`🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}\n` : '' } @@ -74,20 +74,20 @@ export const contractInstructions = ( - {inverse Navigate to your project}: {blue cd {bold ${projectName}}} ${ - contract === 'ts' && !install + contract === 'javascript' && !install ? chalk` - {inverse Install all dependencies} {blue npm {bold install}}` : 'Then:' } - {inverse Build your contract}: ${ - contract === 'ts' + contract === 'javascript' ? chalk`{blue npm {bold run build}}` : chalk`{blue {bold cargo near build}}` } - {inverse Test your contract} in the Sandbox: ${ - contract === 'ts' + contract === 'javascript' ? chalk`{blue npm {bold run test}}` : chalk`{blue {bold cargo test}}` } diff --git a/src/tracking.ts b/src/tracking.ts index b93a5f105..b4d96ce25 100644 --- a/src/tracking.ts +++ b/src/tracking.ts @@ -1,10 +1,9 @@ -import {Contract, Frontend} from './types'; import chalk from 'chalk'; -import mixpanel from 'mixpanel'; +import {Contract, Frontend, TrackingEventPayload} from './types'; -const MIXPANEL_TOKEN = '24177ef1ec09ffea5cb6f68909c66a61'; +const POSTHOG_API_KEY = 'phc_bMxqEAiInwlq3FMyZvuFPZ8qdYuVwh9L5YfqRpeFk0I'; +const POSTHOG_API_URL = 'https://eu.i.posthog.com/capture'; -const tracker = mixpanel.init(MIXPANEL_TOKEN); export const trackingMessage = chalk.italic('Near collects anonymous information on the commands used. No personal information that could identify you is shared'); @@ -12,18 +11,42 @@ export const trackingMessage = chalk.italic('Near collects anonymous information 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'); + console.log('PostHog logging is skipped in CI env'); return; } - try { - const mixPanelProperties = { - frontend, - contract, + + const payload: TrackingEventPayload = { + distinct_id: 'create-near-app', + event: 'error', + properties: { + engine: process.versions.node, os: process.platform, - nodeVersion: process.versions.node, - timestamp: new Date().toString() - }; - tracker.track('CNA', mixPanelProperties); + }, + timestamp: new Date(), + }; + + if (contract !== 'none') { + payload.event = 'contract'; + payload.properties.language = contract; + } + + if (frontend !== 'none') { + payload.event = 'frontend'; + payload.properties.framework = frontend; + } + + const headers = new Headers(); + headers.append('Content-Type', 'application/json'); + + try { + await fetch(POSTHOG_API_URL, { + method: 'POST', + body: JSON.stringify({ + api_key: POSTHOG_API_KEY, + ...payload, + }), + headers, + }); } catch (e) { console.error( 'Warning: problem while sending tracking data. Error: ', diff --git a/src/types.ts b/src/types.ts index 51fda33e1..216ec261a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ -export type Contract = 'ts' | 'rs' | 'none'; -export const CONTRACTS: Contract[] = ['ts', 'rs', 'none']; +export type Contract = 'javascript' | 'rust' | 'none'; +export const CONTRACTS: Contract[] = ['javascript', 'rust', 'none']; export type Frontend = 'next-app' | 'next-page' | 'none'; export const FRONTENDS: Frontend[] = ['next-app' , 'next-page', 'none']; @@ -31,4 +31,17 @@ export type CreateGatewayParams = { export type FrontendMessage = { [key in Exclude]: string; +}; + +export type TrackingEventName = 'contract' | 'frontend' | 'error'; +export type TrackingEventPayload = { + distinct_id: string, + event: TrackingEventName, + properties: { + engine: string, + os: string, + language?: string, + framework?: string + }, + timestamp: Date, }; \ No newline at end of file diff --git a/src/user-input.ts b/src/user-input.ts index 39e9136b2..758c749e2 100644 --- a/src/user-input.ts +++ b/src/user-input.ts @@ -39,8 +39,8 @@ const appChoices: Choices = [ }, ]; const contractChoices: Choices = [ - { title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'ts' }, - { title: 'Rust Contract', description: 'A Near contract written in Rust', value: 'rs' }, + { title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'javascript' }, + { title: 'Rust Contract', description: 'A Near contract written in Rust', value: 'rust' }, ]; const frontendChoices: Choices = [ diff --git a/templates/contracts/ts/README.md b/templates/contracts/javascript/README.md similarity index 100% rename from templates/contracts/ts/README.md rename to templates/contracts/javascript/README.md diff --git a/templates/contracts/ts/package.json b/templates/contracts/javascript/package.json similarity index 100% rename from templates/contracts/ts/package.json rename to templates/contracts/javascript/package.json diff --git a/templates/contracts/ts/sandbox-test/main.ava.js b/templates/contracts/javascript/sandbox-test/main.ava.js similarity index 100% rename from templates/contracts/ts/sandbox-test/main.ava.js rename to templates/contracts/javascript/sandbox-test/main.ava.js diff --git a/templates/contracts/ts/src/contract.ts b/templates/contracts/javascript/src/contract.ts similarity index 100% rename from templates/contracts/ts/src/contract.ts rename to templates/contracts/javascript/src/contract.ts diff --git a/templates/contracts/ts/tsconfig.json b/templates/contracts/javascript/tsconfig.json similarity index 100% rename from templates/contracts/ts/tsconfig.json rename to templates/contracts/javascript/tsconfig.json diff --git a/templates/contracts/ts/yarn.lock b/templates/contracts/javascript/yarn.lock similarity index 100% rename from templates/contracts/ts/yarn.lock rename to templates/contracts/javascript/yarn.lock diff --git a/templates/contracts/rs/Cargo.lock b/templates/contracts/rust/Cargo.lock similarity index 100% rename from templates/contracts/rs/Cargo.lock rename to templates/contracts/rust/Cargo.lock diff --git a/templates/contracts/rs/Cargo.toml b/templates/contracts/rust/Cargo.toml similarity index 100% rename from templates/contracts/rs/Cargo.toml rename to templates/contracts/rust/Cargo.toml diff --git a/templates/contracts/rs/README.md b/templates/contracts/rust/README.md similarity index 100% rename from templates/contracts/rs/README.md rename to templates/contracts/rust/README.md diff --git a/templates/contracts/rs/rust-toolchain.toml b/templates/contracts/rust/rust-toolchain.toml similarity index 100% rename from templates/contracts/rs/rust-toolchain.toml rename to templates/contracts/rust/rust-toolchain.toml diff --git a/templates/contracts/rs/src/lib.rs b/templates/contracts/rust/src/lib.rs similarity index 100% rename from templates/contracts/rs/src/lib.rs rename to templates/contracts/rust/src/lib.rs diff --git a/templates/contracts/rs/tests/test_basics.rs b/templates/contracts/rust/tests/test_basics.rs similarity index 100% rename from templates/contracts/rs/tests/test_basics.rs rename to templates/contracts/rust/tests/test_basics.rs diff --git a/yarn.lock b/yarn.lock index 4a6693af3..d71e1226b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2112,13 +2112,6 @@ add-stream@^1.0.0: resolved "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz" integrity sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ== -agent-base@6: - version "6.0.2" - resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" - integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== - dependencies: - debug "4" - agent-base@^7.0.2, agent-base@^7.1.0, agent-base@^7.1.1: version "7.1.1" resolved "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz" @@ -2371,6 +2364,11 @@ async-retry@1.3.3: dependencies: retry "0.13.1" +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + available-typed-arrays@^1.0.7: version "1.0.7" resolved "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz" @@ -2383,6 +2381,15 @@ axe-core@=4.7.0: resolved "https://registry.npmjs.org/axe-core/-/axe-core-4.7.0.tgz" integrity sha512-M0JtH+hlOL5pLQwHOLNYZaXuhqmvS8oExsqB1SBYgA4Dk7u/xx+YdGHXaK5pyUfed5mYXdlYiphWq3G8cRi5JQ== +axios@^1.7.4: + version "1.7.7" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f" + integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + axobject-query@^3.2.1: version "3.2.1" resolved "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz" @@ -2837,6 +2844,13 @@ color-name@~1.1.4: resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + commander@^11.0.0: version "11.1.0" resolved "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz" @@ -3327,6 +3341,11 @@ degenerator@^4.0.4: esprima "^4.0.1" vm2 "^3.9.19" +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + deprecation@^2.0.0: version "2.3.1" resolved "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz" @@ -4019,6 +4038,11 @@ flatted@^3.2.9: resolved "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz" integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== +follow-redirects@^1.15.6: + version "1.15.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" + integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== + for-each@^0.3.3: version "0.3.3" resolved "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz" @@ -4031,6 +4055,15 @@ form-data-encoder@^2.1.2: resolved "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.1.4.tgz" integrity sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw== +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + formdata-polyfill@^4.0.10: version "4.0.10" resolved "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz" @@ -4413,14 +4446,6 @@ http2-wrapper@^2.1.10: quick-lru "^5.1.1" resolve-alpn "^1.2.0" -https-proxy-agent@5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz" - integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== - dependencies: - agent-base "6" - debug "4" - https-proxy-agent@^7.0.0: version "7.0.4" resolved "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz" @@ -5741,7 +5766,7 @@ mime-db@1.52.0: resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@2.1.35: +mime-types@2.1.35, mime-types@^2.1.12: version "2.1.35" resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -5794,13 +5819,6 @@ minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6: resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== -mixpanel@^0.18.0: - version "0.18.0" - resolved "https://registry.npmjs.org/mixpanel/-/mixpanel-0.18.0.tgz" - integrity sha512-VyUoiLB/S/7abYYHGD5x0LijeuJCUabG8Hb+FvYU3Y99xHf1Qh+s4/pH9lt50fRitAHncWbU1FE01EknUfVVjQ== - dependencies: - https-proxy-agent "5.0.0" - modify-values@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz" @@ -6306,6 +6324,14 @@ possible-typed-array-names@^1.0.0: resolved "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz" integrity sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q== +posthog-node@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/posthog-node/-/posthog-node-4.2.0.tgz#b7213200e12535ce60c9aaa26e8bd0470852ba19" + integrity sha512-hgyCYMyzMvuF3qWMw6JvS8gT55v7Mtp5wKWcnDrw+nu39D0Tk9BXD7I0LOBp0lGlHEPaXCEVYUtviNKrhMALGA== + dependencies: + axios "^1.7.4" + rusha "^0.8.14" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz" @@ -6752,6 +6778,11 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" +rusha@^0.8.14: + version "0.8.14" + resolved "https://registry.yarnpkg.com/rusha/-/rusha-0.8.14.tgz#a977d0de9428406138b7bb90d3de5dcd024e2f68" + integrity sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA== + rxjs@^7.8.1: version "7.8.1" resolved "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz" From 0c91b60c1d09c4400d2d38ed15e7a35814e37bae Mon Sep 17 00:00:00 2001 From: gagdiez Date: Fri, 27 Sep 2024 18:28:06 +0200 Subject: [PATCH 3/5] fix: maintain odl nomenclature --- src/messages.ts | 10 +++++----- src/types.ts | 4 ++-- src/user-input.ts | 4 ++-- templates/contracts/{rust => rs}/Cargo.lock | 0 templates/contracts/{rust => rs}/Cargo.toml | 0 templates/contracts/{rust => rs}/README.md | 0 templates/contracts/{rust => rs}/rust-toolchain.toml | 0 templates/contracts/{rust => rs}/src/lib.rs | 0 templates/contracts/{rust => rs}/tests/test_basics.rs | 0 templates/contracts/{javascript => ts}/README.md | 0 templates/contracts/{javascript => ts}/package.json | 0 .../{javascript => ts}/sandbox-test/main.ava.js | 0 templates/contracts/{javascript => ts}/src/contract.ts | 0 templates/contracts/{javascript => ts}/tsconfig.json | 0 templates/contracts/{javascript => ts}/yarn.lock | 0 test/__snapshots__/make.test.ts.snap | 8 ++++---- 16 files changed, 13 insertions(+), 13 deletions(-) rename templates/contracts/{rust => rs}/Cargo.lock (100%) rename templates/contracts/{rust => rs}/Cargo.toml (100%) rename templates/contracts/{rust => rs}/README.md (100%) rename templates/contracts/{rust => rs}/rust-toolchain.toml (100%) rename templates/contracts/{rust => rs}/src/lib.rs (100%) rename templates/contracts/{rust => rs}/tests/test_basics.rs (100%) rename templates/contracts/{javascript => ts}/README.md (100%) rename templates/contracts/{javascript => ts}/package.json (100%) rename templates/contracts/{javascript => ts}/sandbox-test/main.ava.js (100%) rename templates/contracts/{javascript => ts}/src/contract.ts (100%) rename templates/contracts/{javascript => ts}/tsconfig.json (100%) rename templates/contracts/{javascript => ts}/yarn.lock (100%) diff --git a/src/messages.ts b/src/messages.ts index c09c3a7f4..4865c7df2 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -27,7 +27,7 @@ export const successContractToText = (contract: Contract) => contract === 'none' ? '' : chalk`a smart contract in {bold ${ - contract === 'rust' ? 'Rust' : 'Typescript' + contract === 'rs' ? 'Rust' : 'Typescript' }}`; const frontendTemplates: FrontendMessage = { @@ -52,7 +52,7 @@ export const setupSuccess = ( contract )}${successFrontendToText(frontend)}. ${ - contract === 'rust' + contract === 'rs' ? chalk`🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}\n` : '' } @@ -74,20 +74,20 @@ export const contractInstructions = ( - {inverse Navigate to your project}: {blue cd {bold ${projectName}}} ${ - contract === 'javascript' && !install + contract === 'ts' && !install ? chalk` - {inverse Install all dependencies} {blue npm {bold install}}` : 'Then:' } - {inverse Build your contract}: ${ - contract === 'javascript' + contract === 'ts' ? chalk`{blue npm {bold run build}}` : chalk`{blue {bold cargo near build}}` } - {inverse Test your contract} in the Sandbox: ${ - contract === 'javascript' + contract === 'ts' ? chalk`{blue npm {bold run test}}` : chalk`{blue {bold cargo test}}` } diff --git a/src/types.ts b/src/types.ts index 216ec261a..197fdfe4b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ -export type Contract = 'javascript' | 'rust' | 'none'; -export const CONTRACTS: Contract[] = ['javascript', 'rust', 'none']; +export type Contract = 'ts' | 'rs' | 'none'; +export const CONTRACTS: Contract[] = ['ts', 'rs', 'none']; export type Frontend = 'next-app' | 'next-page' | 'none'; export const FRONTENDS: Frontend[] = ['next-app' , 'next-page', 'none']; diff --git a/src/user-input.ts b/src/user-input.ts index 758c749e2..39e9136b2 100644 --- a/src/user-input.ts +++ b/src/user-input.ts @@ -39,8 +39,8 @@ const appChoices: Choices = [ }, ]; const contractChoices: Choices = [ - { title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'javascript' }, - { title: 'Rust Contract', description: 'A Near contract written in Rust', value: 'rust' }, + { title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'ts' }, + { title: 'Rust Contract', description: 'A Near contract written in Rust', value: 'rs' }, ]; const frontendChoices: Choices = [ diff --git a/templates/contracts/rust/Cargo.lock b/templates/contracts/rs/Cargo.lock similarity index 100% rename from templates/contracts/rust/Cargo.lock rename to templates/contracts/rs/Cargo.lock diff --git a/templates/contracts/rust/Cargo.toml b/templates/contracts/rs/Cargo.toml similarity index 100% rename from templates/contracts/rust/Cargo.toml rename to templates/contracts/rs/Cargo.toml diff --git a/templates/contracts/rust/README.md b/templates/contracts/rs/README.md similarity index 100% rename from templates/contracts/rust/README.md rename to templates/contracts/rs/README.md diff --git a/templates/contracts/rust/rust-toolchain.toml b/templates/contracts/rs/rust-toolchain.toml similarity index 100% rename from templates/contracts/rust/rust-toolchain.toml rename to templates/contracts/rs/rust-toolchain.toml diff --git a/templates/contracts/rust/src/lib.rs b/templates/contracts/rs/src/lib.rs similarity index 100% rename from templates/contracts/rust/src/lib.rs rename to templates/contracts/rs/src/lib.rs diff --git a/templates/contracts/rust/tests/test_basics.rs b/templates/contracts/rs/tests/test_basics.rs similarity index 100% rename from templates/contracts/rust/tests/test_basics.rs rename to templates/contracts/rs/tests/test_basics.rs diff --git a/templates/contracts/javascript/README.md b/templates/contracts/ts/README.md similarity index 100% rename from templates/contracts/javascript/README.md rename to templates/contracts/ts/README.md diff --git a/templates/contracts/javascript/package.json b/templates/contracts/ts/package.json similarity index 100% rename from templates/contracts/javascript/package.json rename to templates/contracts/ts/package.json diff --git a/templates/contracts/javascript/sandbox-test/main.ava.js b/templates/contracts/ts/sandbox-test/main.ava.js similarity index 100% rename from templates/contracts/javascript/sandbox-test/main.ava.js rename to templates/contracts/ts/sandbox-test/main.ava.js diff --git a/templates/contracts/javascript/src/contract.ts b/templates/contracts/ts/src/contract.ts similarity index 100% rename from templates/contracts/javascript/src/contract.ts rename to templates/contracts/ts/src/contract.ts diff --git a/templates/contracts/javascript/tsconfig.json b/templates/contracts/ts/tsconfig.json similarity index 100% rename from templates/contracts/javascript/tsconfig.json rename to templates/contracts/ts/tsconfig.json diff --git a/templates/contracts/javascript/yarn.lock b/templates/contracts/ts/yarn.lock similarity index 100% rename from templates/contracts/javascript/yarn.lock rename to templates/contracts/ts/yarn.lock diff --git a/test/__snapshots__/make.test.ts.snap b/test/__snapshots__/make.test.ts.snap index 147ea0f69..9d8e66ce9 100644 --- a/test/__snapshots__/make.test.ts.snap +++ b/test/__snapshots__/make.test.ts.snap @@ -1054,11 +1054,11 @@ import { useEffect, useState } from 'react'; import '@/app/globals.css'; import { NearContext } from '@/context'; import { Navigation } from '@/components/navigation'; -import { NetworkId, HelloNearContract } from '@/config'; +import { NetworkId } from '@/config'; import { Wallet } from '@/wallets/near'; -const wallet = new Wallet({ networkId: NetworkId, createAccessKeyFor: HelloNearContract }); +const wallet = new Wallet({ networkId: NetworkId }); // Layout Component export default function RootLayout({ children }) { @@ -1773,9 +1773,9 @@ import { NearContext } from '@/context'; import { Navigation } from '@/components/navigation'; import { Wallet } from '@/wallets/near'; -import { NetworkId, HelloNearContract } from '@/config'; +import { NetworkId } from '@/config'; -const wallet = new Wallet({ createAccessKeyFor: HelloNearContract, networkId: NetworkId }); +const wallet = new Wallet({ networkId: NetworkId }); export default function MyApp({ Component, pageProps }) { const [signedAccountId, setSignedAccountId] = useState(''); From 3a16be076f39fa2ef8d3ba486093d2415989470d Mon Sep 17 00:00:00 2001 From: gagdiez Date: Fri, 27 Sep 2024 18:32:27 +0200 Subject: [PATCH 4/5] fix: add real public api key --- src/tracking.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracking.ts b/src/tracking.ts index 16a1b9b83..be0781137 100644 --- a/src/tracking.ts +++ b/src/tracking.ts @@ -1,7 +1,7 @@ import chalk from 'chalk'; import {Contract, Frontend, TrackingEventPayload} from './types'; -const POSTHOG_API_KEY = 'phc_bMxqEAiInwlq3FMyZvuFPZ8qdYuVwh9L5YfqRpeFk0I'; +const POSTHOG_API_KEY = 'phc_95PGQnbyatmj2TBRPWYfhbHfqB6wgZj5QRL8WY9gW20'; const POSTHOG_API_URL = 'https://eu.i.posthog.com/capture'; From f90b0673a2489b2d605c410cf945fd98e7b6fb9e Mon Sep 17 00:00:00 2001 From: gagdiez Date: Fri, 27 Sep 2024 18:33:04 +0200 Subject: [PATCH 5/5] fix: test --- .github/workflows/test-frontend.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml index 7a472d11d..850e86978 100644 --- a/.github/workflows/test-frontend.yml +++ b/.github/workflows/test-frontend.yml @@ -19,6 +19,4 @@ jobs: - name: Create Frontend No Components run: npm run start -- hello-near --frontend next-page - name: Install - run: cd hello-near && npm install - - name: Install - run: cd hello-components && npm install + run: cd hello-near && npm install \ No newline at end of file