-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bumped dependencies to the latest version * Added editorconfig * Added our linting setup * Added more * Fixed linting * Added Circle CI * Added correct badges * Removed whitespace * Tim is also at ZEIT * Renamed license
- Loading branch information
Showing
14 changed files
with
523 additions
and
1,845 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,37 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
# specify the version you desire here | ||
- image: circleci/node:latest | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
# documented at https://circleci.com/docs/2.0/circleci-images/ | ||
# - image: circleci/mongo:3.4.4 | ||
|
||
working_directory: ~/repo | ||
|
||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "yarn.lock" }} | ||
|
||
# run tests! | ||
- run: yarn test |
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,37 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
tab_width = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{*.json,*.json.example,*.gyp,*.yml,*.yaml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{*.py,*.asm}] | ||
indent_style = space | ||
|
||
[*.py] | ||
indent_size = 4 | ||
|
||
[*.asm] | ||
indent_size = 8 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
# Ideal settings - some plugins might support these. | ||
[*.js] | ||
quote_type = single | ||
|
||
[{*.c,*.cc,*.h,*.hh,*.cpp,*.hpp,*.m,*.mm,*.mpp,*.js,*.java,*.go,*.rs,*.php,*.ng,*.jsx,*.ts,*.d,*.cs,*.swift}] | ||
curly_bracket_next_line = false | ||
spaces_around_operators = true | ||
spaces_around_brackets = outside | ||
# close enough to 1TB | ||
indent_brace_style = K&R |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
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 |
---|---|---|
@@ -1,106 +1,105 @@ | ||
#!/usr/bin/env node | ||
|
||
// Native | ||
const { existsSync } = require('fs') | ||
const path = require('path') | ||
const {existsSync} = require('fs'); | ||
const path = require('path'); | ||
|
||
// Packages | ||
const mri = require('mri') | ||
const dotEnv = require('dotenv') | ||
const mri = require('mri'); | ||
const dotEnv = require('dotenv'); | ||
|
||
// Utilities | ||
const generateHelp = require('../lib/help') | ||
const serve = require('../lib/serve') | ||
const { version } = require('../package') | ||
const logError = require('../lib/error') | ||
const generateHelp = require('../lib/help'); | ||
const serve = require('../lib/serve'); | ||
const {version} = require('../package'); | ||
const logError = require('../lib/error'); | ||
|
||
const flags = mri(process.argv.slice(2), { | ||
default: { | ||
host: '::', | ||
port: 3000, | ||
limit: '1mb', | ||
dotenv: '.env' | ||
}, | ||
alias: { | ||
p: 'port', | ||
H: 'host', | ||
c: 'cold', | ||
w: 'watch', | ||
L: 'poll', | ||
s: 'silent', | ||
h: 'help', | ||
v: 'version', | ||
i: 'ignore', | ||
l: 'limit', | ||
d: 'dotenv' | ||
}, | ||
unknown(flag) { | ||
console.log(`The option "${flag}" is unknown. Use one of these:`) | ||
console.log(generateHelp()) | ||
process.exit(1) | ||
} | ||
}) | ||
'default': { | ||
host: '::', | ||
port: 3000, | ||
limit: '1mb', | ||
dotenv: '.env' | ||
}, | ||
'alias': { | ||
p: 'port', | ||
H: 'host', | ||
c: 'cold', | ||
w: 'watch', | ||
L: 'poll', | ||
s: 'silent', | ||
h: 'help', | ||
v: 'version', | ||
i: 'ignore', | ||
l: 'limit', | ||
d: 'dotenv' | ||
}, | ||
unknown(flag) { | ||
console.log(`The option "${flag}" is unknown. Use one of these:`); | ||
console.log(generateHelp()); | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
// When `-h` or `--help` are used, print out | ||
// the usage information | ||
if (flags.help) { | ||
console.log(generateHelp()) | ||
process.exit() | ||
console.log(generateHelp()); | ||
process.exit(); | ||
} | ||
|
||
// Print out the package's version when | ||
// `--version` or `-v` are used | ||
if (flags.version) { | ||
console.log(version) | ||
process.exit() | ||
console.log(version); | ||
process.exit(); | ||
} | ||
|
||
// Load the `.env` file | ||
dotEnv.config({ | ||
path: path.resolve(process.cwd(), flags.dotenv) | ||
}) | ||
path: path.resolve(process.cwd(), flags.dotenv) | ||
}); | ||
|
||
if (flags.cold && (flags.watch || flags.poll)) { | ||
logError( | ||
'The --cold flag is not compatible with --watch or --poll!', | ||
'watch-flags' | ||
) | ||
process.exit(1) | ||
logError( | ||
'The --cold flag is not compatible with --watch or --poll!', | ||
'watch-flags' | ||
); | ||
process.exit(1); | ||
} | ||
|
||
let file = flags._[0] | ||
let file = flags._[0]; | ||
|
||
if (!file) { | ||
try { | ||
// eslint-disable-next-line import/no-dynamic-require | ||
const packageJson = require(path.resolve(process.cwd(), 'package.json')) | ||
file = packageJson.main || 'index.js' | ||
} catch (err) { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
logError( | ||
`Could not read \`package.json\`: ${err.message}`, | ||
'invalid-package-json' | ||
) | ||
process.exit(1) | ||
} | ||
} | ||
try { | ||
const packageJson = require(path.resolve(process.cwd(), 'package.json')); | ||
file = packageJson.main || 'index.js'; | ||
} catch (err) { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
logError( | ||
`Could not read \`package.json\`: ${err.message}`, | ||
'invalid-package-json' | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
if (!file) { | ||
logError('No path defined!', 'path-missing') | ||
process.exit(1) | ||
logError('No path defined!', 'path-missing'); | ||
process.exit(1); | ||
} | ||
|
||
if (file[0] !== '/') { | ||
file = path.resolve(process.cwd(), file) | ||
file = path.resolve(process.cwd(), file); | ||
} | ||
|
||
if (!existsSync(file)) { | ||
logError( | ||
`The file or directory "${path.basename(file)}" doesn't exist!`, | ||
'path-not-existent' | ||
) | ||
process.exit(1) | ||
logError( | ||
`The file or directory "${path.basename(file)}" doesn't exist!`, | ||
'path-not-existent' | ||
); | ||
process.exit(1); | ||
} | ||
|
||
serve(file, flags) | ||
serve(file, flags); |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// Packages | ||
const { red, blue } = require('chalk') | ||
const {red, blue} = require('chalk'); | ||
|
||
module.exports = (message, errorCode) => { | ||
const repo = errorCode === 'watch-flags' ? 'micro-dev' : 'micro' | ||
const repo = errorCode === 'watch-flags' ? 'micro-dev' : 'micro'; | ||
|
||
console.error(`${red('Error:')} ${message}`) | ||
console.error(`${blue('How to Fix It:')} https://err.sh/${repo}/${errorCode}`) | ||
} | ||
console.error(`${red('Error:')} ${message}`); | ||
console.error(`${blue('How to Fix It:')} https://err.sh/${repo}/${errorCode}`); | ||
}; |
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
Oops, something went wrong.