From 02825de38447aa92a0399f271b1fbeed35249087 Mon Sep 17 00:00:00 2001 From: David Herman Date: Sun, 28 Feb 2021 23:26:00 -0800 Subject: [PATCH] WIP --- .gitignore | 1 + create-neon/package-lock.json | 20 +++++++++++++++++ create-neon/package.json | 32 ++++++++++++++++++++++++++++ create-neon/src/bin/create-neon.ts | 4 ++++ create-neon/src/util.ts | 1 + create-neon/templates/.gitignore.hbs | 4 ++++ create-neon/templates/Cargo.toml.hbs | 19 +++++++++++++++++ create-neon/templates/README.md.hbs | 3 +++ create-neon/templates/lib.rs.hbs | 11 ++++++++++ create-neon/tsconfig.json | 27 +++++++++++++++++++++++ 10 files changed, 122 insertions(+) create mode 100644 create-neon/package-lock.json create mode 100644 create-neon/package.json create mode 100644 create-neon/src/bin/create-neon.ts create mode 100644 create-neon/src/util.ts create mode 100644 create-neon/templates/.gitignore.hbs create mode 100644 create-neon/templates/Cargo.toml.hbs create mode 100644 create-neon/templates/README.md.hbs create mode 100644 create-neon/templates/lib.rs.hbs create mode 100644 create-neon/tsconfig.json diff --git a/.gitignore b/.gitignore index f9cc099e7..c5e4c4a80 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ Cargo.lock **/index.node **/artifacts.json cli/lib +create-neon/dist test/cli/lib npm-debug.log rls*.log diff --git a/create-neon/package-lock.json b/create-neon/package-lock.json new file mode 100644 index 000000000..cc366bbb1 --- /dev/null +++ b/create-neon/package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "create-neon", + "version": "0.1.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "14.14.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.31.tgz", + "integrity": "sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g==", + "dev": true + }, + "typescript": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.2.tgz", + "integrity": "sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ==", + "dev": true + } + } +} diff --git a/create-neon/package.json b/create-neon/package.json new file mode 100644 index 000000000..129e04ceb --- /dev/null +++ b/create-neon/package.json @@ -0,0 +1,32 @@ +{ + "name": "create-neon", + "version": "0.1.0", + "description": "Create Neon projects with no build configuration.", + "author": "Dave Herman ", + "license": "MIT", + "bugs": { + "url": "https://github.com/neon-bindings/neon/issues" + }, + "homepage": "https://github.com/neon-bindings/neon#readme", + "bin": "./dist/bin/create-neon.js", + "files": [ + "dist/**/*", + "templates/**/*" + ], + "scripts": { + "build": "tsc", + "prepublishOnly": "npm run build", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/neon-bindings/neon.git" + }, + "keywords": [ + "neon" + ], + "devDependencies": { + "@types/node": "^14.14.31", + "typescript": "^4.2.2" + } +} diff --git a/create-neon/src/bin/create-neon.ts b/create-neon/src/bin/create-neon.ts new file mode 100644 index 000000000..c8741febd --- /dev/null +++ b/create-neon/src/bin/create-neon.ts @@ -0,0 +1,4 @@ +import { FARTS } from '../util'; + +console.log('hey'); +console.log(FARTS); diff --git a/create-neon/src/util.ts b/create-neon/src/util.ts new file mode 100644 index 000000000..4a91733f2 --- /dev/null +++ b/create-neon/src/util.ts @@ -0,0 +1 @@ +export const FARTS: string = 'farts'; diff --git a/create-neon/templates/.gitignore.hbs b/create-neon/templates/.gitignore.hbs new file mode 100644 index 000000000..db22c6fc5 --- /dev/null +++ b/create-neon/templates/.gitignore.hbs @@ -0,0 +1,4 @@ +target +index.node +**/node_modules +**/.DS_Store diff --git a/create-neon/templates/Cargo.toml.hbs b/create-neon/templates/Cargo.toml.hbs new file mode 100644 index 000000000..c26f61af9 --- /dev/null +++ b/create-neon/templates/Cargo.toml.hbs @@ -0,0 +1,19 @@ +[package] +name = "{{project.name.cargo}}" +version = "{{project.version}}" +{{#if project.author}} +authors = ["{{project.author}}{{#if project.email}} <{{project.email}}>{{/if}}"] +{{/if}} +{{#if project.license}} +license = "{{project.license}}" +{{/if}} +edition = "2018" +exclude = ["index.node"] + +[lib] +crate-type = ["cdylib"] + +[dependencies.neon] +version = {{neon.libs.version}} +default-features = false +features = ["napi-6"] diff --git a/create-neon/templates/README.md.hbs b/create-neon/templates/README.md.hbs new file mode 100644 index 000000000..f4c6e9edb --- /dev/null +++ b/create-neon/templates/README.md.hbs @@ -0,0 +1,3 @@ +# {{project.name.npm.full}} + +{{project.description}} diff --git a/create-neon/templates/lib.rs.hbs b/create-neon/templates/lib.rs.hbs new file mode 100644 index 000000000..9fd52d67b --- /dev/null +++ b/create-neon/templates/lib.rs.hbs @@ -0,0 +1,11 @@ +use neon::prelude::*; + +fn hello(mut cx: FunctionContext) -> JsResult { + Ok(cx.string("hello node")) +} + +#[neon::main] +fn main(mut cx: ModuleContext) -> NeonResult<()> { + cx.export_function("hello", hello)?; + Ok(()) +} diff --git a/create-neon/tsconfig.json b/create-neon/tsconfig.json new file mode 100644 index 000000000..00d746b0d --- /dev/null +++ b/create-neon/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": [ + "es6", + "es7" + ], + "allowJs": false, + + "sourceMap": false, + "outDir": "dist", + + "esModuleInterop": true, + "strict": true, + "noImplicitReturns": true, + "allowUnreachableCode": false, + "noUnusedLocals": true, + "noUnusedParameters": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] +}