Skip to content

Commit 5c0325f

Browse files
feat: hook up ci to publish to npm (#226)
* chore: add missing fields to package.json * feat: add postlight org scope to package name * feat: automate npm publish * test: npm publish without filters * fix: add docker image * test: change directory * test: add working directory * fix: defaults syntax * test: add workspace * fix: attach workspace * fix: use standard mercury email * fix: use ISO time format and preserve original timezone offset * fix: do not match time zone offset * chore: move babel runtime-corejs2 to prod deps * chore: uncomment config to deploy on git tag * feat: publish to npm public * adding browser-request It doesn't seem to impact the build, but technically it should be there so for good measure, why not... * chore: roll version back to original state
1 parent 663cc45 commit 5c0325f

5 files changed

Lines changed: 83 additions & 32 deletions

File tree

.circleci/config.yml

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,74 @@
11
version: 2
2+
3+
defaults: &defaults
4+
working_directory: ~/repo
5+
docker:
6+
- image: circleci/node:8.10-browsers
7+
28
jobs:
39
test-node:
4-
docker:
5-
- image: circleci/node:8.10-browsers
10+
<<: *defaults
611
steps:
712
- checkout
813
# For some reason phantomjs-prebuild is failing w/yarn, but npm installing works
9-
- run: "npm install phantomjs-prebuilt"
10-
- run: "yarn install"
11-
- run: "yarn lint:ci"
12-
- run: "yarn build:ci"
13-
- run: "yarn test:node --maxWorkers=4"
14-
- run: "./scripts/pr-parser-preview.sh"
15-
14+
- run: 'npm install phantomjs-prebuilt'
15+
- run: 'yarn install'
16+
- run: 'yarn lint:ci'
17+
- run: 'yarn build:ci'
18+
- run: 'yarn test:node --maxWorkers=4'
19+
- run: './scripts/pr-parser-preview.sh'
1620
- store_artifacts:
1721
path: tmp/artifacts
22+
- persist_to_workspace:
23+
root: ~/repo
24+
paths: .
1825

1926
test-web:
20-
docker:
21-
- image: circleci/node:8.10-browsers
27+
<<: *defaults
2228
steps:
29+
- attach_workspace:
30+
at: ~/repo
2331
- checkout
24-
- run: "yarn install"
25-
- run: "yarn add karma-cli --dev"
26-
- run: "yarn test:web --maxWorkers=4"
27-
- run: "yarn build:web:ci --maxWorkers=4"
32+
- run: 'yarn install'
33+
- run: 'yarn add karma-cli --dev'
34+
- run: 'yarn test:web --maxWorkers=4'
35+
- run: 'yarn build:web:ci --maxWorkers=4'
36+
37+
deploy:
38+
<<: *defaults
39+
steps:
40+
- attach_workspace:
41+
at: ~/repo
42+
- run:
43+
name: Authenticate with registry
44+
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
45+
- run:
46+
name: Publish package
47+
command: npm publish --access public
2848

2949
update-fixtures:
3050
docker:
3151
- image: circleci/node:8.10
3252
steps:
3353
- checkout
34-
- run: "yarn install"
35-
- run: "node ./scripts/update-fixtures.js"
36-
54+
- run: 'yarn install'
55+
- run: 'node ./scripts/update-fixtures.js'
3756

3857
workflows:
3958
version: 2
4059
build_and_test:
4160
jobs:
4261
- test-node
4362
- test-web
63+
- deploy:
64+
requires:
65+
- test-node
66+
- test-web
67+
filters:
68+
tags:
69+
only: /^v.*/
70+
branches:
71+
ignore: /.*/
4472
# UNCOMMENT WHEN READY TO AUTOMATE THIS TASK
4573
# scheduled_tasks:
4674
# triggers:

package.json

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
{
2-
"name": "mercury-parser",
2+
"name": "@postlight/mercury-parser",
33
"version": "1.0.13",
4-
"description": "",
5-
"repository": "github:postlight/mercury-parser",
4+
"description": "Mercury transforms web pages into clean text. Publishers and programmers use it to make the web make sense, and readers use it to read any web article comfortably.",
5+
"author": "Postlight <[email protected]>",
6+
"homepage": "https://mercury.postlight.com",
7+
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/postlight/mercury-parser.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/postlight/mercury-parser/issues"
14+
},
15+
"keywords": [
16+
"mercury",
17+
"parser",
18+
"reader",
19+
"web",
20+
"content"
21+
],
622
"main": "./dist/mercury.js",
723
"scripts": {
824
"lint": "eslint . --fix",
@@ -25,15 +41,15 @@
2541
"add-contributor": "all-contributors add",
2642
"generate-contributors": "all-contributors generate"
2743
},
28-
"author": "Postlight",
29-
"license": "ISC",
44+
"engines": {
45+
"node": ">=8.10"
46+
},
3047
"devDependencies": {
3148
"@babel/core": "^7.0.0",
3249
"@babel/plugin-transform-runtime": "^7.0.0",
3350
"@babel/polyfill": "^7.0.0",
3451
"@babel/preset-env": "^7.0.0",
3552
"@babel/runtime": "^7.0.0",
36-
"@babel/runtime-corejs2": "^7.2.0",
3753
"@jesses/circle-github-bot": "^2.1.0",
3854
"@octokit/rest": "^16.9.0",
3955
"all-contributors-cli": "^5.10.0",
@@ -87,22 +103,28 @@
87103
"watchify": "^3.11.0"
88104
},
89105
"dependencies": {
90-
"browser-request": "postlight/browser-request#feat-add-headers-to-response",
106+
"browser-request": "github:postlight/browser-request#feat-add-headers-to-response",
91107
"cheerio": "^0.22.0",
92-
"difflib": "postlight/difflib.js",
108+
"difflib": "github:postlight/difflib.js",
93109
"ellipsize": "0.1.0",
94110
"iconv-lite": "0.4.24",
95111
"jquery": "^3.3.1",
96112
"moment": "^2.23.0",
97113
"moment-parseformat": "3.0.0",
98114
"moment-timezone": "0.5.23",
99-
"request": "czardoz/request",
115+
"request": "github:czardoz/request",
100116
"request-promise": "^4.2.2",
101117
"string-direction": "^0.1.2",
102118
"url": "^0.11.0",
103119
"valid-url": "^1.0.9",
104-
"wuzzy": "^0.1.3"
120+
"wuzzy": "^0.1.3",
121+
"@babel/runtime-corejs2": "^7.2.0"
105122
},
123+
"bundleDependencies": [
124+
"jquery",
125+
"moment-timezone",
126+
"browser-request"
127+
],
106128
"browser": {
107129
"main": "./dist/mercury.web.js",
108130
"cheerio": "./src/shims/cheerio-query",

scripts/get-test-report.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ${failedTests
4848
`;
4949
return failureReport;
5050
} catch (e) {
51+
// eslint-disable-next-line no-console
5152
console.log('Error generating test report', e);
5253
return false;
5354
}

src/extractors/custom/www.fastcompany.com/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('WwwFastcompanyComExtractor', () => {
5959

6060
// Update these values with the expected values from
6161
// the article.
62-
assert.equal(date_published, '2017-01-09T05:00:00.000Z');
62+
assert.equal(date_published.split('T')[0], '2017-01-09');
6363
});
6464

6565
it('returns the dek', async () => {

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ browser-process-hrtime@^0.1.2:
16931693
resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz#616f00faef1df7ec1b5bf9cfe2bdc3170f26c7b4"
16941694
integrity sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==
16951695

1696-
browser-request@postlight/browser-request#feat-add-headers-to-response:
1696+
"browser-request@github:postlight/browser-request#feat-add-headers-to-response":
16971697
version "0.3.2"
16981698
resolved "https://codeload.github.com/postlight/browser-request/tar.gz/38faa5b85741aabfca61aa37d1ef044d68969ddf"
16991699
dependencies:
@@ -2898,7 +2898,7 @@ diffie-hellman@^5.0.0:
28982898
miller-rabin "^4.0.0"
28992899
randombytes "^2.0.0"
29002900

2901-
difflib@postlight/difflib.js:
2901+
"difflib@github:postlight/difflib.js":
29022902
version "0.2.6"
29032903
resolved "https://codeload.github.com/postlight/difflib.js/tar.gz/32e8e38c7fcd935241b9baab71bb432fd9b166ed"
29042904
dependencies:
@@ -8158,7 +8158,7 @@ request@^2.87.0:
81588158
tunnel-agent "^0.6.0"
81598159
uuid "^3.3.2"
81608160

8161-
request@czardoz/request:
8161+
"request@github:czardoz/request":
81628162
version "2.74.1"
81638163
resolved "https://codeload.github.com/czardoz/request/tar.gz/6ebb4651b72bee7292e54943adfa6b503465adfb"
81648164
dependencies:

0 commit comments

Comments
 (0)