diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81654c3..04782cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,12 @@ jobs: - name: install run: npm install - working-directory: ${{ matrix.example }} + working-directory: "examples/${{ matrix.example }}" - name: build run: npm run build - working-directory: ${{ matrix.example }} + working-directory: "examples/${{ matrix.example }}" - name: test run: npm run test --if-present - working-directory: ${{ matrix.example }} + working-directory: "examples/${{ matrix.example }}" diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index cb298ce..f280d9f 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -48,6 +48,7 @@ pipeline { stage('store-js') { steps { script { copyExample() } } } stage('light-js') { steps { script { copyExample() } } } stage('rln-js') { steps { script { copyExample() } } } + stage('light-chat') { steps { script { copyExample() } } } } } @@ -68,7 +69,7 @@ pipeline { def buildExample(example=STAGE_NAME) { def dest = "${WORKSPACE}/build/docs/${example}" - dir("${example}") { + dir("examples/${example}") { sh 'npm install --silent' sh 'npm run build' sh "mkdir -p ${dest}" @@ -78,6 +79,5 @@ def buildExample(example=STAGE_NAME) { def copyExample(example=STAGE_NAME) { sh "mkdir -p build/docs/${example}" - sh "cp ${example}/index.html build/docs/${example}/" - sh "[ -f ${example}/style.css ] && cp ${example}/style.css build/docs/${example}/ || exit 0" + sh "cp examples/${example}/*.(js|css|html) build/docs/${example}/" } diff --git a/packages/create-waku-app/.gitignore b/create-waku-app/.gitignore similarity index 100% rename from packages/create-waku-app/.gitignore rename to create-waku-app/.gitignore diff --git a/packages/create-waku-app/README.md b/create-waku-app/README.md similarity index 100% rename from packages/create-waku-app/README.md rename to create-waku-app/README.md diff --git a/create-waku-app/build.js b/create-waku-app/build.js new file mode 100644 index 0000000..05facc4 --- /dev/null +++ b/create-waku-app/build.js @@ -0,0 +1,29 @@ +#!/usr/bin/env node +const path = require("path"); +const fs = require("fs-extra"); + +const examplesSource = path.resolve(__dirname, "../examples"); +const examplesDestination = path.resolve(__dirname, "./examples"); + +function run() { + fs.ensureDirSync(examplesDestination); + + try { + console.log("Started copying supported Waku examples."); + fs.copySync(examplesSource, examplesDestination, { filter: nodeModulesFiler }); + console.log("Finished copying examples."); + } catch (error) { + console.error("Failed to copy examples due to " + error.message); + throw Error(error.message); + } +} + +function nodeModulesFiler(src) { + if (src.includes("node_modules")) { + return false; + } + + return true; +} + +run(); diff --git a/create-waku-app/createApp.js b/create-waku-app/createApp.js new file mode 100644 index 0000000..59c3244 --- /dev/null +++ b/create-waku-app/createApp.js @@ -0,0 +1,178 @@ +const path = require("path"); +const fs = require("fs-extra"); +const enquirer = require("enquirer"); +const execSync = require("child_process").execSync; + +const { Command } = require("commander"); +const validateProjectName = require("validate-npm-package-name"); + +const DEFAULT_EXAMPLE = "light-chat"; + +const supportedExamplesDir = path.resolve(__dirname, "./examples"); +const supportedExamples = readDirNames(supportedExamplesDir); + +const init = async (name, description, version) => { + let appName; + let template; + + const options = new Command() + .name(name) + .description(description) + .version(version, "-v, --version", "output the version number") + .arguments( + "", + "Project directory to initialize Waku app" + ) + .action((_appName) => { + appName = _appName; + }) + .option( + "-t, --template ", + "specify a template for the created project or you can use the wizard." + ) + .allowUnknownOption() + .parse() + .opts(); + + template = options.template; + + if (!template) { + const templatePrompt = new enquirer.Select({ + name: "template", + message: "Select template", + choices: buildChoices(supportedExamples), + }); + + try { + template = await templatePrompt.run(); + } catch (e) { + console.error(`Failed at selecting a template: ${e.message}`); + process.exit(1); + } + } + + if (!supportedExamples[template]) { + const supportedExamplesMessage = Object.keys(supportedExamples).reduce( + (acc, v) => { + acc += `\t${v}\n`; + return acc; + }, + "" + ); + + console.error(`Unknown template: ${template}`); + console.error( + `We support only following templates:\n${supportedExamplesMessage}` + ); + process.exit(1); + } + + createApp(appName, template); +}; + +function createApp(name, template) { + const appRoot = path.resolve(name); + const appName = path.basename(appRoot); + + const templateDir = path.resolve(supportedExamplesDir, template); + + terminateIfAppExists(appName); + terminateIfProjectNameInvalid(appName); + + console.log(`Initializing ${appName} from ${template} template.`); + + fs.ensureDirSync(appName); + fs.copySync(templateDir, appRoot); + + runNpmInApp(appRoot); + runGitInit(appRoot); +} + +function runNpmInApp(root) { + const packageJsonPath = path.resolve(root, "package.json"); + + if (!fs.existsSync(packageJsonPath)) { + return; + } + + console.log("Installing npm packages."); + try { + execSync(`npm install --prefix ${root}`, { stdio: "ignore" }); + console.log("Successfully installed npm dependencies."); + } catch (e) { + console.warn("Failed to install npm dependencies", e); + } +} + +function runGitInit(root) { + if (isInGitRepository()) { + return; + } + + console.log("Initiating git repository."); + try { + execSync(`git init ${root}`, { stdio: "ignore" }); + console.log("Successfully initialized git repo."); + } catch (e) { + console.warn("Git repo not initialized", e); + } +} + +function isInGitRepository() { + try { + execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" }); + return true; + } catch (e) { + return false; + } +} + +function terminateIfProjectNameInvalid(name) { + const validationResult = validateProjectName(name); + + if (!validationResult.validForNewPackages) { + console.error( + `Cannot create a project named ${name} because of npm naming restrictions:\n` + ); + [ + ...(validationResult.errors || []), + ...(validationResult.warnings || []), + ].forEach((error) => console.error(` * ${error}`)); + console.error("\nPlease choose a different project name."); + process.exit(1); + } +} + +function terminateIfAppExists(appRoot) { + if (fs.existsSync(appRoot)) { + console.error( + `Cannot create a project because it already exists by the name: ${appRoot}` + ); + process.exit(1); + } +} + +function readDirNames(target) { + return fs + .readdirSync(target, { withFileTypes: true }) + .filter((dir) => dir.isDirectory()) + .map((dir) => dir.name) + .reduce((acc, name) => { + acc[name] = path.resolve(target, name); + return acc; + }, {}); +} + +function buildChoices(examples) { + // handle a case if default example will be deleted without updating this place + if (!examples[DEFAULT_EXAMPLE]) { + return Object.keys(examples); + } + + return [ + DEFAULT_EXAMPLE, + ...Object.keys(examples).filter((v) => v !== DEFAULT_EXAMPLE), + ]; +} + +module.exports = { init }; diff --git a/packages/create-waku-app/index.js b/create-waku-app/index.js similarity index 94% rename from packages/create-waku-app/index.js rename to create-waku-app/index.js index c8bd301..db5ae19 100644 --- a/packages/create-waku-app/index.js +++ b/create-waku-app/index.js @@ -16,4 +16,4 @@ if (!semver.satisfies(currentNodeVersion, supportedNodeVersion)) { const { init } = require("./createApp"); -init(packageJson.name, packageJson.description, packageJson.version, packageJson.wakuExamples); +init(packageJson.name, packageJson.description, packageJson.version); diff --git a/packages/create-waku-app/package-lock.json b/create-waku-app/package-lock.json similarity index 100% rename from packages/create-waku-app/package-lock.json rename to create-waku-app/package-lock.json diff --git a/packages/create-waku-app/package.json b/create-waku-app/package.json similarity index 70% rename from packages/create-waku-app/package.json rename to create-waku-app/package.json index 11e1269..e592a92 100644 --- a/packages/create-waku-app/package.json +++ b/create-waku-app/package.json @@ -35,19 +35,9 @@ "dapps" ], "license": "MIT OR Apache-2.0", - "wakuExamples": { - "eth-pm": "../../eth-pm", - "light-js": "../../light-js", - "relay-angular-chat": "../../relay-angular-chat", - "relay-js": "../../relay-js", - "relay-reactjs-chat": "../../relay-reactjs-chat", - "rln-js": "../../rln-js", - "store-js": "../../store-js", - "store-reactjs-chat": "../../store-reactjs-chat", - "web-chat": "../../web-chat" - }, "dependencies": { "commander": "^9.4.1", + "enquirer": "^2.3.6", "fs-extra": "^11.1.0", "semver": "^7.3.8", "validate-npm-package-name": "^5.0.0" diff --git a/.cspell.json b/examples/eth-pm/.cspell.json similarity index 100% rename from .cspell.json rename to examples/eth-pm/.cspell.json diff --git a/eth-pm/.env b/examples/eth-pm/.env similarity index 100% rename from eth-pm/.env rename to examples/eth-pm/.env diff --git a/eth-pm/.gitignore b/examples/eth-pm/.gitignore similarity index 100% rename from eth-pm/.gitignore rename to examples/eth-pm/.gitignore diff --git a/eth-pm/.npmrc b/examples/eth-pm/.npmrc similarity index 100% rename from eth-pm/.npmrc rename to examples/eth-pm/.npmrc diff --git a/eth-pm/README.md b/examples/eth-pm/README.md similarity index 100% rename from eth-pm/README.md rename to examples/eth-pm/README.md diff --git a/eth-pm/craco.config.js b/examples/eth-pm/craco.config.js similarity index 100% rename from eth-pm/craco.config.js rename to examples/eth-pm/craco.config.js diff --git a/eth-pm/package-lock.json b/examples/eth-pm/package-lock.json similarity index 99% rename from eth-pm/package-lock.json rename to examples/eth-pm/package-lock.json index 214f8fd..31f3fff 100644 --- a/eth-pm/package-lock.json +++ b/examples/eth-pm/package-lock.json @@ -16606,6 +16606,7 @@ "version": "8.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -16642,6 +16643,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -16650,6 +16652,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz", "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", + "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, @@ -22429,6 +22432,7 @@ "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, "dependencies": { "minimist": "^1.2.6" }, @@ -47798,6 +47802,7 @@ "version": "8.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -47810,6 +47815,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, "requires": { "balanced-match": "^1.0.0" } @@ -47818,6 +47824,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz", "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", + "dev": true, "requires": { "brace-expansion": "^2.0.1" } @@ -52005,6 +52012,7 @@ "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, "requires": { "minimist": "^1.2.6" } diff --git a/eth-pm/package.json b/examples/eth-pm/package.json similarity index 98% rename from eth-pm/package.json rename to examples/eth-pm/package.json index 45f009d..47f30b8 100644 --- a/eth-pm/package.json +++ b/examples/eth-pm/package.json @@ -27,7 +27,7 @@ "test": "run-s build test:*", "test:lint": "eslint src --ext .ts --ext .tsx", "test:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --list-different", - "test:spelling": "cspell \"{README.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ../.cspell.json", + "test:spelling": "cspell \"{README.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ./.cspell.json", "fix:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --write", "fix:lint": "eslint src --ext .ts --ext .tsx --fix" }, diff --git a/eth-pm/public/favicon.ico b/examples/eth-pm/public/favicon.ico similarity index 100% rename from eth-pm/public/favicon.ico rename to examples/eth-pm/public/favicon.ico diff --git a/eth-pm/public/favicon.png b/examples/eth-pm/public/favicon.png similarity index 100% rename from eth-pm/public/favicon.png rename to examples/eth-pm/public/favicon.png diff --git a/eth-pm/public/index.html b/examples/eth-pm/public/index.html similarity index 100% rename from eth-pm/public/index.html rename to examples/eth-pm/public/index.html diff --git a/eth-pm/public/manifest.json b/examples/eth-pm/public/manifest.json similarity index 100% rename from eth-pm/public/manifest.json rename to examples/eth-pm/public/manifest.json diff --git a/eth-pm/public/robots.txt b/examples/eth-pm/public/robots.txt similarity index 100% rename from eth-pm/public/robots.txt rename to examples/eth-pm/public/robots.txt diff --git a/eth-pm/src/App.css b/examples/eth-pm/src/App.css similarity index 100% rename from eth-pm/src/App.css rename to examples/eth-pm/src/App.css diff --git a/eth-pm/src/App.tsx b/examples/eth-pm/src/App.tsx similarity index 100% rename from eth-pm/src/App.tsx rename to examples/eth-pm/src/App.tsx diff --git a/eth-pm/src/BroadcastPublicKey.tsx b/examples/eth-pm/src/BroadcastPublicKey.tsx similarity index 100% rename from eth-pm/src/BroadcastPublicKey.tsx rename to examples/eth-pm/src/BroadcastPublicKey.tsx diff --git a/eth-pm/src/ConnectWallet.tsx b/examples/eth-pm/src/ConnectWallet.tsx similarity index 100% rename from eth-pm/src/ConnectWallet.tsx rename to examples/eth-pm/src/ConnectWallet.tsx diff --git a/eth-pm/src/crypto.ts b/examples/eth-pm/src/crypto.ts similarity index 100% rename from eth-pm/src/crypto.ts rename to examples/eth-pm/src/crypto.ts diff --git a/eth-pm/src/index.css b/examples/eth-pm/src/index.css similarity index 100% rename from eth-pm/src/index.css rename to examples/eth-pm/src/index.css diff --git a/eth-pm/src/index.tsx b/examples/eth-pm/src/index.tsx similarity index 100% rename from eth-pm/src/index.tsx rename to examples/eth-pm/src/index.tsx diff --git a/eth-pm/src/key_pair_handling/KeyPairHandling.tsx b/examples/eth-pm/src/key_pair_handling/KeyPairHandling.tsx similarity index 100% rename from eth-pm/src/key_pair_handling/KeyPairHandling.tsx rename to examples/eth-pm/src/key_pair_handling/KeyPairHandling.tsx diff --git a/eth-pm/src/key_pair_handling/LoadKeyPair.tsx b/examples/eth-pm/src/key_pair_handling/LoadKeyPair.tsx similarity index 100% rename from eth-pm/src/key_pair_handling/LoadKeyPair.tsx rename to examples/eth-pm/src/key_pair_handling/LoadKeyPair.tsx diff --git a/eth-pm/src/key_pair_handling/PasswordInput.tsx b/examples/eth-pm/src/key_pair_handling/PasswordInput.tsx similarity index 100% rename from eth-pm/src/key_pair_handling/PasswordInput.tsx rename to examples/eth-pm/src/key_pair_handling/PasswordInput.tsx diff --git a/eth-pm/src/key_pair_handling/SaveKeyPair.tsx b/examples/eth-pm/src/key_pair_handling/SaveKeyPair.tsx similarity index 100% rename from eth-pm/src/key_pair_handling/SaveKeyPair.tsx rename to examples/eth-pm/src/key_pair_handling/SaveKeyPair.tsx diff --git a/eth-pm/src/key_pair_handling/key_pair_storage.ts b/examples/eth-pm/src/key_pair_handling/key_pair_storage.ts similarity index 100% rename from eth-pm/src/key_pair_handling/key_pair_storage.ts rename to examples/eth-pm/src/key_pair_handling/key_pair_storage.ts diff --git a/eth-pm/src/logo.svg b/examples/eth-pm/src/logo.svg similarity index 100% rename from eth-pm/src/logo.svg rename to examples/eth-pm/src/logo.svg diff --git a/eth-pm/src/messaging/Messages.tsx b/examples/eth-pm/src/messaging/Messages.tsx similarity index 100% rename from eth-pm/src/messaging/Messages.tsx rename to examples/eth-pm/src/messaging/Messages.tsx diff --git a/eth-pm/src/messaging/Messaging.tsx b/examples/eth-pm/src/messaging/Messaging.tsx similarity index 100% rename from eth-pm/src/messaging/Messaging.tsx rename to examples/eth-pm/src/messaging/Messaging.tsx diff --git a/eth-pm/src/messaging/SendMessage.tsx b/examples/eth-pm/src/messaging/SendMessage.tsx similarity index 100% rename from eth-pm/src/messaging/SendMessage.tsx rename to examples/eth-pm/src/messaging/SendMessage.tsx diff --git a/eth-pm/src/messaging/wire.ts b/examples/eth-pm/src/messaging/wire.ts similarity index 100% rename from eth-pm/src/messaging/wire.ts rename to examples/eth-pm/src/messaging/wire.ts diff --git a/eth-pm/src/react-app-env.d.ts b/examples/eth-pm/src/react-app-env.d.ts similarity index 100% rename from eth-pm/src/react-app-env.d.ts rename to examples/eth-pm/src/react-app-env.d.ts diff --git a/eth-pm/src/setupTests.ts b/examples/eth-pm/src/setupTests.ts similarity index 100% rename from eth-pm/src/setupTests.ts rename to examples/eth-pm/src/setupTests.ts diff --git a/eth-pm/src/waku.ts b/examples/eth-pm/src/waku.ts similarity index 100% rename from eth-pm/src/waku.ts rename to examples/eth-pm/src/waku.ts diff --git a/eth-pm/tsconfig.json b/examples/eth-pm/tsconfig.json similarity index 100% rename from eth-pm/tsconfig.json rename to examples/eth-pm/tsconfig.json diff --git a/light-chat/favicon.ico b/examples/light-chat/favicon.ico similarity index 100% rename from light-chat/favicon.ico rename to examples/light-chat/favicon.ico diff --git a/light-chat/favicon.png b/examples/light-chat/favicon.png similarity index 100% rename from light-chat/favicon.png rename to examples/light-chat/favicon.png diff --git a/light-chat/index.html b/examples/light-chat/index.html similarity index 100% rename from light-chat/index.html rename to examples/light-chat/index.html diff --git a/light-chat/index.js b/examples/light-chat/index.js similarity index 100% rename from light-chat/index.js rename to examples/light-chat/index.js diff --git a/light-chat/manifest.json b/examples/light-chat/manifest.json similarity index 100% rename from light-chat/manifest.json rename to examples/light-chat/manifest.json diff --git a/light-chat/package-lock.json b/examples/light-chat/package-lock.json similarity index 100% rename from light-chat/package-lock.json rename to examples/light-chat/package-lock.json diff --git a/light-chat/package.json b/examples/light-chat/package.json similarity index 100% rename from light-chat/package.json rename to examples/light-chat/package.json diff --git a/light-chat/style.css b/examples/light-chat/style.css similarity index 100% rename from light-chat/style.css rename to examples/light-chat/style.css diff --git a/light-js/README.md b/examples/light-js/README.md similarity index 100% rename from light-js/README.md rename to examples/light-js/README.md diff --git a/light-js/favicon.ico b/examples/light-js/favicon.ico similarity index 100% rename from light-js/favicon.ico rename to examples/light-js/favicon.ico diff --git a/light-js/favicon.png b/examples/light-js/favicon.png similarity index 100% rename from light-js/favicon.png rename to examples/light-js/favicon.png diff --git a/light-js/index.html b/examples/light-js/index.html similarity index 100% rename from light-js/index.html rename to examples/light-js/index.html diff --git a/light-js/manifest.json b/examples/light-js/manifest.json similarity index 100% rename from light-js/manifest.json rename to examples/light-js/manifest.json diff --git a/relay-angular-chat/.gitignore b/examples/relay-angular-chat/.gitignore similarity index 100% rename from relay-angular-chat/.gitignore rename to examples/relay-angular-chat/.gitignore diff --git a/relay-angular-chat/README.md b/examples/relay-angular-chat/README.md similarity index 100% rename from relay-angular-chat/README.md rename to examples/relay-angular-chat/README.md diff --git a/relay-angular-chat/angular.json b/examples/relay-angular-chat/angular.json similarity index 100% rename from relay-angular-chat/angular.json rename to examples/relay-angular-chat/angular.json diff --git a/relay-angular-chat/karma.conf.js b/examples/relay-angular-chat/karma.conf.js similarity index 100% rename from relay-angular-chat/karma.conf.js rename to examples/relay-angular-chat/karma.conf.js diff --git a/relay-angular-chat/package-lock.json b/examples/relay-angular-chat/package-lock.json similarity index 100% rename from relay-angular-chat/package-lock.json rename to examples/relay-angular-chat/package-lock.json diff --git a/relay-angular-chat/package.json b/examples/relay-angular-chat/package.json similarity index 100% rename from relay-angular-chat/package.json rename to examples/relay-angular-chat/package.json diff --git a/relay-angular-chat/src/@types/protons/types.d.ts b/examples/relay-angular-chat/src/@types/protons/types.d.ts similarity index 100% rename from relay-angular-chat/src/@types/protons/types.d.ts rename to examples/relay-angular-chat/src/@types/protons/types.d.ts diff --git a/relay-angular-chat/src/@types/time-cache/types.d.ts b/examples/relay-angular-chat/src/@types/time-cache/types.d.ts similarity index 100% rename from relay-angular-chat/src/@types/time-cache/types.d.ts rename to examples/relay-angular-chat/src/@types/time-cache/types.d.ts diff --git a/relay-angular-chat/src/app/app.component.css b/examples/relay-angular-chat/src/app/app.component.css similarity index 100% rename from relay-angular-chat/src/app/app.component.css rename to examples/relay-angular-chat/src/app/app.component.css diff --git a/relay-angular-chat/src/app/app.component.html b/examples/relay-angular-chat/src/app/app.component.html similarity index 100% rename from relay-angular-chat/src/app/app.component.html rename to examples/relay-angular-chat/src/app/app.component.html diff --git a/relay-angular-chat/src/app/app.component.spec.ts b/examples/relay-angular-chat/src/app/app.component.spec.ts similarity index 100% rename from relay-angular-chat/src/app/app.component.spec.ts rename to examples/relay-angular-chat/src/app/app.component.spec.ts diff --git a/relay-angular-chat/src/app/app.component.ts b/examples/relay-angular-chat/src/app/app.component.ts similarity index 100% rename from relay-angular-chat/src/app/app.component.ts rename to examples/relay-angular-chat/src/app/app.component.ts diff --git a/relay-angular-chat/src/app/app.module.ts b/examples/relay-angular-chat/src/app/app.module.ts similarity index 100% rename from relay-angular-chat/src/app/app.module.ts rename to examples/relay-angular-chat/src/app/app.module.ts diff --git a/relay-angular-chat/src/app/messages/messages.component.css b/examples/relay-angular-chat/src/app/messages/messages.component.css similarity index 100% rename from relay-angular-chat/src/app/messages/messages.component.css rename to examples/relay-angular-chat/src/app/messages/messages.component.css diff --git a/relay-angular-chat/src/app/messages/messages.component.html b/examples/relay-angular-chat/src/app/messages/messages.component.html similarity index 100% rename from relay-angular-chat/src/app/messages/messages.component.html rename to examples/relay-angular-chat/src/app/messages/messages.component.html diff --git a/relay-angular-chat/src/app/messages/messages.component.spec.ts b/examples/relay-angular-chat/src/app/messages/messages.component.spec.ts similarity index 100% rename from relay-angular-chat/src/app/messages/messages.component.spec.ts rename to examples/relay-angular-chat/src/app/messages/messages.component.spec.ts diff --git a/relay-angular-chat/src/app/messages/messages.component.ts b/examples/relay-angular-chat/src/app/messages/messages.component.ts similarity index 100% rename from relay-angular-chat/src/app/messages/messages.component.ts rename to examples/relay-angular-chat/src/app/messages/messages.component.ts diff --git a/relay-angular-chat/src/app/waku.service.spec.ts b/examples/relay-angular-chat/src/app/waku.service.spec.ts similarity index 100% rename from relay-angular-chat/src/app/waku.service.spec.ts rename to examples/relay-angular-chat/src/app/waku.service.spec.ts diff --git a/relay-angular-chat/src/app/waku.service.ts b/examples/relay-angular-chat/src/app/waku.service.ts similarity index 100% rename from relay-angular-chat/src/app/waku.service.ts rename to examples/relay-angular-chat/src/app/waku.service.ts diff --git a/relay-angular-chat/src/assets/.gitkeep b/examples/relay-angular-chat/src/assets/.gitkeep similarity index 100% rename from relay-angular-chat/src/assets/.gitkeep rename to examples/relay-angular-chat/src/assets/.gitkeep diff --git a/relay-angular-chat/src/environments/environment.prod.ts b/examples/relay-angular-chat/src/environments/environment.prod.ts similarity index 100% rename from relay-angular-chat/src/environments/environment.prod.ts rename to examples/relay-angular-chat/src/environments/environment.prod.ts diff --git a/relay-angular-chat/src/environments/environment.ts b/examples/relay-angular-chat/src/environments/environment.ts similarity index 100% rename from relay-angular-chat/src/environments/environment.ts rename to examples/relay-angular-chat/src/environments/environment.ts diff --git a/relay-angular-chat/src/favicon.ico b/examples/relay-angular-chat/src/favicon.ico similarity index 100% rename from relay-angular-chat/src/favicon.ico rename to examples/relay-angular-chat/src/favicon.ico diff --git a/relay-angular-chat/src/favicon.png b/examples/relay-angular-chat/src/favicon.png similarity index 100% rename from relay-angular-chat/src/favicon.png rename to examples/relay-angular-chat/src/favicon.png diff --git a/relay-angular-chat/src/index.html b/examples/relay-angular-chat/src/index.html similarity index 100% rename from relay-angular-chat/src/index.html rename to examples/relay-angular-chat/src/index.html diff --git a/relay-angular-chat/src/main.ts b/examples/relay-angular-chat/src/main.ts similarity index 100% rename from relay-angular-chat/src/main.ts rename to examples/relay-angular-chat/src/main.ts diff --git a/relay-angular-chat/src/manifest.json b/examples/relay-angular-chat/src/manifest.json similarity index 100% rename from relay-angular-chat/src/manifest.json rename to examples/relay-angular-chat/src/manifest.json diff --git a/relay-angular-chat/src/styles.css b/examples/relay-angular-chat/src/styles.css similarity index 100% rename from relay-angular-chat/src/styles.css rename to examples/relay-angular-chat/src/styles.css diff --git a/relay-angular-chat/src/test.ts b/examples/relay-angular-chat/src/test.ts similarity index 100% rename from relay-angular-chat/src/test.ts rename to examples/relay-angular-chat/src/test.ts diff --git a/relay-angular-chat/tsconfig.app.json b/examples/relay-angular-chat/tsconfig.app.json similarity index 100% rename from relay-angular-chat/tsconfig.app.json rename to examples/relay-angular-chat/tsconfig.app.json diff --git a/relay-angular-chat/tsconfig.json b/examples/relay-angular-chat/tsconfig.json similarity index 100% rename from relay-angular-chat/tsconfig.json rename to examples/relay-angular-chat/tsconfig.json diff --git a/relay-angular-chat/tsconfig.spec.json b/examples/relay-angular-chat/tsconfig.spec.json similarity index 100% rename from relay-angular-chat/tsconfig.spec.json rename to examples/relay-angular-chat/tsconfig.spec.json diff --git a/relay-js/README.md b/examples/relay-js/README.md similarity index 100% rename from relay-js/README.md rename to examples/relay-js/README.md diff --git a/relay-js/favicon.ico b/examples/relay-js/favicon.ico similarity index 100% rename from relay-js/favicon.ico rename to examples/relay-js/favicon.ico diff --git a/relay-js/favicon.png b/examples/relay-js/favicon.png similarity index 100% rename from relay-js/favicon.png rename to examples/relay-js/favicon.png diff --git a/relay-js/index.html b/examples/relay-js/index.html similarity index 100% rename from relay-js/index.html rename to examples/relay-js/index.html diff --git a/relay-js/manifest.json b/examples/relay-js/manifest.json similarity index 100% rename from relay-js/manifest.json rename to examples/relay-js/manifest.json diff --git a/relay-reactjs-chat/.gitignore b/examples/relay-reactjs-chat/.gitignore similarity index 100% rename from relay-reactjs-chat/.gitignore rename to examples/relay-reactjs-chat/.gitignore diff --git a/relay-reactjs-chat/.npmrc b/examples/relay-reactjs-chat/.npmrc similarity index 100% rename from relay-reactjs-chat/.npmrc rename to examples/relay-reactjs-chat/.npmrc diff --git a/relay-reactjs-chat/README.md b/examples/relay-reactjs-chat/README.md similarity index 100% rename from relay-reactjs-chat/README.md rename to examples/relay-reactjs-chat/README.md diff --git a/relay-reactjs-chat/craco.config.js b/examples/relay-reactjs-chat/craco.config.js similarity index 100% rename from relay-reactjs-chat/craco.config.js rename to examples/relay-reactjs-chat/craco.config.js diff --git a/relay-reactjs-chat/package-lock.json b/examples/relay-reactjs-chat/package-lock.json similarity index 100% rename from relay-reactjs-chat/package-lock.json rename to examples/relay-reactjs-chat/package-lock.json diff --git a/relay-reactjs-chat/package.json b/examples/relay-reactjs-chat/package.json similarity index 100% rename from relay-reactjs-chat/package.json rename to examples/relay-reactjs-chat/package.json diff --git a/relay-reactjs-chat/public/favicon.ico b/examples/relay-reactjs-chat/public/favicon.ico similarity index 100% rename from relay-reactjs-chat/public/favicon.ico rename to examples/relay-reactjs-chat/public/favicon.ico diff --git a/relay-reactjs-chat/public/favicon.png b/examples/relay-reactjs-chat/public/favicon.png similarity index 100% rename from relay-reactjs-chat/public/favicon.png rename to examples/relay-reactjs-chat/public/favicon.png diff --git a/relay-reactjs-chat/public/index.html b/examples/relay-reactjs-chat/public/index.html similarity index 100% rename from relay-reactjs-chat/public/index.html rename to examples/relay-reactjs-chat/public/index.html diff --git a/relay-reactjs-chat/public/manifest.json b/examples/relay-reactjs-chat/public/manifest.json similarity index 100% rename from relay-reactjs-chat/public/manifest.json rename to examples/relay-reactjs-chat/public/manifest.json diff --git a/relay-reactjs-chat/public/robots.txt b/examples/relay-reactjs-chat/public/robots.txt similarity index 100% rename from relay-reactjs-chat/public/robots.txt rename to examples/relay-reactjs-chat/public/robots.txt diff --git a/relay-reactjs-chat/src/App.css b/examples/relay-reactjs-chat/src/App.css similarity index 100% rename from relay-reactjs-chat/src/App.css rename to examples/relay-reactjs-chat/src/App.css diff --git a/relay-reactjs-chat/src/App.js b/examples/relay-reactjs-chat/src/App.js similarity index 100% rename from relay-reactjs-chat/src/App.js rename to examples/relay-reactjs-chat/src/App.js diff --git a/relay-reactjs-chat/src/App.test.js b/examples/relay-reactjs-chat/src/App.test.js similarity index 100% rename from relay-reactjs-chat/src/App.test.js rename to examples/relay-reactjs-chat/src/App.test.js diff --git a/relay-reactjs-chat/src/index.css b/examples/relay-reactjs-chat/src/index.css similarity index 100% rename from relay-reactjs-chat/src/index.css rename to examples/relay-reactjs-chat/src/index.css diff --git a/relay-reactjs-chat/src/index.js b/examples/relay-reactjs-chat/src/index.js similarity index 100% rename from relay-reactjs-chat/src/index.js rename to examples/relay-reactjs-chat/src/index.js diff --git a/relay-reactjs-chat/src/logo.svg b/examples/relay-reactjs-chat/src/logo.svg similarity index 100% rename from relay-reactjs-chat/src/logo.svg rename to examples/relay-reactjs-chat/src/logo.svg diff --git a/relay-reactjs-chat/src/setupTests.js b/examples/relay-reactjs-chat/src/setupTests.js similarity index 100% rename from relay-reactjs-chat/src/setupTests.js rename to examples/relay-reactjs-chat/src/setupTests.js diff --git a/rln-js/README.md b/examples/rln-js/README.md similarity index 100% rename from rln-js/README.md rename to examples/rln-js/README.md diff --git a/rln-js/favicon.ico b/examples/rln-js/favicon.ico similarity index 100% rename from rln-js/favicon.ico rename to examples/rln-js/favicon.ico diff --git a/rln-js/favicon.png b/examples/rln-js/favicon.png similarity index 100% rename from rln-js/favicon.png rename to examples/rln-js/favicon.png diff --git a/rln-js/index.html b/examples/rln-js/index.html similarity index 100% rename from rln-js/index.html rename to examples/rln-js/index.html diff --git a/rln-js/manifest.json b/examples/rln-js/manifest.json similarity index 100% rename from rln-js/manifest.json rename to examples/rln-js/manifest.json diff --git a/rln-js/package-lock.json b/examples/rln-js/package-lock.json similarity index 100% rename from rln-js/package-lock.json rename to examples/rln-js/package-lock.json diff --git a/rln-js/package.json b/examples/rln-js/package.json similarity index 100% rename from rln-js/package.json rename to examples/rln-js/package.json diff --git a/rln-js/style.css b/examples/rln-js/style.css similarity index 100% rename from rln-js/style.css rename to examples/rln-js/style.css diff --git a/store-js/README.md b/examples/store-js/README.md similarity index 100% rename from store-js/README.md rename to examples/store-js/README.md diff --git a/store-js/favicon.ico b/examples/store-js/favicon.ico similarity index 100% rename from store-js/favicon.ico rename to examples/store-js/favicon.ico diff --git a/store-js/favicon.png b/examples/store-js/favicon.png similarity index 100% rename from store-js/favicon.png rename to examples/store-js/favicon.png diff --git a/store-js/index.html b/examples/store-js/index.html similarity index 100% rename from store-js/index.html rename to examples/store-js/index.html diff --git a/store-js/manifest.json b/examples/store-js/manifest.json similarity index 100% rename from store-js/manifest.json rename to examples/store-js/manifest.json diff --git a/store-reactjs-chat/.gitignore b/examples/store-reactjs-chat/.gitignore similarity index 100% rename from store-reactjs-chat/.gitignore rename to examples/store-reactjs-chat/.gitignore diff --git a/store-reactjs-chat/README.md b/examples/store-reactjs-chat/README.md similarity index 100% rename from store-reactjs-chat/README.md rename to examples/store-reactjs-chat/README.md diff --git a/store-reactjs-chat/package-lock.json b/examples/store-reactjs-chat/package-lock.json similarity index 100% rename from store-reactjs-chat/package-lock.json rename to examples/store-reactjs-chat/package-lock.json diff --git a/store-reactjs-chat/package.json b/examples/store-reactjs-chat/package.json similarity index 100% rename from store-reactjs-chat/package.json rename to examples/store-reactjs-chat/package.json diff --git a/store-reactjs-chat/public/favicon.ico b/examples/store-reactjs-chat/public/favicon.ico similarity index 100% rename from store-reactjs-chat/public/favicon.ico rename to examples/store-reactjs-chat/public/favicon.ico diff --git a/store-reactjs-chat/public/favicon.png b/examples/store-reactjs-chat/public/favicon.png similarity index 100% rename from store-reactjs-chat/public/favicon.png rename to examples/store-reactjs-chat/public/favicon.png diff --git a/store-reactjs-chat/public/index.html b/examples/store-reactjs-chat/public/index.html similarity index 100% rename from store-reactjs-chat/public/index.html rename to examples/store-reactjs-chat/public/index.html diff --git a/store-reactjs-chat/public/manifest.json b/examples/store-reactjs-chat/public/manifest.json similarity index 100% rename from store-reactjs-chat/public/manifest.json rename to examples/store-reactjs-chat/public/manifest.json diff --git a/store-reactjs-chat/public/robots.txt b/examples/store-reactjs-chat/public/robots.txt similarity index 100% rename from store-reactjs-chat/public/robots.txt rename to examples/store-reactjs-chat/public/robots.txt diff --git a/store-reactjs-chat/src/App.css b/examples/store-reactjs-chat/src/App.css similarity index 100% rename from store-reactjs-chat/src/App.css rename to examples/store-reactjs-chat/src/App.css diff --git a/store-reactjs-chat/src/App.js b/examples/store-reactjs-chat/src/App.js similarity index 100% rename from store-reactjs-chat/src/App.js rename to examples/store-reactjs-chat/src/App.js diff --git a/store-reactjs-chat/src/App.test.js b/examples/store-reactjs-chat/src/App.test.js similarity index 100% rename from store-reactjs-chat/src/App.test.js rename to examples/store-reactjs-chat/src/App.test.js diff --git a/store-reactjs-chat/src/index.css b/examples/store-reactjs-chat/src/index.css similarity index 100% rename from store-reactjs-chat/src/index.css rename to examples/store-reactjs-chat/src/index.css diff --git a/store-reactjs-chat/src/index.js b/examples/store-reactjs-chat/src/index.js similarity index 100% rename from store-reactjs-chat/src/index.js rename to examples/store-reactjs-chat/src/index.js diff --git a/store-reactjs-chat/src/logo.svg b/examples/store-reactjs-chat/src/logo.svg similarity index 100% rename from store-reactjs-chat/src/logo.svg rename to examples/store-reactjs-chat/src/logo.svg diff --git a/store-reactjs-chat/src/setupTests.js b/examples/store-reactjs-chat/src/setupTests.js similarity index 100% rename from store-reactjs-chat/src/setupTests.js rename to examples/store-reactjs-chat/src/setupTests.js diff --git a/examples/web-chat/.cspell.json b/examples/web-chat/.cspell.json new file mode 100644 index 0000000..3a31ad2 --- /dev/null +++ b/examples/web-chat/.cspell.json @@ -0,0 +1,130 @@ +{ + "version": "0.1", + "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json", + "language": "en", + "words": [ + "asym", + "backoff", + "backoffs", + "bitjson", + "bitauth", + "bufbuild", + "chainsafe", + "cimg", + "ciphertext", + "circleci", + "codecov", + "commitlint", + "dependabot", + "dingpu", + "Dlazy", + "dnsaddr", + "Dout", + "Dscore", + "ecies", + "editorconfig", + "enr", + "enrs", + "enrtree", + "ephem", + "esnext", + "ethersproject", + "execa", + "exponentiate", + "fanout", + "floodsub", + "fontsource", + "globby", + "gossipsub", + "huilong", + "iasked", + "ihave", + "ihaves", + "ineed", + "ipfs", + "iwant", + "jdev", + "jswaku", + "keccak", + "lastpub", + "libauth", + "libp", + "lightpush", + "livechat", + "mkdir", + "multiaddr", + "multiaddresses", + "multiaddrs", + "multicodec", + "multicodecs", + "multiformats", + "mplex", + "multihashes", + "muxed", + "muxer", + "muxers", + "mvps", + "nodekey", + "nwaku", + "opendns", + "peerhave", + "portfinder", + "prettierignore", + "proto", + "protobuf", + "protoc", + "reactjs", + "recid", + "rlnrelay", + "roadmap", + "sandboxed", + "scanf", + "secio", + "seckey", + "secp", + "sscanf", + "staticnode", + "statusim", + "submodule", + "submodules", + "supercrypto", + "transpiled", + "typedoc", + "unencrypted", + "unmarshal", + "unmount", + "unmounts", + "untracked", + "upgrader", + "vacp", + "varint", + "waku", + "wakuconnect", + "wakuv", + "wakunode", + "webfonts", + "websockets", + "wifi", + "xsalsa20", + "Alives" + ], + "flagWords": [], + "ignorePaths": [ + "package.json", + "package-lock.json", + "yarn.lock", + "tsconfig.json", + "node_modules/**", + "build", + "gen", + "proto", + "*.spec.ts" + ], + "patterns": [ + { + "name": "import", + "pattern": "/import .*/" + } + ], + "ignoreRegExpList": ["import"] +} diff --git a/web-chat/.env b/examples/web-chat/.env similarity index 100% rename from web-chat/.env rename to examples/web-chat/.env diff --git a/web-chat/.gitignore b/examples/web-chat/.gitignore similarity index 100% rename from web-chat/.gitignore rename to examples/web-chat/.gitignore diff --git a/web-chat/.prettierignore b/examples/web-chat/.prettierignore similarity index 100% rename from web-chat/.prettierignore rename to examples/web-chat/.prettierignore diff --git a/web-chat/README.md b/examples/web-chat/README.md similarity index 100% rename from web-chat/README.md rename to examples/web-chat/README.md diff --git a/web-chat/buf.gen.yaml b/examples/web-chat/buf.gen.yaml similarity index 100% rename from web-chat/buf.gen.yaml rename to examples/web-chat/buf.gen.yaml diff --git a/web-chat/buf.yaml b/examples/web-chat/buf.yaml similarity index 100% rename from web-chat/buf.yaml rename to examples/web-chat/buf.yaml diff --git a/web-chat/package-lock.json b/examples/web-chat/package-lock.json similarity index 100% rename from web-chat/package-lock.json rename to examples/web-chat/package-lock.json diff --git a/web-chat/package.json b/examples/web-chat/package.json similarity index 97% rename from web-chat/package.json rename to examples/web-chat/package.json index 261571f..755091e 100644 --- a/web-chat/package.json +++ b/examples/web-chat/package.json @@ -40,7 +40,7 @@ "test": "run-s build test:*", "test:lint": "eslint src --ext .ts --ext .tsx", "test:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --list-different", - "test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ../.cspell.json", + "test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.{ts,tsx},public/**/*.html}\" -c ./.cspell.json", "fix:prettier": "prettier \"src/**/*.{ts,tsx}\" \"./*.json\" --write", "fix:lint": "eslint src --ext .ts --ext .tsx --fix", "proto": "protons src/proto/*.proto", diff --git a/web-chat/public/favicon.ico b/examples/web-chat/public/favicon.ico similarity index 100% rename from web-chat/public/favicon.ico rename to examples/web-chat/public/favicon.ico diff --git a/web-chat/public/favicon.png b/examples/web-chat/public/favicon.png similarity index 100% rename from web-chat/public/favicon.png rename to examples/web-chat/public/favicon.png diff --git a/web-chat/public/index.html b/examples/web-chat/public/index.html similarity index 100% rename from web-chat/public/index.html rename to examples/web-chat/public/index.html diff --git a/web-chat/public/manifest.json b/examples/web-chat/public/manifest.json similarity index 100% rename from web-chat/public/manifest.json rename to examples/web-chat/public/manifest.json diff --git a/web-chat/public/robots.txt b/examples/web-chat/public/robots.txt similarity index 100% rename from web-chat/public/robots.txt rename to examples/web-chat/public/robots.txt diff --git a/web-chat/src/App.css b/examples/web-chat/src/App.css similarity index 100% rename from web-chat/src/App.css rename to examples/web-chat/src/App.css diff --git a/web-chat/src/App.tsx b/examples/web-chat/src/App.tsx similarity index 100% rename from web-chat/src/App.tsx rename to examples/web-chat/src/App.tsx diff --git a/web-chat/src/ChatList.tsx b/examples/web-chat/src/ChatList.tsx similarity index 100% rename from web-chat/src/ChatList.tsx rename to examples/web-chat/src/ChatList.tsx diff --git a/web-chat/src/Message.ts b/examples/web-chat/src/Message.ts similarity index 100% rename from web-chat/src/Message.ts rename to examples/web-chat/src/Message.ts diff --git a/web-chat/src/MessageInput.tsx b/examples/web-chat/src/MessageInput.tsx similarity index 100% rename from web-chat/src/MessageInput.tsx rename to examples/web-chat/src/MessageInput.tsx diff --git a/web-chat/src/Room.tsx b/examples/web-chat/src/Room.tsx similarity index 100% rename from web-chat/src/Room.tsx rename to examples/web-chat/src/Room.tsx diff --git a/web-chat/src/WakuContext.ts b/examples/web-chat/src/WakuContext.ts similarity index 100% rename from web-chat/src/WakuContext.ts rename to examples/web-chat/src/WakuContext.ts diff --git a/web-chat/src/chat_message.ts b/examples/web-chat/src/chat_message.ts similarity index 100% rename from web-chat/src/chat_message.ts rename to examples/web-chat/src/chat_message.ts diff --git a/web-chat/src/command.ts b/examples/web-chat/src/command.ts similarity index 100% rename from web-chat/src/command.ts rename to examples/web-chat/src/command.ts diff --git a/web-chat/src/index.css b/examples/web-chat/src/index.css similarity index 100% rename from web-chat/src/index.css rename to examples/web-chat/src/index.css diff --git a/web-chat/src/index.tsx b/examples/web-chat/src/index.tsx similarity index 100% rename from web-chat/src/index.tsx rename to examples/web-chat/src/index.tsx diff --git a/web-chat/src/proto/chat_message.proto b/examples/web-chat/src/proto/chat_message.proto similarity index 100% rename from web-chat/src/proto/chat_message.proto rename to examples/web-chat/src/proto/chat_message.proto diff --git a/web-chat/src/proto/chat_message.ts b/examples/web-chat/src/proto/chat_message.ts similarity index 100% rename from web-chat/src/proto/chat_message.ts rename to examples/web-chat/src/proto/chat_message.ts diff --git a/web-chat/src/react-app-env.d.ts b/examples/web-chat/src/react-app-env.d.ts similarity index 100% rename from web-chat/src/react-app-env.d.ts rename to examples/web-chat/src/react-app-env.d.ts diff --git a/web-chat/src/setupTests.ts b/examples/web-chat/src/setupTests.ts similarity index 100% rename from web-chat/src/setupTests.ts rename to examples/web-chat/src/setupTests.ts diff --git a/web-chat/src/types/types.d.ts b/examples/web-chat/src/types/types.d.ts similarity index 100% rename from web-chat/src/types/types.d.ts rename to examples/web-chat/src/types/types.d.ts diff --git a/web-chat/tsconfig.json b/examples/web-chat/tsconfig.json similarity index 100% rename from web-chat/tsconfig.json rename to examples/web-chat/tsconfig.json diff --git a/packages/create-waku-app/build.js b/packages/create-waku-app/build.js deleted file mode 100644 index 5e7d272..0000000 --- a/packages/create-waku-app/build.js +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env node -const path = require("path"); -const fs = require("fs-extra"); - -const packageJson = require("./package.json"); -const examplesFolder = path.resolve("./examples"); - -async function run() { - fs.ensureDirSync(examplesFolder); - - const supportedExamples = Object.entries(packageJson.wakuExamples); - - console.log("Started copying supported Waku examples."); - - const copyPromises = supportedExamples.map(async ([name, relativePath]) => { - const resolvedPath = path.resolve(__dirname, relativePath); - const destinationPath = path.resolve(examplesFolder, name); - - try { - await fs.copy(resolvedPath, destinationPath, { filter: nodeModulesFiler }); - } catch (error) { - console.error(`Failed to copy example ${name} to ${destinationPath} with ${error.message}`); - throw Error(error.message); - } - }); - - try { - await Promise.all(copyPromises); - console.log("Finished copying examples."); - } catch (error) { - console.error("Failed to copy examples due to " + error.message); - } -} - -function nodeModulesFiler(src) { - if (src.includes("node_modules")) { - return false; - } - - return true; -} - -run(); diff --git a/packages/create-waku-app/createApp.js b/packages/create-waku-app/createApp.js deleted file mode 100644 index e7316b0..0000000 --- a/packages/create-waku-app/createApp.js +++ /dev/null @@ -1,121 +0,0 @@ -const path = require("path"); -const fs = require("fs-extra"); -const execSync = require("child_process").execSync; - -const { Command } = require("commander"); -const validateProjectName = require("validate-npm-package-name"); - -const DEFAULT_TEMPLATE = "web-chat"; -const supportedExamplesDir = path.resolve(__dirname, "./examples"); - -const init = (name, description, version, supportedExamples) => { - let appName; - const program = new Command() - .name(name) - .description(description) - .version(version, "-v, --version", "output the version number") - .arguments("", "Project directory to initialize Waku app") - .action(_appName => { - appName = _appName; - }) - .option( - "-t, --template ", - "specify a template for the created project" - ) - .allowUnknownOption() - .parse(); - - const options = program.opts(); - const template = options.template || DEFAULT_TEMPLATE; - - if (!supportedExamples[template]) { - const supportedExamplesMessage = Object.keys(supportedExamples).reduce((acc, v) => { - acc += `\t${v}\n`; - return acc; - }, ""); - - console.error(`Unknown template: ${template}`); - console.error(`We support only following templates:\n${supportedExamplesMessage}`) - process.exit(1); - } - - createApp(appName, template); -}; - -function createApp(name, template) { - const appRoot = path.resolve(name); - const appName = path.basename(appRoot); - - const templateDir = path.resolve(supportedExamplesDir, template); - - terminateIfAppExists(appName); - terminateIfProjectNameInvalid(appName); - - console.log(`Initializing ${appName} from ${template} template.`); - - fs.ensureDirSync(appName); - fs.copySync(templateDir, appRoot); - - runNpmInApp(appRoot); - runGitInit(appRoot); -} - -function runNpmInApp(root) { - const packageJsonPath = path.resolve(root, "package.json"); - - if (!fs.existsSync(packageJsonPath)) { - return; - } - - console.log("Installing npm packages."); - try { - execSync(`npm install --prefix ${root}`, { stdio: "ignore" }); - console.log("Successfully installed npm dependencies."); - } catch (e) { - console.warn("Failed to install npm dependencies", e); - } -} - -function runGitInit(root) { - if (isInGitRepository()) { - return; - } - - console.log("Initiating git repository."); - try { - execSync(`git init ${root}`, { stdio: "ignore" }); - console.log("Successfully initialized git repo."); - } catch (e) { - console.warn("Git repo not initialized", e); - } -} - -function isInGitRepository() { - try { - execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" }); - return true; - } catch (e) { - return false; - } -} - -function terminateIfProjectNameInvalid(name) { - const validationResult = validateProjectName(name); - - if (!validationResult.validForNewPackages) { - console.error(`Cannot create a project named ${name} because of npm naming restrictions:\n`); - [...(validationResult.errors || []), ...(validationResult.warnings || [])] - .forEach(error => console.error(` * ${error}`)); - console.error("\nPlease choose a different project name."); - process.exit(1); - } -} - -function terminateIfAppExists(appRoot) { - if (fs.existsSync(appRoot)) { - console.error(`Cannot create a project because it already exists by the name: ${appRoot}`); - process.exit(1); - } -} - -module.exports = { init }; \ No newline at end of file