Skip to content

Commit 5a95f86

Browse files
committed
initial commit
0 parents  commit 5a95f86

12 files changed

+1474
-0
lines changed

Diff for: .gitignore

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
2+
3+
# Logs
4+
logs
5+
*.log
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19+
.grunt
20+
21+
# node-waf configuration
22+
.lock-wscript
23+
24+
# Compiled binary addons (http://nodejs.org/api/addons.html)
25+
build/Release
26+
27+
# Dependency directory
28+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
29+
node_modules
30+
31+
# Debug log from npm
32+
npm-debug.log
33+
34+
35+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
36+
37+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
38+
39+
*.iml
40+
41+
## Directory-based project format:
42+
.idea/
43+
# if you remove the above rule, at least ignore the following:
44+
45+
# User-specific stuff:
46+
# .idea/workspace.xml
47+
# .idea/tasks.xml
48+
# .idea/dictionaries
49+
50+
# Sensitive or high-churn files:
51+
# .idea/dataSources.ids
52+
# .idea/dataSources.xml
53+
# .idea/sqlDataSources.xml
54+
# .idea/dynamic.xml
55+
# .idea/uiDesigner.xml
56+
57+
# Gradle:
58+
# .idea/gradle.xml
59+
# .idea/libraries
60+
61+
# Mongo Explorer plugin:
62+
# .idea/mongoSettings.xml
63+
64+
## File-based project format:
65+
*.ipr
66+
*.iws
67+
68+
## Plugin-specific files:
69+
70+
# IntelliJ
71+
out/
72+
73+
# mpeltonen/sbt-idea plugin
74+
.idea_modules/
75+
76+
# JIRA plugin
77+
atlassian-ide-plugin.xml
78+
79+
# Crashlytics plugin (for Android Studio and IntelliJ)
80+
com_crashlytics_export_strings.xml
81+
crashlytics.properties
82+
crashlytics-build.properties
83+
84+
85+
/lib
86+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
87+
88+
# Logs
89+
logs
90+
*.log
91+
92+
# Runtime data
93+
pids
94+
*.pid
95+
*.seed
96+
97+
# Directory for instrumented libs generated by jscoverage/JSCover
98+
lib-cov
99+
100+
# Coverage directory used by tools like istanbul
101+
coverage
102+
103+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
104+
.grunt
105+
106+
# node-waf configuration
107+
.lock-wscript
108+
109+
# Compiled binary addons (http://nodejs.org/api/addons.html)
110+
build/Release
111+
112+
# Dependency directory
113+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
114+
node_modules
115+
116+
# Debug log from npm
117+
npm-debug.log
118+
119+
120+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
121+
122+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
123+
124+
*.iml
125+
126+
## Directory-based project format:
127+
.idea/
128+
# if you remove the above rule, at least ignore the following:
129+
130+
# User-specific stuff:
131+
# .idea/workspace.xml
132+
# .idea/tasks.xml
133+
# .idea/dictionaries
134+
135+
# Sensitive or high-churn files:
136+
# .idea/dataSources.ids
137+
# .idea/dataSources.xml
138+
# .idea/sqlDataSources.xml
139+
# .idea/dynamic.xml
140+
# .idea/uiDesigner.xml
141+
142+
# Gradle:
143+
# .idea/gradle.xml
144+
# .idea/libraries
145+
146+
# Mongo Explorer plugin:
147+
# .idea/mongoSettings.xml
148+
149+
## File-based project format:
150+
*.ipr
151+
*.iws
152+
153+
## Plugin-specific files:
154+
155+
# IntelliJ
156+
out/
157+
158+
# mpeltonen/sbt-idea plugin
159+
.idea_modules/
160+
161+
# JIRA plugin
162+
atlassian-ide-plugin.xml
163+
164+
# Crashlytics plugin (for Android Studio and IntelliJ)
165+
com_crashlytics_export_strings.xml
166+
crashlytics.properties
167+
crashlytics-build.properties
168+
169+
170+
/lib

Diff for: .travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sudo: false
2+
language: node_js
3+
node_js: "stable"

Diff for: LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 azu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

