UNPKG

create-sellflow

Version:

Pre-built cross-platform Shopify app template

85 lines (68 loc) 2.1 kB
#! /usr/bin/env node const fs = require("fs"); const path = require("path"); const prompts = require("prompts"); const { execSync } = require("child_process"); (async () => { // 1. Ask for project name and options const response = await prompts([ { type: "text", name: "projectName", message: "What is your project named?", initial: "my-awesome-app", }, ]); const { projectName } = response; const targetDir = path.join(process.cwd(), projectName); // 2. Create project directory if (!fs.existsSync(targetDir)) { fs.mkdirSync(targetDir, { recursive: true }); } // 3. Copy template files const templateDir = path.join(__dirname, "../templates/basic"); copyDirectoryContents(templateDir, targetDir); // 4. Install dependencies console.log("Installing dependencies..."); execSync("npm install --legacy-peer-deps", { cwd: targetDir, stdio: "inherit", }); // 5. Success message console.log(` Success! Created ${projectName} at ${targetDir} Remember to set your environment variables: EXPO_PUBLIC_STORE_TOKEN= EXPO_PUBLIC_STORE_DOMAIN= EXPO_PUBLIC_ENCRYPTION_KEY= EXPO_PUBLIC_CUSTOMER_STORE_ENDPOINT= EXPO_PUBLIC_CUSTOMER_ACCOUNT_API_TOKEN= EXPO_PUBLIC_CUSTOMER_ACCOUNT_API_ENDPOINT= Inside that directory, you can run several commands: npm start Starts the development server npm run build Builds the app for production Full documentation can be found at https://github.com/sellflow/sellflow Begin by typing: cd ${projectName} npm start `); })().catch((error) => { console.error("Error: ", error); process.exit(1); }); function copyDirectoryContents(source, target) { const files = fs.readdirSync(source); files.forEach((file) => { const sourcePath = path.join(source, file); const targetPath = path.join(target, file); const stats = fs.statSync(sourcePath); if (stats.isDirectory()) { fs.mkdirSync(targetPath, { recursive: true }); copyDirectoryContents(sourcePath, targetPath); } else { fs.copyFileSync(sourcePath, targetPath); } }); }