This repository has been archived by the owner on Mar 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48827b6
Showing
27 changed files
with
6,164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
out | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn tsc --noEmit | ||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"esbenp.prettier-vscode", | ||
"streetsidesoftware.code-spell-checker", | ||
"vivaxy.vscode-conventional-commits" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"javascript.suggestionActions.enabled": false, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"files.trimTrailingWhitespace": true, | ||
"files.trimFinalNewlines": true, | ||
"files.insertFinalNewline": true, | ||
"files.exclude": { | ||
"**/node_modules": true, | ||
"**/.webpack": true, | ||
"yarn.lock": true, | ||
".husky": true | ||
}, | ||
"conventionalCommits.gitmoji": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "start", | ||
"problemMatcher": "$ts-webpack-watch", | ||
"label": "npm: start", | ||
"detail": "Start building & watching in development mode", | ||
"isBackground": true, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Create Notion App · [![CI](https://github.com/nbundle/create-notion-app/actions/workflows/ci.yml/badge.svg)](https://github.com/nbundle/create-notion-app/actions/workflows/ci.yml) | ||
|
||
Create [nbundle]-powered [Notion] apps with one command: | ||
|
||
<details> | ||
<summary>npm</summary> | ||
|
||
```shell | ||
npx create-notion-app | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>yarn</summary> | ||
|
||
```shell | ||
yarn create notion-app | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>pnpm</summary> | ||
|
||
```shell | ||
pnpm create notion-app | ||
``` | ||
|
||
</details> | ||
|
||
Or for a TypeScript project: | ||
|
||
<details> | ||
<summary>npm</summary> | ||
|
||
```shell | ||
npx create-notion-app --ts | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>yarn</summary> | ||
|
||
```shell | ||
yarn create notion-app --ts | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>pnpm</summary> | ||
|
||
```shell | ||
pnpm create notion-app --ts | ||
``` | ||
|
||
</details> | ||
|
||
## Options | ||
|
||
`create-notion-app` comes with the following options: | ||
|
||
| Option | Description | | ||
| -------------------------- | ---------------------------------- | | ||
| **-t, --ts, --typescript** | Initialize as a TypeScript project | | ||
|
||
## Contributing | ||
|
||
### Requirements | ||
|
||
- Node 14+ | ||
|
||
- Yarn 1.22+ | ||
|
||
### Setup | ||
|
||
1. Install requirements | ||
|
||
2. Clone the repository | ||
|
||
3. Run `yarn` to install dependencies | ||
|
||
### Develop | ||
|
||
- Run `yarn start` to start building & watching in development mode | ||
|
||
- Commit adhering to [Angular commit convention](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit) (use `yarn commit` or [Conventional Commits in Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits) to commit interactively) | ||
|
||
- Submit a PR and make sure required status checks pass | ||
|
||
- When a PR is merged or code is pushed to `main`, Github automatically builds & publishes a new release if there are relevant changes | ||
|
||
<!-- Links --> | ||
|
||
[nbundle]: https://www.nbundle.com | ||
[notion]: https://www.notion.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env node | ||
require("../out/main.js"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
extends: ["@commitlint/config-angular"], | ||
ignores: [(commit) => /^build\((deps|deps-dev)\): bump/.test(commit)], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"ignorePaths": ["package.json", "cspell.json", ".vscode", "out"], | ||
"words": [ | ||
"commitlint", | ||
"hgcheck", | ||
"hgignore", | ||
"intellij", | ||
"mkdocs", | ||
"nbundle", | ||
"npmignore", | ||
"pnpm" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
"*": ["prettier --write --ignore-unknown", "cspell --no-must-find-files"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"name": "create-notion-app", | ||
"version": "0.0.0-SNAPSHOT", | ||
"description": "Create nbundle-powered Notion apps with one command", | ||
"keywords": [ | ||
"notion", | ||
"notion-api", | ||
"notion-client", | ||
"notion-app", | ||
"notion-integration", | ||
"notion-extension", | ||
"notion-plugin", | ||
"notion-addon", | ||
"notion-automation", | ||
"nbundle", | ||
"nbundle-app", | ||
"nbundle-integration", | ||
"nbundle-extension", | ||
"nbundle-plugin", | ||
"nbundle-addon" | ||
], | ||
"license": "AGPL-3.0", | ||
"repository": "https://github.com/nbundle/create-notion-app", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"files": [ | ||
"out", | ||
"bin" | ||
], | ||
"main": "out/main.js", | ||
"bin": { | ||
"create-notion-app": "bin/create-notion-app.js" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0", | ||
"yarn": "^1.22.0" | ||
}, | ||
"scripts": { | ||
"prepare": "husky install", | ||
"start": "webpack --mode development --watch --color", | ||
"build": "webpack --mode production --color" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.0.2", | ||
"@commitlint/config-angular": "^17.0.0", | ||
"@commitlint/prompt-cli": "^17.0.0", | ||
"@tsconfig/node14": "^1.0.1", | ||
"@types/async-retry": "^1.4.4", | ||
"@types/got": "^9.6.12", | ||
"@types/node": "^14.18.12", | ||
"@types/tar": "^6.1.1", | ||
"async-retry": "^1.3.3", | ||
"cspell": "^6.1.2", | ||
"got": "^12.1.0", | ||
"husky": "^8.0.1", | ||
"lint-staged": "^13.0.1", | ||
"prettier": "^2.6.2", | ||
"semantic-release": "^19.0.3", | ||
"tar": "^6.1.11", | ||
"ts-loader": "^9.3.0", | ||
"tsconfig-paths-webpack-plugin": "^3.5.2", | ||
"webpack": "^5.73.0", | ||
"webpack-cli": "^4.9.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import fs from "fs/promises"; | ||
import chalk from "chalk"; | ||
|
||
import { | ||
mustBeEmpty, | ||
downloadAndExtractRepo, | ||
formatProject, | ||
installDependencies, | ||
tryGitInit, | ||
} from "./utils"; | ||
import path from "path"; | ||
|
||
export interface CreateOptions { | ||
typescript?: boolean; | ||
} | ||
|
||
export default async function create( | ||
projectDirectory: string, | ||
options: CreateOptions | ||
): Promise<void> { | ||
await fs.mkdir(projectDirectory, { recursive: true }); | ||
|
||
await mustBeEmpty(projectDirectory); | ||
|
||
const example = `example${options.typescript ? "-ts" : ""}`; | ||
|
||
console.log( | ||
`Downloading template ${chalk.cyan(example)}. This might take a moment.\n` | ||
); | ||
|
||
await downloadAndExtractRepo(projectDirectory, { | ||
username: "nbundle", | ||
name: example, | ||
branch: "main", | ||
}); | ||
|
||
await formatProject(projectDirectory); | ||
|
||
console.log("Installing packages. This might take a couple of minutes.\n"); | ||
|
||
await installDependencies(projectDirectory); | ||
|
||
if (await tryGitInit(projectDirectory)) { | ||
console.log("Initialized a git repository.\n"); | ||
} | ||
|
||
const packageManager = "yarn"; | ||
const useYarn = packageManager === "yarn"; | ||
|
||
const name = path.basename(projectDirectory); | ||
let cdPath: string; | ||
if (path.join(process.cwd(), name) === projectDirectory) { | ||
cdPath = name; | ||
} else { | ||
cdPath = projectDirectory; | ||
} | ||
console.log( | ||
`${chalk.green("Success!")} Created ${chalk.blue(projectDirectory)}\n` | ||
); | ||
console.log("Inside that directory, you can run several commands:\n"); | ||
console.log( | ||
chalk.cyan(` ${packageManager} ${useYarn ? "" : "run "}develop`) | ||
); | ||
console.log(" Starts the development server.\n"); | ||
console.log(chalk.cyan(` ${packageManager} ${useYarn ? "" : "run "}build`)); | ||
console.log(" Builds the app for production.\n"); | ||
console.log(chalk.cyan(` ${packageManager} preview`)); | ||
console.log(" Runs the built app in production mode.\n"); | ||
console.log("We suggest that you begin by typing:\n"); | ||
console.log(chalk.cyan(" cd"), cdPath); | ||
console.log( | ||
` ${chalk.cyan(`${packageManager} ${useYarn ? "" : "run "}dev`)}\n` | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import path from "path"; | ||
import fs from "fs/promises"; | ||
import { Command, Option } from "commander"; | ||
|
||
import create from "./create"; | ||
|
||
async function index() { | ||
const program = new Command(); | ||
|
||
const pkgJson = await fs.readFile( | ||
path.resolve(__dirname, "..", "package.json"), | ||
"utf8" | ||
); | ||
const pkg = JSON.parse(pkgJson); | ||
|
||
program | ||
.name(pkg.name) | ||
.description(pkg.description) | ||
.version(pkg.version, "-v, -V, --version") | ||
.arguments("<project-directory>") | ||
.usage(`<project-directory> [options]`) | ||
.option("-t, --ts, --typescript", "initialize as a TypeScript project") | ||
.addOption( | ||
new Option( | ||
"-t, --typescript", | ||
"initialize as a TypeScript project" | ||
).hideHelp() | ||
) | ||
.action((projectDirectory, opts) => | ||
create(path.resolve(projectDirectory), { | ||
typescript: opts.ts || opts.typescript, | ||
}) | ||
); | ||
|
||
await program.parseAsync(); | ||
} | ||
|
||
index().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import child_process from "child_process"; | ||
import { promisify } from "util"; | ||
|
||
export const exec = promisify(child_process.exec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import stream from "stream"; | ||
import { promisify } from "util"; | ||
|
||
export const pipeline = promisify(stream.pipeline); |
Oops, something went wrong.