├── .gitignore ├── README.md ├── package.json ├── LICENSE ├── createApp.js └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | node_modules/ 4 | .DS_Store 5 | npm-debug.log* 6 | yarn-debug.log* 7 | yarn-error.log* 8 | /.changelog 9 | .npm/ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Create React App 2 | 3 | ## Configure 4 | 5 | Get your `REACT_APP_CLIENT_SECRET` and `REACT_APP_CLIENT_SECRET` key from https://partners.aesirx.io by creating an account. 6 | 7 | ## Quick Overview 8 | 9 | ```sh 10 | npx create-aesirx-app 11 | ``` 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-aesirx-app", 3 | "version": "1.0.0", 4 | "keywords": [ 5 | "aesirx" 6 | ], 7 | "description": "Create AesirX apps with one command.", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/aesirxio/create-aesirx-app" 11 | }, 12 | "author": "AesirX", 13 | "license": "MIT", 14 | "engines": { 15 | "node": ">=14" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/aesirxio/create-aesirx-app/issues" 19 | }, 20 | "files": [ 21 | "index.js", 22 | "createApp.js" 23 | ], 24 | "bin": { 25 | "create-aesirx-app": "./index.js" 26 | }, 27 | "dependencies": { 28 | "chalk": "^4.1.2", 29 | "commander": "^4.1.1", 30 | "cross-spawn": "^7.0.3", 31 | "fs-extra": "^10.0.0", 32 | "prompts": "^2.4.2" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-present, Facebook, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /createApp.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const path = require("path"); 4 | const chalk = require("chalk"); 5 | const { execSync } = require("child_process"); 6 | const fs = require("fs-extra"); 7 | const spawn = require("cross-spawn"); 8 | 9 | async function createApp(res) { 10 | const root = path.resolve(res.path); 11 | 12 | console.log(); 13 | 14 | console.log( 15 | `Creating a new ${chalk.green(res.app)} app in ${chalk.green(root)}.` 16 | ); 17 | 18 | console.log(); 19 | 20 | switch (res.app) { 21 | case "AesirX DMA": 22 | execSync( 23 | `git clone -b master https://github.com/aesirxio/dma-app ${res.path}`, 24 | { 25 | stdio: "ignore", 26 | } 27 | ); 28 | break; 29 | 30 | case "AesirX DAM": 31 | execSync( 32 | `git clone -b master https://github.com/aesirxio/dam-app ${res.path}`, 33 | { 34 | stdio: "ignore", 35 | } 36 | ); 37 | break; 38 | 39 | default: 40 | break; 41 | } 42 | 43 | const env = `REACT_APP_CLIENT_ID=app 44 | REACT_APP_CLIENT_SECRET=${res.client_secret} 45 | REACT_APP_ENDPOINT_URL=https://api.aesirx.io 46 | REACT_APP_WEBSOCKET_ENDPOINT=https://ws.r.redweb.digital 47 | REACT_APP_ENCRYPT=encrypt 48 | REACT_APP_LICENSE=${res.license} 49 | REACT_APP_TEST_MODE=${res.test}`; 50 | 51 | fs.writeFileSync(path.join(root, ".env"), env); 52 | 53 | process.chdir(root); 54 | 55 | const command = "npm"; 56 | const args = [ 57 | "install", 58 | "--no-audit", 59 | "--save", 60 | "--save-exact", 61 | "--loglevel", 62 | "error", 63 | ]; 64 | 65 | const child = spawn(command, args, { stdio: "inherit" }); 66 | 67 | child.on("close", () => { 68 | console.log( 69 | `cd ${chalk.green(res.path)} and ${chalk.green(`npm run start`)}` 70 | ); 71 | 72 | process.exit(1); 73 | }); 74 | 75 | console.log(); 76 | } 77 | 78 | module.exports = createApp; 79 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | const chalk = require("chalk"); 6 | const prompts = require("prompts"); 7 | 8 | const createApp = require("./createApp"); 9 | const currentNodeVersion = process.versions.node; 10 | const semver = currentNodeVersion.split("."); 11 | const major = semver[0]; 12 | 13 | if (major < 14) { 14 | console.error( 15 | "You are running Node " + 16 | currentNodeVersion + 17 | ".\n" + 18 | "Create AesirX App requires Node 14 or higher. \n" + 19 | "Please update your version of Node." 20 | ); 21 | process.exit(1); 22 | } 23 | 24 | async function run() { 25 | const res = await prompts([ 26 | { 27 | type: "text", 28 | name: "path", 29 | message: "What is your project named?", 30 | initial: "my-app", 31 | }, 32 | { 33 | type: "select", 34 | name: "app", 35 | message: "What AesirX App do you want?", 36 | choices: [ 37 | { title: "AesirX DMA", value: "AesirX DMA" }, 38 | { title: "AesirX DAM", value: "AesirX DAM" }, 39 | ], 40 | initial: 0, 41 | }, 42 | { 43 | type: "text", 44 | name: "client_secret", 45 | message: "What is your REACT_APP_CLIENT_SECRET?", 46 | }, 47 | { 48 | type: "text", 49 | name: "license", 50 | message: "What is your REACT_APP_LICENSE?", 51 | }, 52 | { 53 | type: "select", 54 | name: "test", 55 | message: "Is it test mode?", 56 | choices: [ 57 | { title: "Yes", value: "true" }, 58 | { title: "No", value: "false" }, 59 | ], 60 | initial: 1, 61 | }, 62 | ]); 63 | 64 | try { 65 | await createApp(res); 66 | } catch (reason) { 67 | throw reason; 68 | } 69 | } 70 | 71 | run().catch(async (reason) => { 72 | console.log(); 73 | console.log("Aborting installation."); 74 | if (reason.command) { 75 | console.log(` ${chalk.cyan(reason.command)} has failed.`); 76 | } else { 77 | console.log( 78 | chalk.red("Unexpected error. Please report it as a bug:") + "\n", 79 | reason 80 | ); 81 | } 82 | console.log(); 83 | 84 | process.exit(1); 85 | }); 86 | --------------------------------------------------------------------------------