Skip to content

Commit

Permalink
Merge pull request #5 from crypblizz8/feat/husky
Browse files Browse the repository at this point in the history
feat: init github actions and husky
  • Loading branch information
crypblizz8 authored Sep 26, 2024
2 parents 7aba125 + 514fd58 commit 08bf309
Show file tree
Hide file tree
Showing 11 changed files with 5,182 additions and 1,501 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Initial Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
- run: npm run build
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
npm-debug.log
.DS_Store
.DS_Store

dist
node_modules/
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# create-nillion-app
# Create Nillion App

A CLI tool to create a new Nillion app with Next.js integration.

## Usage

This will create a new Nillion app in the `my-nillion-app` directory.

`npx create-nillion-app my-nillion-app`
`npx create-nillion-app`

## What it does

1. Installs `nilup`, the Nillion SDK tool installer and version manager
2. Creates a Next.js project with App Router
3. Installs `@nillion/client-react-hooks`
4. Sets up a `nillion` folder for SDK access
2. Install an Nada projects
3. Clones an example Next.js project with App Router
a. Installs `@nillion/client-react-hooks`
b.

Directory tree should look like:

```
.
├── nada_quickstart_programs
│   ├── XXX
└── nillion-app
├── XXX
```

## Requirements

Expand Down
126 changes: 4 additions & 122 deletions bin/create-nillion-app.js
Original file line number Diff line number Diff line change
@@ -1,122 +1,4 @@
// #!/usr/bin/env node

// const { execSync } = require("child_process");
// const fs = require("fs");
// const path = require("path");
// const nillionLogo = `
// _ _ _ _
// _ __ (_) | (_) ___ _ __
// | '_ \\| | | | |/ _ \\| '_ \\
// | | | | | | | | (_) | | | |
// |_| |_|_|_|_|_|\\___/|_| |_|

// `;
// function displayLogo() {
// console.log("\x1b[34m%s\x1b[0m", nillionLogo);
// }

// function displayWelcomeMessage() {
// const purpleText = "\x1b[34m";
// const resetColor = "\x1b[0m";
// console.log(
// `Welcome to ${purpleText}create-nillion-app${resetColor} - the quickstart Nillion CLI`
// );
// }

// function isNilupInstalled() {
// try {
// const output = execSync("nilup -V", { stdio: "pipe" }).toString().trim();
// console.log(`Nilup is already installed. Version: ${output}`);
// return true;
// } catch (error) {
// return false;
// }
// }

// function installNilup() {
// console.log("--------------------");
// console.log("Installing nilup... This may take a few minutes.🙏 ");
// execSync("curl -fsSL https://nilup.nilogy.xyz/install.sh | sh", {
// stdio: "inherit",
// });
// execSync("nilup install latest", { stdio: "inherit" });
// execSync("nilup use latest", { stdio: "inherit" });
// execSync("nilup init", { stdio: "inherit" });
// }

// function setupNadaFolder(rootDir) {
// console.log("Setting up Nada project...");

// execSync("nada init nada_quickstart_programs", { stdio: "inherit" });
// execSync("python3 -m venv .venv", { stdio: "inherit" });

// // Determine the correct activate script based on the OS
// const activateScript =
// process.platform === "win32"
// ? ".venv\\Scripts\\activate"
// : "source .venv/bin/activate";

// // Install nada-dsl
// execSync(`${activateScript} && pip install --upgrade nada-dsl`, {
// stdio: "inherit",
// shell: true,
// });

// process.chdir(rootDir);
// }

// function createNextJsProject(rootDir) {
// console.log("--------------------");
// console.log("Cloning Next.js project...");
// const nextAppPath = path.join(rootDir, "nillion-app");
// fs.mkdirSync(nextAppPath, { recursive: true });
// process.chdir(nextAppPath);

// console.log("Note: Degit is used to clone the Next.js project.");
// execSync("npx degit NillionNetwork/client-ts/examples/nextjs .", {
// stdio: "inherit",
// });
// process.chdir(rootDir);
// }

// function updatePackageJson(rootDir) {
// const packageJsonPath = path.join(rootDir, "nillion-app", "package.json");
// const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
// packageJson.scripts = {
// ...packageJson.scripts,
// "nillion:update":
// "nilup update && nilup install latest && nilup use latest",
// "nada:activate":
// process.platform === "win32"
// ? "cd ..\\nada_quickstart_programs && .venv\\Scripts\\activate"
// : "cd ../nada_quickstart_programs && source .venv/bin/activate",
// };
// fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
// }

// function main() {
// const projectName = process.argv[2] || "nillion-quickstart";

// displayLogo();
// displayWelcomeMessage();

// console.log("Checking if Nilup is installed...");
// if (!isNilupInstalled()) {
// installNilup();
// }

// fs.mkdirSync(projectName, { recursive: true });
// process.chdir(projectName);

// setupNadaFolder(process.cwd());
// createNextJsProject(process.cwd());
// updatePackageJson(process.cwd());

// console.log(
// `Nillion quickstart "${projectName}" has been created successfully! 🚀`
// );
// console.log(`Follow the rest of the Documenation Quickstart to get started!`);
// console.log("--------------------");
// }

// main();
import("../dist/index.js").catch((err) => {
console.error("Error:", err);
process.exit(1);
});
13 changes: 9 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import globals from "globals";
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import * as tseslint from "typescript-eslint";
import eslintPluginPrettier from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier";
import eslintPluginJest from "eslint-plugin-jest";

export default tseslint.config(
export default [
{
files: ["**/*.{js,mjs,cjs,ts}"],
languageOptions: {
globals: {
...globals.node,
...globals.es2021,
...globals.jest,
},
parser: tseslint.parser,
parserOptions: {
Expand All @@ -20,18 +22,21 @@ export default tseslint.config(
plugins: {
"@typescript-eslint": tseslint.plugin,
prettier: eslintPluginPrettier,
jest: eslintPluginJest,
},
rules: {
...eslintPluginPrettier.configs.recommended.rules,
"prettier/prettier": "error",
...eslintPluginJest.configs.recommended.rules,
},
},
js.configs.recommended,
...tseslint.configs.recommended,
prettierConfig,
{
files: ["**/tests/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
rules: {
// Add Later
...eslintPluginJest.configs.recommended.rules,
},
},
);
];
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
extensionsToTreatAsEsm: [".ts"],
globals: {
"ts-jest": {
useESM: true,
},
},
transform: {
"^.+\\.tsx?$": ["ts-jest", { useESM: true }],
},
};
Loading

0 comments on commit 08bf309

Please sign in to comment.