Diff for: README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# can-npm-publish
2+
3+
A command line tool that check to see if `npm publish` is possible.
4+
5+
## Check list
6+
7+
- [ ] Check that the package is not `private:true`
8+
- [ ] Check that `pacakge@version` is already published in npm registry
9+
10+
## Install
11+
12+
Install with [npm](https://www.npmjs.com/):
13+
14+
npm install can-npm-publish
15+
16+
## Usage
17+
18+
Run `can-npm-publish` before `npm publish`:
19+
20+
can-npm-publish && npm publish
21+
22+
### UseCase
23+
24+
You can use it for publishing without choice.
25+
For example, it is useful for using with [lerna](https://github.com/lerna/lerna "lerna").
26+
27+
Publish all packages if it is possible.
28+
29+
lerna exec -- can-npm-publish && npm publish
30+
31+
## Changelog
32+
33+
See [Releases page](https://github.com/azu/can-npm-publish/releases).
34+
35+
## Running tests
36+
37+
Install devDependencies and Run `npm test`:
38+
39+
npm i -d && npm test
40+
41+
## Contributing
42+
43+
Pull requests and stars are always welcome.
44+
45+
For bugs and feature requests, [please create an issue](https://github.com/azu/can-npm-publish/issues).
46+
47+
1. Fork it!
48+
2. Create your feature branch: `git checkout -b my-new-feature`
49+
3. Commit your changes: `git commit -am 'Add some feature'`
50+
4. Push to the branch: `git push origin my-new-feature`
51+
5. Submit a pull request :D
52+
53+
## Author
54+
55+
- [github/azu](https://github.com/azu)
56+
- [twitter/azu_re](https://twitter.com/azu_re)
57+
58+
## License
59+
60+
MIT © azu

Diff for: bin/cmd.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env node
2+
"use strict";
3+
const meow = require("meow");
4+
const canNpmPublish = require("../lib/can-npm-publish").canNpmPublish;
5+
const cli = meow(
6+
`
7+
Usage
8+
$ can-npm-publish [directory|pacakge.json path]
9+
10+
Examples
11+
$ can-npm-publish
12+
$ echo $? # 0 or 1
13+
`,
14+
{
15+
flags: {
16+
help: {
17+
type: "boolean",
18+
alias: "h"
19+
},
20+
verbose: {
21+
type: "boolean"
22+
}
23+
}
24+
}
25+
);
26+
if (cli.flags.help) {
27+
cli.showHelp();
28+
}
29+
30+
canNpmPublish(cli.input[0])
31+
.then(() => {
32+
process.exit(0);
33+
})
34+
.catch(error => {
35+
if (cli.flags.verbose) {
36+
console.log(error.message);
37+
}
38+
process.exit(1);
39+
});

Diff for: package.json

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "can-npm-publish",
3+
"version": "1.0.0",
4+
"description": "A command line tool that check to see if `npm publish` is possible.",
5+
"keywords": [
6+
"cli",
7+
"npm",
8+
"publish"
9+
],
10+
"homepage": "https://github.com/azu/can-npm-publish",
11+
"bugs": {
12+
"url": "https://github.com/azu/can-npm-publish/issues"
13+
},
14+
"license": "MIT",
15+
"author": "azu",
16+
"files": [
17+
"bin/",
18+
"lib/",
19+
"src/"
20+
],
21+
"main": "lib/can-npm-publish.js",
22+
"bin": {
23+
"can-npm-publish": "./bin/cmd.js"
24+
},
25+
"directories": {
26+
"lib": "lib",
27+
"test": "test"
28+
},
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/azu/can-npm-publish.git"
32+
},
33+
"scripts": {
34+
"test": "echo \"Error: no test specified\" && exit 1",
35+
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
36+
"precommit": "lint-staged",
37+
"postcommit": "git reset"
38+
},
39+
"dependencies": {
40+
"meow": "^4.0.0",
41+
"node-fetch": "^1.7.3",
42+
"read-pkg": "^3.0.0"
43+
},
44+
"devDependencies": {
45+
"husky": "^0.14.3",
46+
"lint-staged": "^6.0.1",
47+
"mocha": "^5.0.0",
48+
"prettier": "^1.10.2"
49+
},
50+
"prettier": {
51+
"singleQuote": false,
52+
"printWidth": 120,
53+
"tabWidth": 4
54+
},
55+
"lint-staged": {
56+
"*.{js,jsx,ts,tsx,css}": [
57+
"prettier --write",
58+
"git add"
59+
]
60+
}
61+
}

Diff for: test/can-npm-publish-test.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require("path");
2+
const assert = require("assert");
3+
const canNpmPublish = require("../lib/can-npm-publish").canNpmPublish;
4+
5+
const shouldNotCalled = () => {
6+
throw new Error("SHOULD NOT CALLED");
7+
};
8+
describe("can-npm-publish", () => {
9+
it("should be rejected, it is private:true", () => {
10+
return canNpmPublish(path.join(__dirname, "fixtures/private.json")).then(shouldNotCalled, error => {
11+
assert.ok(/This package is private/.test(error.message));
12+
});
13+
});
14+
it("should be rejected, it is already published", () => {
15+
return canNpmPublish(path.join(__dirname, "fixtures/already-published.json")).then(shouldNotCalled, error => {
16+
assert.ok(/is already published/.test(error.message));
17+
});
18+
});
19+
it("should be resolve, it is not published yet", () => {
20+
return canNpmPublish(path.join(__dirname, "fixtures/not-published-yet.json"));
21+
});
22+
});

0 commit comments

Comments
 (0)