-
Notifications
You must be signed in to change notification settings - Fork 2
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
AbigailDeng
authored and
AbigailDeng
committed
Nov 15, 2022
0 parents
commit 80e72a2
Showing
125 changed files
with
12,324 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,22 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# builds | ||
build | ||
dist | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development | ||
.env.test.local | ||
.env.production | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
package-lock.json |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Bunlong | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,156 @@ | ||
# Create Next App [](https://www.npmjs.com/package/@create-next-app/core) | ||
|
||
Create Next App allows you to create a [Next.js](https://nextjs.org) app by running one command. It come with default, material, bootstrap, semantic... templates, Next.js examples and Next.js CMS. | ||
|
||
## Features | ||
|
||
- Standard Template – providing a way to create your app with standard templates such as default, material, bootstrap, semantic, ... etc. | ||
- Standard Example – providing a way to bootstrap your app with standard examples such as basic css, typescript, next css, next routes, redux, ... etc. | ||
- Standard CMS – comming soon... | ||
|
||
## Installation | ||
|
||
Create Next App can be installed via npm: | ||
|
||
``` | ||
npm install --global @create-next-app/core | ||
``` | ||
|
||
Create Next App can be installed via yarn: | ||
|
||
``` | ||
yarn global add @create-next-app/core | ||
``` | ||
|
||
## To learn how to use Create Next App | ||
|
||
- [Home](https://create-next-app.js.org) | ||
- [Templates](https://create-next-app.js.org/get-started-with-templates) | ||
- [Examples](https://create-next-app.js.org/get-started-with-examples) | ||
|
||
<!-- ## Install | ||
To use create-next-app command line interface you have to install `create-next-app`. | ||
create-next-app is available on npm. It can be installed with the following command: | ||
``` | ||
npm install --global create-next-app | ||
``` | ||
create-next-app is available on yarn as well. It can be installed with the following command: | ||
``` | ||
yarn global add create-next-app | ||
``` | ||
You don't need to install or setup Webpack or Babel. They come with Next.js, so you can just start coding after running create-next-app command line. | ||
## Create a Next App in seconds | ||
To create a new Next.js app called <i>my-app</i> with `default` or `material` or `bootstrap` or `semantic` templates. | ||
1. Go to [Create Next App templates](https://create-next-app.js.org/#templates) | ||
2. Choose a template to create your Next.js app (such as default) | ||
3. And then run `create-next-app my-app --template default` | ||
4. Well done! | ||
It will create a directory called <i>my-app</i> inside the current folder. | ||
Inside that directory, it will generate the initial project structure and install the transitive dependencies: | ||
``` | ||
. | ||
├── README.md | ||
├── components | ||
│ ├── head.js | ||
│ └── nav.js | ||
├── next.config.js | ||
├── node_modules | ||
│ ├── [...] | ||
├── package.json | ||
├── pages | ||
│ └── index.js | ||
├── static | ||
│ └── favicon.ico | ||
└── yarn.lock | ||
``` | ||
No configuration or complicated folder structures, just the files you need to build your app. When the installation is done, you can open your project folder, run this command: | ||
``` | ||
cd my-app | ||
``` | ||
Inside the newly created project, you can run some built-in commands: | ||
### `npm run dev` or `yarn dev` | ||
Runs the app in development mode.<br/> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
The page will automatically reload if you make changes to the code.<br> | ||
You will see the build errors and lint warnings in the console. | ||
Out of the box, we get: | ||
- Automatic transpilation and bundling (with webpack and babel) | ||
- Hot code reloading | ||
- Server rendering and indexing of `./pages` | ||
- Static file serving. `./static/` is mapped to `/static/` | ||
### `npm run build` or `yarn build` | ||
Builds the app for production to the `.next` folder.<br/> | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
### `npm run start` or `yarn start` | ||
Starts the application in production mode. The application should be compiled with `npm run build` first. | ||
Now you maybe ready to code and deploy your app! | ||
## Start Next Examples | ||
There are a bunch of examples in the Next.js repository that you can use to bootstrap your app. | ||
To bootstrap your app with example: | ||
1. Go to [Create Next App examples](https://create-next-app.js.org/#examples) | ||
2. Choose an example to bootstrap your app (such as basic-css) | ||
3. And then run `create-next-app my-app --example basic-css` | ||
4. Well done! | ||
Now you maybe ready to code and deploy your app! | ||
## User Guide | ||
You can find detailed instructions on using Next.js and many tips in [its documentation](https://nextjs.org/docs/). --> | ||
|
||
## 💖 Wrap Up | ||
|
||
If you think any of the `create-next-app` can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit. | ||
|
||
## 🌟 Contribution | ||
|
||
We'd love to have your helping hand on contributions to `create-next-app` by forking and sending a pull request! | ||
|
||
Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠) | ||
|
||
How to contribute: | ||
|
||
- Open pull request with improvements | ||
- Discuss ideas in issues | ||
- Spread the word | ||
- Reach out with any feedback | ||
|
||
## ⚖️ License | ||
|
||
The MIT License [](https://opensource.org/licenses/MIT) | ||
|
||
<!-- | ||
rm -rf /home/bunlong/.nvm/versions/node/v12.3.1/lib/node_modules/@create-next-app | ||
npm install --global /home/bunlong/workspace/os/create-next-app | ||
--> |
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,26 @@ | ||
#! /usr/bin/env node | ||
|
||
const program = require("commander"); | ||
const pkg = require("../package.json"); | ||
const chalk = require("chalk"); | ||
const lib = require(".."); | ||
|
||
const consoles = lib.consoles; | ||
const createNextApp = lib.createNextApp; | ||
|
||
let projectName; | ||
|
||
program | ||
.version(pkg.version) | ||
.arguments("<project-directory>") | ||
.usage(`${chalk.green("<project-directory>")} [options]`) | ||
.action(function (name) { | ||
projectName = name; | ||
}) | ||
.allowUnknownOption() | ||
.on("--help", consoles.help) | ||
.parse(process.argv); | ||
|
||
createNextApp({ | ||
projectName, | ||
}); |
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,8 @@ | ||
const createNextApp = require('./lib') | ||
|
||
const consoles = require('./lib/consoles') | ||
|
||
module.exports = { | ||
createNextApp: createNextApp, | ||
consoles: consoles | ||
} |
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 @@ | ||
const chalk = require("chalk"); | ||
const output = require("./utils/output"); | ||
|
||
const program = { | ||
name: "create-next-aelf", | ||
}; | ||
|
||
exports.help = function () { | ||
return ` | ||
Only ${chalk.green("<project-directory>")} is required. | ||
If you have any problems, do not hesitate to file an issue: | ||
${chalk.cyan( | ||
"https://github.com/AElfProject/aelf-boilerplate/issues/new" | ||
)} | ||
`; | ||
}; | ||
|
||
// no project name | ||
exports.missingProjectName = function () { | ||
return ` | ||
Please specify the project directory: | ||
${chalk.cyan(program.name)} ${chalk.green("<project-directory>")} | ||
For example: | ||
${chalk.cyan(program.name)} ${chalk.green("my-next-app")} | ||
Run ${chalk.cyan(`${program.name} --help`)} to see all options. | ||
`; | ||
}; | ||
|
||
// project already exist | ||
exports.alreadyExists = function (projectName) { | ||
return ` | ||
Uh oh! Looks like there's already a directory called ${chalk.red( | ||
projectName | ||
)}. Please try a different name or delete that folder.`; | ||
}; | ||
|
||
exports.copying = function (projectName) { | ||
return ` | ||
Creating ${chalk.bold(chalk.green(projectName))}... | ||
`; | ||
}; |
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,31 @@ | ||
const consoles = require("./consoles"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const copyDir = require("./utils/copy-dir"); | ||
|
||
module.exports = function createNextApp(opts) { | ||
const projectName = opts.projectName; | ||
|
||
// no project name -> exit | ||
if (!projectName) { | ||
console.log(consoles.missingProjectName()); | ||
process.exit(1); | ||
} | ||
// project already exist -> exit | ||
if (fs.existsSync(projectName) && projectName !== ".") { | ||
console.log(consoles.alreadyExists(projectName)); | ||
process.exit(1); | ||
} | ||
|
||
const projectPath = (opts.projectPath = process.cwd() + "/" + projectName); | ||
|
||
let templatePath = path.resolve(__dirname, "../scaffolds/aelf"); | ||
|
||
copyDir({ | ||
templatePath: templatePath, | ||
projectPath: projectPath, | ||
projectName: projectName, | ||
}).catch(function (err) { | ||
throw err; | ||
}); | ||
}; |
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 @@ | ||
const path = require("path"); | ||
const Promise = require("promise"); | ||
const consoles = require("../consoles"); | ||
const output = require("./output"); | ||
const fs = require("fs-extra"); | ||
|
||
module.exports = function copyDir(opts) { | ||
const templatePath = opts.templatePath; | ||
const projectPath = opts.projectPath; | ||
const projectName = opts.projectName; | ||
|
||
console.log(consoles.copying(projectName)); | ||
|
||
return new Promise(function (resolve, reject) { | ||
const stopCopySpinner = output.wait("Copying files"); | ||
|
||
fs.copy(templatePath, projectPath) | ||
.then(function () { | ||
// copy and rename gitignore file | ||
return fs.move( | ||
path.resolve(projectPath, "./gitignore"), | ||
path.resolve(projectPath, "./.gitignore") | ||
); | ||
}) | ||
.then(function () { | ||
stopCopySpinner(); | ||
output.success( | ||
`Created files for "${output.cmd(projectName)}" next app` | ||
); | ||
return this; | ||
}) | ||
.then(resolve) | ||
.catch(function (err) { | ||
console.error(err); | ||
stopCopySpinner(); | ||
output.error("Copy command failed, try again."); | ||
reject(err); | ||
process.exit(1); | ||
}); | ||
}); | ||
}; |
Oops, something went wrong.