Skip to content

Commit

Permalink
Initial open source version
Browse files Browse the repository at this point in the history
  • Loading branch information
gcorne committed Oct 17, 2019
0 parents commit 7a3e831
Show file tree
Hide file tree
Showing 116 changed files with 13,972 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
tmp
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
extends: 'eslint:recommended',
root: true,
env: {
browser: false,
node: true,
commonjs: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
'no-console': 'off',
'no-return-await': 'error',
},

overrides: [
{
files: ['**/__tests__/**/*.js', '**/__mocks__/**/*.js'],
env: {
jest: true,
node: true,
},
},
],
};
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
tmp
context
coverage
hubspot.config.yml
lerna-debug.log
npm-debug.log
npm-debug.log.*
*.log
.DS_Store
coverage

47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Change Log
==========

## Next

### CMS CLI

* Added *modes* to specify if read/write commands should use either the `draft` or `publish` mode.
* Added the `--mode` option for use with commands `upload`, `watch`, and `fetch`.
* Added the `defaultMode` field for use in `hubspot.config.yml` files.
* Set the fallback mode to `publish`.
* Removed the `--portalId` option. The `--portal` option accepts both portal ids and config names.
* Consolidated uploading of files and folders into the `upload` command. The `sync` command is no longer supported, use `upload` instead.

## 0.0.21

### CMS CLI

* Adjust `create` command and add ability to create templates
* Improve fetching of files
* Refine built-in help
* Fix path handling in older versions of `node`

## 0.0.13

### CMS CLI

* Fix OAuth2 authentication flow when the config file is empty
* Better handle paths when running `sync` and `upload` sub-commands

## 0.0.12

### CMS CLI

* Fix issues with using the tools on Windows when uploading files
* Add `fetch` command to download assets from HubSpot
* Add Apache 2.0 license

## 0.0.11

### CMS CLI

* Add ability to name portals in config and set a default portal

## 0.0.10

Initial version
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing
## Setup

* Install the dependencies

```bash
yarn
```

* Bootstrap `lerna`

In order to manage multiple npm packages in the same Github repos, we use [lerna](https://lerna.js.org/).

```bash
yarn lerna bootstrap
````

* To test a command

First, you will need to create a config for the portals that you want to be able to test using.

Once the config is created, commands can be run by providing a path to the executable file:

```
yarn hscms upload --portalId [src] [dest]`
```
* To test a command when `@hubspot/cms-cli` is a dependency in another package like `cms-theme-boilerplate`.
In order to test changes in another npm package that is using `@hubspot/cms-cli`, [yarn link](https://yarnpkg.com/lang/en/docs/cli/link/) can be used.
```bash
cd /path/to/other-npm-package
yarn link @hubspot/cms-cli
```

## Documentation

- [Technical Design](./docs/TechnicalDesign.md)
- [Publishing Releases](./docs/PublishingReleases.md)
- [Debugging](./docs/Debugging.md)
12 changes: 12 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright 2019 HubSpot, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# hubspot-cms-tools
Node packages intended for HubSpot CMS developers to enable local development and advanced workflows like continuous deployment.

## Getting Started

See the `@hubspot/cms-cli` [README](./packages/cms-cli/README.md).


## Contributing

For more information on developing, see the [Contributing Guide](CONTRIBUTING.md).

8 changes: 8 additions & 0 deletions docs/Debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Debugging
========

It is possible to debug the CLI using the Chrome developer tools.

1. Run command via `node --inspect-brk ./packages/cms-cli/bin/hscms.js`
2. Open `about:inspect` in Chrome
3. Click "Open dedicated DevTools for Node"
20 changes: 20 additions & 0 deletions docs/PublishingReleases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[lerna]: https://github.com/lerna/lerna
[from-package]: https://github.com/lerna/lerna/tree/master/commands/publish#bump-from-package

Publishing Releases
===================

We're using [lerna][lerna] to make managing multiple packages in the same repos easier.

Before releasing a new version, it is a good idea to release a prerelease so that folks can test out the changes.

## Publishing a new version

1. Run `yarn publish-release`. The publish command will handle bumping the version, tagging via git, and publishing the packages to NPM.
1. If there are publishing errors, you can run again via `yarn lerna publish from-package` ([Docs][from-package]).

## Publishing a prerelease

1. Run `yarn publish-prerelease`. The publish command will handle bumping the version, tagging via git, and publishing the packages to NPM under the `next` dist-tag.
1. If there are publishing errors, you can run again via `yarn lerna publish from-package` ([Docs][from-package]).

19 changes: 19 additions & 0 deletions docs/TechnicalDesign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Technical Design

To provide CMS developers with a flexible and powerful set of tools, the technical design is as follows:

1. The commands should follow Unix best practices in terms of composibility. See [Unix Philosophy](https://en.wikipedia.org/wiki/Unix_philosophy)

```
Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.
```

2. Don't prescribe a particular node task runner (Gulp, Grunt, etc...). Instead work to separate the cli from the underlying functionality so that we can easily create a library separate from the CLI for use in the creation of tasks.

3. Support multiple portals. It should be easy to run the commands against multiple portals.

4. Minimize dependencies.

5. Plan for the code to be open source.
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
projects: ['<rootDir>/packages/*'],
collectCoverage: true,
};
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
"version": "0.0.26"
}
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "hubspot-cms-tools",
"version": "1.0.0",
"description": "Tooling for interacting with the HubSpot CMS",
"repository": "https://github.com/HubSpot/hubspot-cms-tools",
"devDependencies": {
"eslint": "^6.5.1",
"husky": "^1.3.1",
"lerna": "^3.13.1",
"lint-staged": "^8.1.4",
"prettier": "^1.18.2"
},
"workspaces": [
"packages/*"
],
"scripts": {
"lint": "eslint . && prettier --list-different 'packages/**/*.{js,json}'",
"prettier:write": "prettier --write 'packages/**/*.{js,json}'",
"publish-release": "yarn lerna publish --conventional-graduate",
"publish-prerelease": "yarn lerna publish prerelease --preid beta --dist-tag next",
"test": "jest"
},
"lint-staged": {
"**/*.{js,scss,css}": [
"prettier -l",
"eslint"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"dependencies": {
"jest": "^24.8.0"
}
}
5 changes: 5 additions & 0 deletions packages/api-auth-lib/Errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class HubSpotAuthError extends Error {}

module.exports = {
HubSpotAuthError,
};
Loading

0 comments on commit 7a3e831

Please sign in to comment.