Skip to content

Commit 6ecdcf0

Browse files
authored
v0.11.0
* feat(cmds): add `default-env` option to both `project` and `projectId` commands * chore(deps): update dev dependencies include eslint, mocha, nyc, @babel/cli and more
1 parent a38208e commit 6ecdcf0

File tree

6 files changed

+986
-3993
lines changed

6 files changed

+986
-3993
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
uses: actions/setup-node@v1
2323
with:
2424
node-version: 12
25+
registry-url: https://registry.npmjs.org/
2526

2627
- name: Get yarn cache
2728
id: yarn-cache
@@ -56,21 +57,20 @@ jobs:
5657
path: lib
5758

5859
- name: Publish To NPM
59-
run: npm publish $(if [ ${{github.ref}} == 'refs/heads/next' ]; then echo '--tag next';fi;)
6060
env:
6161
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62+
run: |
63+
npm publish $(if [ ${{github.ref}} == 'refs/heads/next' ]; then echo '--tag next';fi;)
6364
6465
- name: Upload Coverage + Climate
6566
if: success()
6667
env:
6768
CI: true
6869
CODE_COV: ${{ secrets.CODE_COV }}
6970
CODECLIMATE_REPO_TOKEN: ${{ secrets.CODE_CLIMATE }}
71+
# Upload to Code Coverage. Curl used in place of codecov/codecov-action
72+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
7073
run: |
71-
# Upload to Code Cover. Curl used in place of codecov/codecov-action
72-
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
7374
curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV
74-
# Install codeclimate tool and upload
7575
npm install -g codeclimate-test-reporter
7676
codeclimate-test-reporter < coverage/lcov.info

cmds/project.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ module.exports = function(program) {
1313
program
1414
.command('project')
1515
.description('Get name of project associated with current CI environment')
16+
.option(
17+
'-d, --default-env <envName>',
18+
'Default environment (used in place of master)'
19+
)
1620
.action((directory, options) => {
17-
const projectKey = getProjectName()
21+
const defaultProject = directory && directory.defaultEnv
22+
const projectKey = getProjectName(defaultProject && { defaultProject })
1823
if (!projectKey) {
1924
process.exit(1)
2025
} else {

cmds/projectId.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ module.exports = function(program) {
1313
program
1414
.command('projectId')
1515
.description('Get projectId of associated with current CI environment')
16+
.option(
17+
'-d, --default-env <envName>',
18+
'Default environment (used in place of master)'
19+
)
1620
.action((directory, options) => {
17-
const projectKey = getProjectId()
21+
const defaultProject = directory && directory.defaultEnv
22+
const projectKey = getProjectId(defaultProject && { defaultProject })
1823
if (!projectKey) {
1924
process.exit(1)
2025
} else {

package.json

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firebase-ci",
3-
"version": "0.10.0",
3+
"version": "0.11.0",
44
"description": "Simplified Firebase interaction for continuous integration including deploying hosting, functions, and database/storage rules.",
55
"main": "lib/index.js",
66
"bin": {
@@ -71,22 +71,21 @@
7171
"lodash": "^4.17.15"
7272
},
7373
"devDependencies": {
74-
"@babel/cli": "^7.7.0",
75-
"@babel/core": "^7.7.2",
76-
"@babel/plugin-transform-modules-commonjs": "^7.7.0",
77-
"@babel/preset-env": "^7.7.1",
78-
"@babel/register": "^7.7.0",
79-
"@jedmao/semantic-release-npm-github-config": "^1.0.8",
74+
"@babel/cli": "^7.7.7",
75+
"@babel/core": "^7.7.7",
76+
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
77+
"@babel/preset-env": "^7.7.7",
78+
"@babel/register": "^7.7.7",
8079
"babel-eslint": "^10.0.3",
8180
"babel-plugin-lodash": "^3.3.4",
82-
"babel-plugin-module-resolver": "^3.2.0",
81+
"babel-plugin-module-resolver": "^4.0.0",
8382
"chai": "^4.2.0",
8483
"chai-files": "^1.4.0",
8584
"codecov": "^3.6.1",
8685
"cross-env": "^6.0.3",
8786
"env-cmd": "^10.0.1",
88-
"eslint": "^6.6.0",
89-
"eslint-config-prettier": "^6.5.0",
87+
"eslint": "^6.8.0",
88+
"eslint-config-prettier": "^6.9.0",
9089
"eslint-config-standard": "^14.1.0",
9190
"eslint-plugin-babel": "^5.3.0",
9291
"eslint-plugin-import": "^2.18.2",
@@ -95,13 +94,12 @@
9594
"eslint-plugin-prettier": "^3.1.0",
9695
"eslint-plugin-promise": "^4.2.0",
9796
"eslint-plugin-standard": "^4.0.0",
98-
"husky": "^3.0.9",
99-
"mocha": "^6.2.2",
100-
"nyc": "^14.1.1",
101-
"prettier": "^1.18.2",
97+
"husky": "^4.0.0",
98+
"mocha": "^7.0.0",
99+
"nyc": "^15.0.0",
100+
"prettier": "^1.19.1",
102101
"rimraf": "^3.0.0",
103-
"semantic-release": "^15.13.31",
104-
"sinon": "^7.5.0",
105-
"sinon-chai": "^3.3.0"
102+
"sinon": "^8.0.4",
103+
"sinon-chai": "^3.4.0"
106104
}
107105
}

src/utils/ci.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ export function getProjectKey(opts) {
6565
export function getProjectName(opts) {
6666
const projectKey = getProjectKey(opts)
6767
const firebaserc = getFile('.firebaserc')
68-
return get(
69-
firebaserc,
70-
`projects.${projectKey}`,
71-
get(firebaserc, 'projects.master', get(firebaserc, 'projects.default'))
68+
return (
69+
get(firebaserc, `projects.${projectKey}`) ||
70+
(opts &&
71+
opts.defaultProject &&
72+
get(firebaserc, `projects.${opts.defaultProject}`)) ||
73+
get(firebaserc, 'projects.master') ||
74+
get(firebaserc, 'projects.default')
7275
)
7376
}
7477

@@ -81,9 +84,21 @@ export function getProjectName(opts) {
8184
export function getProjectId(opts) {
8285
const projectKey = getProjectKey(opts)
8386
const firebaserc = getFile('.firebaserc')
87+
console.log('project key', projectKey)
8488
return (
8589
process.env.FIREBASE_CI_PROJECT ||
86-
get(firebaserc, `ci.createConfig.${projectKey}.firebase.projectId`) ||
90+
get(
91+
firebaserc,
92+
`ci.createConfig.${
93+
projectKey === 'default' ? 'master' : projectKey
94+
}.firebase.projectId`
95+
) ||
96+
(opts &&
97+
opts.defaultProject &&
98+
get(
99+
firebaserc,
100+
`ci.createConfig.${opts.defaultProject}.firebase.projectId`
101+
)) ||
87102
get(firebaserc, `ci.createConfig.master.firebase.projectId`) ||
88103
getProjectName(opts)
89104
)

0 commit comments

Comments
 (0)