├── .editorconfig
├── .gitignore
├── .travis.yml
├── ARCHITECTURE.md
├── INSTALL.md
├── LICENSE.md
├── README.md
├── brand
├── AppCenter-transparent.png
├── AppCenter.png
└── AppCenter.svg
├── build
├── README.md
├── common.ts
└── gulpfile.ts
├── config.example.js
├── nuxt.config.js
├── package-lock.json
├── package.json
├── src
├── README.md
├── app.ts
├── bin.js
├── bootstrap.js
├── cli
│ ├── cli.ts
│ ├── commands
│ │ ├── build.ts
│ │ ├── ci.ts
│ │ ├── index.ts
│ │ ├── migrate.ts
│ │ ├── repo.ts
│ │ ├── seed.ts
│ │ └── version.ts
│ └── utilities.ts
├── client
│ ├── README.md
│ ├── components
│ │ └── the-navbar.vue
│ ├── fonts
│ │ └── open-sans
│ │ │ ├── LICENSE.txt
│ │ │ ├── bold-italic.ttf
│ │ │ ├── bold.ttf
│ │ │ ├── extra-bold-italic.ttf
│ │ │ ├── extra-bold.ttf
│ │ │ ├── italic.ttf
│ │ │ ├── light-italic.ttf
│ │ │ ├── light.ttf
│ │ │ ├── regular.ttf
│ │ │ ├── semi-bold-italic.ttf
│ │ │ └── semi-bold.ttf
│ ├── images
│ │ └── brand
│ │ │ └── elementary-logomark.svg
│ ├── layouts
│ │ ├── blank.vue
│ │ └── default.vue
│ └── pages
│ │ ├── error.vue
│ │ └── index.vue
├── lib
│ ├── app.ts
│ ├── cache
│ │ ├── index.ts
│ │ ├── provider.ts
│ │ └── type.ts
│ ├── config
│ │ ├── config.ts
│ │ ├── index.ts
│ │ └── loader.ts
│ ├── database
│ │ ├── README.md
│ │ ├── database.ts
│ │ ├── index.ts
│ │ ├── migration
│ │ │ ├── 2.0.0-001-github_repositories.ts
│ │ │ ├── 2.0.0-002-github_releases.ts
│ │ │ ├── 2.0.0-003-users.ts
│ │ │ ├── 2.0.0-004-github_users.ts
│ │ │ ├── 2.0.0-005-github_repositories_github_users.ts
│ │ │ ├── 2.0.0-006-stripe_accounts.ts
│ │ │ ├── 2.0.0-007-projects.ts
│ │ │ ├── 2.0.0-008-releases.ts
│ │ │ ├── 2.0.0-009-builds.ts
│ │ │ └── 2.0.0-010-build_logs.ts
│ │ ├── provider.ts
│ │ └── seed
│ │ │ ├── 001-github_repositories.ts
│ │ │ ├── 002-github_releases.ts
│ │ │ ├── 003-users.ts
│ │ │ ├── 004-github_users.ts
│ │ │ ├── 005-github_repositories_github_users.ts
│ │ │ ├── 006-stripe_accounts.ts
│ │ │ ├── 007-projects.ts
│ │ │ ├── 008-releases.ts
│ │ │ └── 009-builds.ts
│ ├── log
│ │ ├── index.ts
│ │ ├── level.ts
│ │ ├── log.ts
│ │ ├── logger.ts
│ │ ├── output.ts
│ │ ├── outputs
│ │ │ ├── console.ts
│ │ │ ├── index.ts
│ │ │ └── sentry.ts
│ │ └── provider.ts
│ ├── queue
│ │ ├── index.ts
│ │ ├── provider.ts
│ │ ├── providers
│ │ │ └── redis
│ │ │ │ ├── index.ts
│ │ │ │ ├── job.ts
│ │ │ │ └── queue.ts
│ │ └── type.ts
│ ├── service
│ │ ├── aptly.ts
│ │ ├── github.ts
│ │ ├── index.ts
│ │ ├── provider.ts
│ │ └── type.ts
│ └── utility
│ │ ├── eventemitter.ts
│ │ ├── glob.ts
│ │ ├── markdown.ts
│ │ ├── rdnn.ts
│ │ └── template.ts
├── repo
│ ├── README.md
│ ├── provider.ts
│ └── repo.ts
└── worker
│ ├── README.md
│ ├── docker.ts
│ ├── index.ts
│ ├── log.ts
│ ├── preset
│ ├── build.ts
│ └── release.ts
│ ├── provider.ts
│ ├── task
│ ├── appstream
│ │ ├── description.ts
│ │ ├── exist.md
│ │ ├── id.ts
│ │ ├── index.md
│ │ ├── index.ts
│ │ ├── license.ts
│ │ ├── name.ts
│ │ ├── release.ts
│ │ ├── screenshot.ts
│ │ ├── stripe.ts
│ │ ├── summary.ts
│ │ ├── validate.md
│ │ ├── validate.ts
│ │ └── validate
│ │ │ └── Dockerfile
│ ├── build
│ │ ├── deb.md
│ │ ├── deb.ts
│ │ └── deb
│ │ │ ├── Dockerfile
│ │ │ └── liftoff_0.1_amd64.deb
│ ├── debian
│ │ ├── changelog.ts
│ │ ├── changelogTemplate.ejs
│ │ ├── control.md
│ │ └── control.ts
│ ├── desktop
│ │ ├── exec.ts
│ │ ├── icon.ts
│ │ ├── index.ts
│ │ ├── validate.md
│ │ ├── validate.ts
│ │ └── validate
│ │ │ └── Dockerfile
│ ├── extract
│ │ ├── deb.ts
│ │ └── deb
│ │ │ ├── Dockerfile
│ │ │ └── extract-deb.sh
│ ├── file
│ │ ├── deb.ts
│ │ └── deb
│ │ │ ├── binary.md
│ │ │ ├── binary.ts
│ │ │ ├── nonexistent.ts
│ │ │ └── nonexistentLog.md
│ ├── pack
│ │ ├── deb.ts
│ │ └── deb
│ │ │ ├── Dockerfile
│ │ │ └── pack-deb.sh
│ ├── task.ts
│ ├── upload
│ │ ├── index.ts
│ │ ├── log.md
│ │ ├── log.spec.ts
│ │ ├── log.ts
│ │ ├── package.md
│ │ ├── package.spec.ts
│ │ └── package.ts
│ ├── workspace
│ │ └── setup.ts
│ └── wrapperTask.ts
│ ├── type.ts
│ └── worker.ts
├── test
├── bootstrap.js
├── e2e
│ ├── lib
│ │ ├── log
│ │ │ └── outputs
│ │ │ │ └── console.ts
│ │ └── service
│ │ │ ├── aptly.ts
│ │ │ └── github.ts
│ └── worker
│ │ ├── docker.ts
│ │ ├── task
│ │ └── debian
│ │ │ └── changelog.ts
│ │ └── worker.ts
├── fixture
│ ├── config.js
│ ├── lib
│ │ └── service
│ │ │ ├── aptly
│ │ │ └── asset.json
│ │ │ └── github
│ │ │ ├── asset.json
│ │ │ ├── installation.json
│ │ │ ├── key.pem
│ │ │ ├── log.json
│ │ │ └── vocal.deb
│ └── worker
│ │ ├── docker
│ │ └── image1
│ │ │ └── Dockerfile
│ │ ├── log
│ │ └── test1.md
│ │ └── task
│ │ ├── appstream
│ │ ├── blank.xml
│ │ └── spice-up.xml
│ │ ├── debian
│ │ └── control
│ │ │ ├── gold1
│ │ │ └── gold2
│ │ ├── desktop
│ │ ├── blank.desktop
│ │ └── spice-up.desktop
│ │ └── empty
├── spec
│ ├── lib
│ │ ├── config
│ │ │ ├── index.ts
│ │ │ └── loader.ts
│ │ ├── log
│ │ │ ├── level.ts
│ │ │ └── log.ts
│ │ ├── queue
│ │ │ └── provider.ts
│ │ ├── service
│ │ │ ├── aptly.ts
│ │ │ └── github.ts
│ │ └── utility
│ │ │ ├── eventemitter.ts
│ │ │ ├── glob.ts
│ │ │ └── rdnn.ts
│ └── worker
│ │ ├── log.ts
│ │ ├── preset
│ │ └── release.ts
│ │ └── task
│ │ ├── appstream
│ │ ├── id.ts
│ │ ├── index.ts
│ │ ├── release.ts
│ │ ├── screenshot.ts
│ │ ├── stripe.ts
│ │ └── validate.ts
│ │ ├── debian
│ │ ├── changelog.ts
│ │ └── control.ts
│ │ ├── desktop
│ │ ├── index.ts
│ │ └── validate.ts
│ │ ├── file
│ │ └── deb
│ │ │ └── binary.ts
│ │ └── workspace
│ │ └── setup.ts
└── utility
│ ├── app.ts
│ ├── ci.ts
│ ├── config.ts
│ ├── database.ts
│ ├── docker.ts
│ ├── fs.ts
│ ├── http.ts
│ └── worker
│ ├── context.ts
│ ├── index.ts
│ ├── mock.ts
│ ├── repository.ts
│ └── worker.ts
├── tsconfig.json
├── tsconfig.production.json
└── tslint.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | [*]
7 | charset = utf-8
8 | end_of_line = lf
9 | insert_final_newline = true
10 | trim_trailing_whitespace = true
11 |
12 | # Enforce the one true coding standard
13 | [*]
14 | indent_size = 2
15 | indent_style = space
16 |
17 | # Set the max line count
18 | [*.md]
19 | max_line_length = 80
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # General files
2 | *.log
3 | *.tmp
4 |
5 | # Application files
6 | .cache
7 | /config*
8 | coverage/
9 | .nyc_output
10 | dest/
11 | .nuxt
12 |
13 | !config.example.js
14 |
15 | # Node files
16 | node_modules
17 |
18 | # OS files
19 | .DS_Store
20 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | language: node_js
4 |
5 | sudo: required
6 |
7 | services:
8 | - docker
9 |
10 | addons:
11 | apt:
12 | sources:
13 | - ubuntu-toolchain-r-test
14 | packages:
15 | - libstdc++-4.9-dev
16 |
17 | node_js: 10
18 |
19 | cache:
20 | directories:
21 | - /tmp/liftoff
22 |
23 | script:
24 | - npm run build
25 | - npm run lint
26 | - npm run ci:test
27 |
28 | jobs:
29 | include:
30 | - stage: Test
31 | node_js: 10
32 |
33 | - node_js: 12
34 |
35 | - stage: Release
36 | script: npm run build
37 | deploy:
38 | provider: script
39 | skip_cleanup: true
40 | script: npm run ci:release
41 | on:
42 | repo: elementary/houston
43 | branch: v2
44 |
--------------------------------------------------------------------------------
/ARCHITECTURE.md:
--------------------------------------------------------------------------------
1 | # Houston Architecture
2 |
--------------------------------------------------------------------------------
/INSTALL.md:
--------------------------------------------------------------------------------
1 | # Installing Houston
2 |
3 | ## Needed Services
4 |
5 | To setup Houston you will need a working node environment. Each operating system
6 | is different, so it's best to refer to the official
7 | [node documentation](https://nodejs.org/en/download/) on installing.
8 |
9 | **NOTE** If you are only wanting to run the worker process for `houston ci`
10 | or `houston build`, you _only_ need to install Docker. If you install Docker
11 | on the same machine as Houston, you _should_ need _no_ additional
12 | configuration.
13 |
14 | For a fully working installation you will want to ensure all of these
15 | services are setup, working, and fully accessible to Houston.
16 |
17 | You will need:
18 |
19 | - A [Knexjs supported database](http://knexjs.org/#Installation-node)
20 | - An [Aptly repository](https://www.aptly.info/)
21 | - A **local** [Docker](https://www.docker.com/) server
22 | - A [GitHub OAuth](https://github.com/organizations/elementary/settings/applications) application
23 | - A [Stripe connect](https://dashboard.stripe.com/account/applications/settings) account
24 | - A [Mandrill](https://mandrillapp.com) account
25 |
26 | ## Package
27 |
28 | Simply run `npm i -g @elementaryos/houston`.
29 |
30 | _NOTE: Depending on how you installed node, you may have to run the above command
31 | with `sudo`._
32 |
33 | ## Source
34 |
35 | First, `git clone` this repo.
36 |
37 | Next you will need to install the needed node packages. This is done with:
38 | ```shell
39 | npm ci
40 | ```
41 |
42 | Then build Houston with:
43 | ```shell
44 | npm run build
45 | ```
46 |
47 | Then install it with:
48 | ```shell
49 | npm link
50 | ```
51 |
52 | _NOTE: Depending on how you installed node, you may have to run the above command
53 | with `sudo`._
54 |
55 | You will need to setup your configuration. Simply copy the `config.example.js`
56 | file to another location and edit it's values. This file is well documented with
57 | possible values and links to needed third party services.
58 |
59 | Lastly, you can run houston with:
60 | ```shell
61 | houston
62 | ```
63 |
64 | For a full list of commands run:
65 | ```shell
66 | houston --help
67 | ```
68 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # The MIT License (MIT)
2 |
3 | ### Copyright © 2018 elementary & [contributors](https://github.com/elementary/houston/graphs/contributors)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | -----------------------------------------------------------------------------
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # This is the old AppCenter Dashboard for elementary OS 5.1 and older. You may be looking for the [new Flatpak-based AppCenter Dashboard](https://github.com/elementary/appcenter-dashboard) or the new [AppCenter Reviews repo](https://github.com/elementary/appcenter-reviews).
2 |
3 | ---
4 |
5 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | ---
29 |
30 | > Houston is currently undergoing a rewrite to typescript with an emphasis on
31 | testability. Currently, the only part used in production for v2 is the worker
32 | process. Everything else will be found in the master branch.
33 |
34 | Houston is part of AppCenter, a multi component system for helping developers
35 | and making users' life easier. Houston includes processes for building, testing,
36 | and publishing packages, as well as the front end website.
37 |
38 | For more information about the architecture and processes that make up Houston
39 | please see the [architecture
40 | file](https://github.com/elementary/houston/blob/v2/ARCHITECTURE.md).
41 |
42 | For development information see the [various readme
43 | files](https://github.com/elementary/houston/blob/v2/src/README.md) in the
44 | `src/` directory.
45 |
46 | For building and setting up your own instance read the
47 | [install file](https://github.com/elementary/houston/blob/v2/INSTALL.md).
48 |
--------------------------------------------------------------------------------
/brand/AppCenter-transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/brand/AppCenter-transparent.png
--------------------------------------------------------------------------------
/brand/AppCenter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/brand/AppCenter.png
--------------------------------------------------------------------------------
/build/README.md:
--------------------------------------------------------------------------------
1 | # houston/build/
2 |
3 | This folder holds everything needed to build houston. If you need to change
4 | something about the build, chances are it will be in `common.ts`. We use `gulp`
5 | to run all of the needed tasks. This includes building javascript files,
6 | and building client side assets like CSS and images.
7 |
--------------------------------------------------------------------------------
/build/common.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/build/common.ts
3 | * Holds common build values like directories and stuff
4 | *
5 | * @exports {object} paths - A list of paths to use when building
6 | * @exports {string[]} browsers - A list of browsers to support
7 | */
8 |
9 | import * as path from 'path'
10 |
11 | /**
12 | * paths
13 | * A list of paths to use when building
14 | *
15 | * @var {object}
16 | */
17 | export const paths = {
18 | dest: path.resolve(__dirname, '..', 'dest'),
19 | root: path.resolve(__dirname, '..'),
20 | src: path.resolve(__dirname, '..', 'src')
21 | }
22 |
23 | /**
24 | * browsers
25 | * A list of all browsers we should support when building client side assets
26 | *
27 | * @var {string[]}
28 | */
29 | export const browsers = ['last 2 version']
30 |
--------------------------------------------------------------------------------
/build/gulpfile.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/build/gulpfile.ts
3 | * Builds all of houston. Places everything in houston/dest directory.
4 | */
5 |
6 | import * as fs from 'fs-extra'
7 | import * as gulp from 'gulp'
8 | import * as path from 'path'
9 |
10 | import * as sourcemap from 'gulp-sourcemaps'
11 |
12 | import * as typescript from 'gulp-typescript'
13 |
14 | import * as common from './common'
15 |
16 | const tsConfig = path.resolve(common.paths.root, 'tsconfig.production.json')
17 | const tsProject = typescript.createProject(tsConfig)
18 |
19 | /**
20 | * clean
21 | * Removes the build directory
22 | *
23 | * @async
24 | * @return {string[]} - A list of removed files
25 | */
26 | gulp.task('clean', () => {
27 | return fs.remove(common.paths.dest)
28 | })
29 |
30 | /**
31 | * copy
32 | * Copies over files that do not need to be built, but must be in project folder
33 | *
34 | * @return {stream} - A gulp task
35 | */
36 | gulp.task('copy', () => {
37 | const src = path.resolve(common.paths.src)
38 | const dest = path.resolve(common.paths.dest)
39 |
40 | return gulp.src([
41 | path.resolve(src, '**/*'),
42 | '!' + path.resolve(src, '**/*.ts')
43 | ], { base: src })
44 | .pipe(gulp.dest(dest))
45 | })
46 |
47 | /**
48 | * typescript
49 | * Builds all typescript files into regular javascript files
50 | *
51 | * @return {stream} - A gulp task
52 | */
53 | gulp.task('typescript', () => {
54 | const src = path.resolve(common.paths.src)
55 | const dest = path.resolve(common.paths.dest)
56 |
57 | return gulp.src([
58 | path.resolve(src, '**', '*.ts'),
59 | '!' + path.resolve(src, '**', '*.e2e.ts'),
60 | '!' + path.resolve(src, '**', '*.spec.ts')
61 | ], { base: src })
62 | .pipe(sourcemap.init())
63 | .pipe(tsProject())
64 | .pipe(sourcemap.write('.'))
65 | .pipe(gulp.dest(dest))
66 | })
67 |
68 | /**
69 | * build
70 | * Builds all houston assets
71 | *
72 | * @return {stream} - A gulp task
73 | */
74 | gulp.task('build', gulp.series('clean', gulp.parallel('copy', 'typescript')))
75 |
76 | /**
77 | * watch
78 | * Builds all the houston assets, but watches for changes for faster building
79 | *
80 | * @return {void}
81 | */
82 | gulp.task('watch', () => {
83 | const src = path.resolve(common.paths.src, '**', '*.ts')
84 |
85 | return gulp.watch(src, gulp.series('typescript'))
86 | })
87 |
--------------------------------------------------------------------------------
/nuxt.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/nuxt.config.js
3 | * Configuration for nuxt. Duh. Has to be regular node commonjs modules
4 | */
5 |
6 | const path = require('path')
7 |
8 | module.exports = {
9 | srcDir: path.resolve(__dirname, './src/client'),
10 |
11 | /**
12 | * All of the default head properties to insert.
13 | *
14 | * @see https://github.com/declandewet/vue-meta#recognized-metainfo-properties
15 | */
16 | head: {
17 | titleTemplate: (title) => {
18 | if (title) {
19 | return `${title} - Developer ⋅ elementary`
20 | } else {
21 | return 'Developer ⋅ elementary'
22 | }
23 | },
24 |
25 | meta: [
26 | { charset: 'utf-8' },
27 | { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0' },
28 |
29 | { name: 'description', content: 'Resources for designing, developing, and publishing apps for elementary OS' },
30 | { name: 'author', content: 'elementary LLC' },
31 | { name: 'theme-color', content: '#403757' },
32 |
33 | { name: 'name', content: 'Developer ⋅ elementary' },
34 | { name: 'description', content: 'Resources for designing, developing, and publishing apps for elementary OS' },
35 | { name: 'image', content: 'https://elementary.io/images/developer/preview.png' },
36 |
37 | { name: 'twitter:card', content: 'summary_large_image' },
38 | { name: 'twitter:site', content: '@elementary' },
39 | { name: 'twitter:creator', content: '@elementary' },
40 |
41 | { name: 'og:title', content: 'Developer ⋅ elementary' },
42 | { name: 'og:description', content: 'Resources for designing, developing, and publishing apps for elementary OS' },
43 | { name: 'og:image', content: 'https://elementary.io/images/developer/preview.png' },
44 |
45 | { name: 'apple-mobile-web-app-title', content: 'Dashboard' }
46 | // { name: 'apple-touch-icon', content: '/images/apple-touch-icon.png' }
47 | ],
48 |
49 | link: [
50 | { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Open+Sans:300,400' }
51 | ]
52 | },
53 |
54 | /**
55 | * Cool style for the nuxt progress bar
56 | *
57 | * @var {Object}
58 | */
59 | loading: {
60 | color: '#3892e0',
61 | failedColor: '#da4d45'
62 | },
63 |
64 | ErrorPage: '~/pages/error'
65 | }
66 |
--------------------------------------------------------------------------------
/src/README.md:
--------------------------------------------------------------------------------
1 | # houston/src/
2 |
3 | This folder holds all of the houston code base. Each folder, with the exception
4 | of `cli` and `lib`, hold the code for a different process of houston.
5 |
6 | ## api/
7 |
8 | This holds the code for the API server. It is strictly JSON based with no html.
9 | Anything related to the client, including pages, styles, and endpoints related
10 | to browser information should be in `client/`.
11 |
12 | ## cli/
13 |
14 | This folder holds all of the code needed to get the configuration setup and
15 | start a process. It also holds some useful scripts like database migration
16 | and seeding.
17 |
18 | ## client/
19 |
20 | This folder is everything the user sees. It handles controllers for the client
21 | routes, and markup for styles and pages.
22 |
23 | ## lib/
24 |
25 | This folder holds universal code used in multiple processes. Look here if you
26 | need to change something about the database.
27 |
28 | ## repo/
29 |
30 | This holds the code for the repository syslog server. This is used by nginx
31 | to record download counts of files in the repository.
32 |
33 | ## worker/
34 |
35 | This is the worker process. It is responsible for building and releasing
36 | projects.
37 |
--------------------------------------------------------------------------------
/src/app.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/app.ts
3 | * Helpful entry points for if houston is being used as a library
4 | */
5 |
6 | export { App } from './lib/app'
7 |
8 | export { Config } from './lib/config'
9 |
10 | export {
11 | Aptly,
12 | codeRepositoryFactory,
13 | github
14 | } from './lib/service'
15 |
16 | export { Worker } from './worker'
17 | export { Build as BuildWorker } from './worker'
18 | export { Release as ReleaseWorker } from './worker'
19 |
--------------------------------------------------------------------------------
/src/bin.js:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env node
2 |
3 | require('./bootstrap')
4 | require('./cli/cli')
5 |
--------------------------------------------------------------------------------
/src/bootstrap.js:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/bootstrap.ts
3 | * A bootstrap file that should be loaded once in the whole application.
4 | * Used for loading polyfills and other _hacks_ as needed.
5 | * Because this file is bootstraping the env, it must be es5 styled. Sorry.
6 | */
7 |
8 | require('reflect-metadata')
9 |
--------------------------------------------------------------------------------
/src/cli/cli.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/cli.ts
3 | * Entry point to houston CLI
4 | */
5 |
6 | // Command line files are allowed to have console log statements
7 | // tslint:disable no-console
8 |
9 | import * as yargs from 'yargs'
10 |
11 | import commands from './commands'
12 |
13 | yargs.version(false)
14 | yargs.help('h').alias('h', 'help')
15 |
16 | for (const c of commands) {
17 | yargs.command(c)
18 | }
19 |
20 | yargs.option('config', { alias: 'c', describe: 'Path to configuration file', type: 'string' })
21 |
22 | yargs.recommendCommands()
23 | yargs.showHelpOnFail(true)
24 |
25 | const argv = yargs.argv
26 |
27 | if (argv._.length === 0) {
28 | yargs.showHelp()
29 | process.exit(1)
30 | }
31 |
--------------------------------------------------------------------------------
/src/cli/commands/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/commands/index.ts
3 | * Exports an array of all the commands we can run.
4 | */
5 |
6 | export default [
7 | require('./build'),
8 | require('./ci'),
9 | require('./migrate'),
10 | require('./repo'),
11 | require('./seed'),
12 | require('./version')
13 | ]
14 |
--------------------------------------------------------------------------------
/src/cli/commands/migrate.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/commands/migrate.ts
3 | * Runs database migration scripts
4 | */
5 |
6 | // Command line files are allowed to have console log statements
7 | // tslint:disable no-console
8 |
9 | import { Database } from '../../lib/database'
10 | import { setup } from '../utilities'
11 |
12 | export const command = 'migrate'
13 | export const describe = 'Changes database tables based on houston schemas'
14 |
15 | export const builder = (yargs) => {
16 | return yargs
17 | .option('direction', { describe: 'The direction to migrate', type: 'string', default: 'up' })
18 | }
19 |
20 | export async function handler (argv) {
21 | const { app, config } = setup(argv)
22 | const database = app.get(Database)
23 |
24 | if (argv.direction === 'up') {
25 | const version = config.get('houston.version', 'latest')
26 | console.log(`Updating database tables to ${version} version`)
27 | } else if (argv.direction === 'down') {
28 | console.log(`Downgrading database tables 1 version`)
29 | } else {
30 | console.error(`Incorrect non-option arguments: got ${argv.direction}, need at be up or down`)
31 | process.exit(1)
32 | }
33 |
34 | try {
35 | if (argv.direction === 'up') {
36 | await database.knex.migrate.latest()
37 | } else if (argv.direction === 'down') {
38 | await database.knex.migrate.rollback()
39 | }
40 | } catch (e) {
41 | console.error('Error updating database tables')
42 | console.error(e.message)
43 | process.exit(1)
44 | }
45 |
46 | console.log('Updated database tables')
47 | process.exit(0)
48 | }
49 |
--------------------------------------------------------------------------------
/src/cli/commands/repo.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/commands/repo.ts
3 | * Runs the repository syslogd server
4 | */
5 |
6 | // Command line files are allowed to have console log statements
7 | // tslint:disable no-console
8 |
9 | import { Repo as Server } from '../../repo/repo'
10 | import { setup } from '../utilities'
11 |
12 | export const command = 'repo'
13 | export const describe = 'Starts the repository syslogd server'
14 |
15 | export const builder = (yargs) => {
16 | return yargs
17 | .option('port', { alias: 'p', describe: 'The port to run the server on', type: 'number', default: 0 })
18 | }
19 |
20 | export async function handler (argv) {
21 | const { app } = setup(argv)
22 | const server = app.get(Server)
23 |
24 | await server.listen(argv.port)
25 | }
26 |
--------------------------------------------------------------------------------
/src/cli/commands/seed.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/commands/seed.ts
3 | * Runs database seed scripts
4 | */
5 |
6 | // Command line files are allowed to have console log statements
7 | // tslint:disable no-console
8 |
9 | import { Database } from '../../lib/database/database'
10 | import { setup } from '../utilities'
11 |
12 | export const command = 'seed'
13 | export const describe = 'Seeds the database tables with fake data'
14 |
15 | export async function handler (argv) {
16 | const { app } = setup(argv)
17 | const database = app.get(Database)
18 |
19 | console.log(`Seeding database tables`)
20 |
21 | try {
22 | await database.knex.seed.run()
23 | } catch (e) {
24 | console.error('Error seeding database tables')
25 | console.error(e.message)
26 | process.exit(1)
27 | }
28 |
29 | console.log('Seeded database tables')
30 | process.exit(0)
31 | }
32 |
--------------------------------------------------------------------------------
/src/cli/commands/version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/commands/seed.ts
3 | * Runs database seed scripts
4 | */
5 |
6 | // Command line files are allowed to have console log statements
7 | // tslint:disable no-console
8 |
9 | import { Database } from '../../lib/database/database'
10 | import { setup } from '../utilities'
11 |
12 | export const command = 'version'
13 | export const describe = 'Displays Houston version information'
14 |
15 | export async function handler (argv) {
16 | const { config } = setup(argv)
17 |
18 | console.log(`Release: ${config.get('houston.version')}`)
19 | if (config.has('houston.commit')) {
20 | console.log(`Commit: ${config.get('houston.commit')}`)
21 | } else {
22 | console.log('Commit: Unknown')
23 | }
24 |
25 | process.exit(0)
26 | }
27 |
--------------------------------------------------------------------------------
/src/cli/utilities.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/cli/utilities.ts
3 | * Some utilities for command line stuff
4 | */
5 |
6 | // Command line files are allowed to have console log statements
7 | // tslint:disable no-console
8 |
9 | import { App } from '../lib/app'
10 | import { Config, getConfig } from '../lib/config'
11 | import { Logger } from '../lib/log'
12 |
13 | /**
14 | * Sets up some boilderplate application classes based on command line args
15 | *
16 | * @param {Object} argv
17 | * @return {Object}
18 | */
19 | export function setup (argv): { app: App, config: Config, logger: Logger } {
20 | const config = getConfig(argv.config)
21 | const app = new App(config)
22 | const logger = app.get(Logger)
23 |
24 | process.on('unhandledRejection', (reason) => console.error(reason))
25 |
26 | return { app, config, logger }
27 | }
28 |
--------------------------------------------------------------------------------
/src/client/README.md:
--------------------------------------------------------------------------------
1 | # houston/src/client/
2 |
3 | This is the client side houston process. It's built with `vue` using the `nuxt`
4 | framework. Currently a work in progress and might change.
5 |
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/bold-italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/bold-italic.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/bold.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/extra-bold-italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/extra-bold-italic.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/extra-bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/extra-bold.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/italic.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/light-italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/light-italic.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/light.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/regular.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/semi-bold-italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/semi-bold-italic.ttf
--------------------------------------------------------------------------------
/src/client/fonts/open-sans/semi-bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elementary/houston/6db94aba6d01e67288efae526883980defe2fa80/src/client/fonts/open-sans/semi-bold.ttf
--------------------------------------------------------------------------------
/src/client/images/brand/elementary-logomark.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/client/layouts/blank.vue:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/client/layouts/blank.vue
3 | * A basic no thrills layout.
4 | */
5 |
6 |
7 |
8 |
9 |
10 |
23 |
--------------------------------------------------------------------------------
/src/client/layouts/default.vue:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/client/layouts/default.vue
3 | * The default houston layout with a header, navigation, and footer.
4 | */
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
26 |
27 |
36 |
--------------------------------------------------------------------------------
/src/client/pages/error.vue:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/client/pages/error.vue
3 | * An awesome error page for houston
4 | */
5 |
6 |
7 |
8 | {{ statusCode }}
9 |
10 | Page Not Found
11 | Internal Server Error
12 | Error
13 |
14 | {{ message }}
15 |
16 | Developer Pages
17 |
18 |
19 |
20 |
61 |
62 |
111 |
--------------------------------------------------------------------------------
/src/client/pages/index.vue:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/client/pages/index.vue
3 | * The entry page for houston
4 | */
5 |
6 |
7 |
8 |
testing
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/lib/app.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/app.ts
3 | * IOC container for houston. This is the entrypoint to anything and everything
4 | * sweat in life.
5 | */
6 |
7 | import { Container, ContainerModule } from 'inversify'
8 |
9 | import { Config } from './config'
10 |
11 | /**
12 | * App
13 | * A houston IOC container
14 | */
15 | export class App extends Container {
16 |
17 | /**
18 | * A list of all the providers to load in the application.
19 | *
20 | * @var {ContainerModule[]}
21 | */
22 | protected static providers: ContainerModule[] = [
23 | require('../repo/provider').provider,
24 | require('../worker/provider').provider,
25 | require('./cache/provider').provider,
26 | require('./database/provider').provider,
27 | require('./log/provider').provider,
28 | require('./queue/provider').provider,
29 | require('./service/provider').provider
30 | ]
31 |
32 | /**
33 | * Creates a new App
34 | *
35 | * @param {Config} config
36 | */
37 | public constructor (config: Config) {
38 | super()
39 |
40 | this.bind(App).toConstantValue(this)
41 | this.bind(Config).toConstantValue(config)
42 |
43 | this.setupProviders()
44 | }
45 |
46 | /**
47 | * Sets up all of the providers we have throughout the application.
48 | *
49 | * @return {void}
50 | */
51 | public setupProviders () {
52 | this.load(...App.providers)
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/lib/cache/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/cache/index.ts
3 | * Exports useful cache things
4 | */
5 |
6 | export {
7 | Cache,
8 | ICache,
9 | ICacheFactory
10 | } from './type'
11 |
--------------------------------------------------------------------------------
/src/lib/cache/provider.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/cache/provider.ts
3 | * Registers a basic cache factory.
4 | * TODO: Build this out a bit more with redis support
5 | */
6 |
7 | import { ContainerModule, interfaces } from 'inversify'
8 | import * as Cache from 'lru-cache'
9 |
10 | import * as type from './type'
11 |
12 | export const provider = new ContainerModule((bind) => {
13 | // This is not a great idea. I know. It's a quick and dirty fix.
14 | const instances = {}
15 |
16 | bind>(type.Cache)
17 | .toFactory((context) => (namespace, options = {}) => {
18 | if (instances[namespace]) {
19 | return instances[namespace]
20 | } else {
21 | instances[namespace] = new Cache({
22 | maxAge: (options.maxAge || 3600)
23 | })
24 |
25 | return instances[namespace]
26 | }
27 | })
28 | })
29 |
--------------------------------------------------------------------------------
/src/lib/cache/type.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/cache/type.d.ts
3 | * Types for the cache utility
4 | */
5 |
6 | export const Cache = Symbol.for('Cache') // tslint:disable-line
7 |
8 | export interface ICacheOptions {
9 | tty?: number
10 | }
11 |
12 | export interface ICache {
13 | get (key: string): Promise
14 | set (key: string, value: string): Promise
15 | }
16 |
17 | export type ICacheFactory = (namespace: string, options?: ICacheOptions) => ICache
18 |
--------------------------------------------------------------------------------
/src/lib/config/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/config/index.ts
3 | * Exports useful config things
4 | */
5 |
6 | export { Config } from './config'
7 | export { getConfig } from './loader'
8 |
--------------------------------------------------------------------------------
/src/lib/database/README.md:
--------------------------------------------------------------------------------
1 | # houston/src/lib/database/
2 |
3 | This folder holds all of the database logic. Everything is making use of
4 | [knex](http://knexjs.org), so we recommend you read up a bit on that.
5 |
6 | ## Tables
7 |
8 | These are all the current tables we have:
9 |
10 | - `projects`
11 | - `releases`
12 | - `builds`
13 | - `build_logs`
14 | - `build_issues`
15 | - `packages`
16 |
17 | - `github_projects`
18 | - `github_releases`
19 | - `github_build_issues`
20 |
21 | ## Database Design
22 |
23 | The main tables can be described like this:
24 | ```
25 | projects -> 1:n -> releases -> 1:n -> builds -> 1:n -> packages
26 | ```
27 |
28 | The `projects`, `releases`, and `build_issues` tables have a polymorphic
29 | relationship to a service table like `github_projects`. This allows us to
30 | integrate other third party services easier, and without changing existing data.
31 |
32 | ## Seeds
33 |
34 | The seed folder contains a bunch of helpful seeds designed to be used in tests
35 | and for development. Here is the lodown for how they are setup.
36 |
37 | ### Projects
38 |
39 | Keymaker
40 | - 3 Releases
41 | - 1 Build
42 | - 4 Build logs
43 | - 1 Package
44 |
45 | AppCenter
46 | - 8 Releases (2 invalid)
47 | - 3 Builds
48 | - 2 Build logs
49 | - 3 Packages
50 |
51 | Code
52 | - 1 Release (1 invalid)
53 | - 0 Builds
54 | - 0 build logs
55 | - 0 Packages
56 |
57 | Terminal
58 | - 2 Releases
59 | - 2 Builds
60 | - 3 Build logs
61 | - 1 Package
62 |
63 | ### Users
64 |
65 | The seed files include multiple users, each one representing a different
66 | permission level. As of right now you will not be able to log into these
67 | accounts. They are only used in tests.
68 |
--------------------------------------------------------------------------------
/src/lib/database/database.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/database.ts
3 | * The main database class
4 | *
5 | * @exports {Class} Database - The master database connection class
6 | */
7 |
8 | import { inject, injectable } from 'inversify'
9 | import * as Knex from 'knex'
10 | import * as path from 'path'
11 |
12 | import { Config } from '../config'
13 | import { Log } from '../log'
14 |
15 | /**
16 | * Database
17 | * The master database connection class
18 | *
19 | * @property {Knex} knex - A knex instance for queries
20 | */
21 | @injectable()
22 | export class Database {
23 |
24 | public knex: Knex
25 |
26 | protected config: Config
27 | protected log: Log
28 |
29 | /**
30 | * Creates a Database class
31 | *
32 | * @param {Config} config - Configuration for database connection
33 | * @param {Log} [log] - The log instance to use for reporting
34 | */
35 | constructor (@inject(Config) config: Config, @inject(Log) log: Log) {
36 | const migrationPath = path.resolve(__dirname, 'migration')
37 | const seedPath = path.resolve(__dirname, 'seed')
38 |
39 | // We assign some default file paths for migrations and seeds
40 | const databaseConfig = Object.assign({}, config.get('database'), {
41 | migrations: {
42 | directory: migrationPath,
43 | tableName: 'migrations'
44 | },
45 | seeds: {
46 | directory: seedPath
47 | },
48 | useNullAsDefault: false
49 | })
50 |
51 | this.config = config
52 | this.log = log
53 |
54 | this.knex = Knex(databaseConfig)
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/lib/database/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/index.ts
3 | * Export all the things we could possibly use outside of this module.
4 | */
5 |
6 | export { Database } from './database'
7 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-001-github_repositories.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-001-github_repositories.ts
3 | * The inital houston 2.0.0 migration for GitHub repositories table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('github_repositories', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.integer('key').notNullable().unique()
23 |
24 | table.string('owner').notNullable()
25 | table.string('name').notNullable()
26 |
27 | table.boolean('is_private').notNullable()
28 |
29 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
30 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
31 | table.timestamp('deleted_at').nullable()
32 | })
33 | }
34 |
35 | /**
36 | * down
37 | * Database information for downgrading version 2.0.0
38 | *
39 | * @param {Object} knex - An initalized Knex package
40 | * @return {Promise} - A promise of successful database migration
41 | */
42 | export function down (knex: Knex) {
43 | return knex.schema.dropTable('github_repositories')
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-002-github_releases.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-002-github_releases.ts
3 | * The inital houston 2.0.0 migration for GitHub releases table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('github_releases', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.integer('key').notNullable().unique()
23 |
24 | table.string('tag').notNullable()
25 |
26 | table.uuid('github_repository').notNullable()
27 | table.foreign('github_repository').references('id').inTable('github_repositories')
28 |
29 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
30 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
31 | table.timestamp('deleted_at').nullable()
32 | })
33 | }
34 |
35 | /**
36 | * down
37 | * Database information for downgrading version 2.0.0
38 | *
39 | * @param {Object} knex - An initalized Knex package
40 | * @return {Promise} - A promise of successful database migration
41 | */
42 | export function down (knex: Knex) {
43 | return knex.schema.dropTable('github_releases')
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-003-users.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-003-users.ts
3 | * The inital houston 2.0.0 migration for users table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('users', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.string('name').notNullable()
23 | table.string('email').notNullable()
24 |
25 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
26 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
27 | table.timestamp('deleted_at').nullable()
28 | })
29 | }
30 |
31 | /**
32 | * down
33 | * Database information for downgrading version 2.0.0
34 | *
35 | * @param {Object} knex - An initalized Knex package
36 | * @return {Promise} - A promise of successful database migration
37 | */
38 | export function down (knex: Knex) {
39 | return knex.schema.dropTable('users')
40 | }
41 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-004-github_users.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-004-github_users.ts
3 | * The inital houston 2.0.0 migration for github users table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('github_users', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.integer('key').notNullable().unique()
23 | table.string('login').notNullable()
24 |
25 | table.string('name').nullable()
26 | table.string('email').nullable()
27 | table.string('company').nullable()
28 | table.string('avatar').nullable()
29 |
30 | table.string('access_key').nullable()
31 | table.string('scopes').nullable()
32 |
33 | table.uuid('user_id').nullable()
34 | table.foreign('user_id').references('id').inTable('users')
35 |
36 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
37 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
38 | table.timestamp('deleted_at').nullable()
39 | })
40 | }
41 |
42 | /**
43 | * down
44 | * Database information for downgrading version 2.0.0
45 | *
46 | * @param {Object} knex - An initalized Knex package
47 | * @return {Promise} - A promise of successful database migration
48 | */
49 | export function down (knex: Knex) {
50 | return knex.schema.dropTable('github_users')
51 | }
52 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-005-github_repositories_github_users.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-005-github_repositories_github_users.ts
3 | * The inital houston 2.0.0 migration for pivot table between github users and
4 | * repositories.
5 | *
6 | * @exports {Function} up - Database information for upgrading to version 2.0.0
7 | * @exports {Function} down - Database information for downgrading version 2.0.0
8 | */
9 |
10 | import * as Knex from 'knex'
11 |
12 | /**
13 | * up
14 | * Database information for upgrading to version 2.0.0
15 | *
16 | * @param {Object} knex - An initalized Knex package
17 | * @return {Promise} - A promise of database migration
18 | */
19 | export function up (knex: Knex) {
20 | return knex.schema.createTable('github_repositories_github_users', (table) => {
21 | table.increments()
22 |
23 | table.uuid('github_repository_id').nullable()
24 | table.foreign('github_repository_id').references('id').inTable('github_repositories')
25 |
26 | table.uuid('github_user_id').nullable()
27 | table.foreign('github_user_id').references('id').inTable('github_users')
28 | })
29 | }
30 |
31 | /**
32 | * down
33 | * Database information for downgrading version 2.0.0
34 | *
35 | * @param {Object} knex - An initalized Knex package
36 | * @return {Promise} - A promise of successful database migration
37 | */
38 | export function down (knex: Knex) {
39 | return knex.schema.dropTable('github_repositories_github_users')
40 | }
41 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-006-stripe_accounts.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-006-stripe_accounts.ts
3 | * The inital houston 2.0.0 migration for stripe accounts table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('stripe_accounts', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.integer('key').notNullable().unique()
23 |
24 | table.string('name').unique()
25 | table.string('color').nullable()
26 | table.string('url').nullable()
27 |
28 | table.string('public_key').nullable()
29 | table.string('secret_key').nullable()
30 |
31 | table.uuid('user_id').notNullable()
32 | table.foreign('user_id').references('id').inTable('users')
33 |
34 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
35 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
36 | table.timestamp('deleted_at').nullable()
37 | })
38 | }
39 |
40 | /**
41 | * down
42 | * Database information for downgrading version 2.0.0
43 | *
44 | * @param {Object} knex - An initalized Knex package
45 | * @return {Promise} - A promise of successful database migration
46 | */
47 | export function down (knex: Knex) {
48 | return knex.schema.dropTable('stripe_accounts')
49 | }
50 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-007-projects.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-007-projects.ts
3 | * The inital houston 2.0.0 migration for projects table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('projects', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.string('name_domain').unique().index()
23 | table.string('name_human').notNullable()
24 | table.string('name_developer').notNullable()
25 |
26 | table.enu('type', ['application']).defaultTo('application')
27 |
28 | table.uuid('projectable_id').notNullable()
29 | table.string('projectable_type').notNullable()
30 |
31 | table.uuid('stripe_id').nullable()
32 | table.foreign('stripe_id').references('id').inTable('stripe_accounts')
33 |
34 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
35 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
36 | table.timestamp('deleted_at').nullable()
37 | })
38 | }
39 |
40 | /**
41 | * down
42 | * Database information for downgrading version 2.0.0
43 | *
44 | * @param {Object} knex - An initalized Knex package
45 | * @return {Promise} - A promise of successful database migration
46 | */
47 | export function down (knex: Knex) {
48 | return knex.schema.dropTable('projects')
49 | }
50 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-008-releases.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-008-releases.ts
3 | * The inital houston 2.0.0 migration for releases table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('releases', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.string('version').notNullable()
23 | table.integer('version_major').notNullable()
24 | table.integer('version_minor').notNullable()
25 | table.integer('version_patch').notNullable()
26 | table.integer('version_build').nullable()
27 |
28 | table.boolean('is_prerelease').defaultTo(false)
29 |
30 | table.uuid('releaseable_id').notNullable()
31 | table.string('releaseable_type').notNullable()
32 |
33 | table.uuid('project_id').notNullable()
34 | table.foreign('project_id').references('id').inTable('projects')
35 |
36 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
37 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
38 | table.timestamp('deleted_at').nullable()
39 | })
40 | }
41 |
42 | /**
43 | * down
44 | * Database information for downgrading version 2.0.0
45 | *
46 | * @param {Object} knex - An initalized Knex package
47 | * @return {Promise} - A promise of successful database migration
48 | */
49 | export function down (knex: Knex) {
50 | return knex.schema.dropTable('releases')
51 | }
52 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-009-builds.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-009-builds.ts
3 | * The inital houston 2.0.0 migration for builds table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('builds', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.enum('status', [
23 | 'queue',
24 | 'build',
25 | 'test',
26 | 'review',
27 | 'publish',
28 | 'fail',
29 | 'error'
30 | ]).nullable()
31 |
32 | table.json('appcenter').nullable()
33 | table.json('appstream').nullable()
34 |
35 | table.uuid('release_id').notNullable()
36 | table.foreign('release_id').references('id').inTable('releases')
37 |
38 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
39 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
40 | table.timestamp('deleted_at').nullable()
41 | })
42 | }
43 |
44 | /**
45 | * down
46 | * Database information for downgrading version 2.0.0
47 | *
48 | * @param {Object} knex - An initalized Knex package
49 | * @return {Promise} - A promise of successful database migration
50 | */
51 | export function down (knex: Knex) {
52 | return knex.schema.dropTable('builds')
53 | }
54 |
--------------------------------------------------------------------------------
/src/lib/database/migration/2.0.0-010-build_logs.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/migration/2.0.0-010-build_logs.ts
3 | * The inital houston 2.0.0 migration for build logs table
4 | *
5 | * @exports {Function} up - Database information for upgrading to version 2.0.0
6 | * @exports {Function} down - Database information for downgrading version 2.0.0
7 | */
8 |
9 | import * as Knex from 'knex'
10 |
11 | /**
12 | * up
13 | * Database information for upgrading to version 2.0.0
14 | *
15 | * @param {Object} knex - An initalized Knex package
16 | * @return {Promise} - A promise of database migration
17 | */
18 | export function up (knex: Knex) {
19 | return knex.schema.createTable('build_logs', (table) => {
20 | table.uuid('id').primary()
21 |
22 | table.string('title').notNullable()
23 | table.string('body').notNullable()
24 |
25 | table.string('test').nullable()
26 |
27 | table.json('metadata').nullable()
28 |
29 | table.uuid('build_id').nullable()
30 | table.foreign('build_id').references('id').inTable('builds')
31 |
32 | table.timestamp('created_at').notNullable().defaultTo(knex.fn.now())
33 | table.timestamp('updated_at').notNullable().defaultTo(knex.fn.now())
34 | table.timestamp('deleted_at').nullable()
35 | })
36 | }
37 |
38 | /**
39 | * down
40 | * Database information for downgrading version 2.0.0
41 | *
42 | * @param {Object} knex - An initalized Knex package
43 | * @return {Promise} - A promise of successful database migration
44 | */
45 | export function down (knex: Knex) {
46 | return knex.schema.dropTable('build_logs')
47 | }
48 |
--------------------------------------------------------------------------------
/src/lib/database/provider.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/provider.ts
3 | * Provides the app with the needed Log classes
4 | */
5 |
6 | import { ContainerModule } from 'inversify'
7 |
8 | import { Database } from './database'
9 |
10 | export const provider = new ContainerModule((bind) => {
11 | bind(Database).toSelf()
12 | })
13 |
--------------------------------------------------------------------------------
/src/lib/database/seed/001-github_repositories.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/001-github_repositories.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the Github repositories table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the Github repositories table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('github_repositories').del()
18 |
19 | await knex('github_repositories').insert({
20 | created_at: new Date(),
21 | deleted_at: null,
22 | id: 'b272a75e-5263-4133-b2e1-c8894b29493c',
23 | is_private: false,
24 | key: 891357,
25 | name: 'keymaker',
26 | owner: 'btkostner',
27 | updated_at: new Date()
28 | })
29 |
30 | await knex('github_repositories').insert({
31 | created_at: new Date(),
32 | deleted_at: null,
33 | id: '14f2dc0d-9648-498e-b06e-a8479e0a7b26',
34 | is_private: false,
35 | key: 8234623,
36 | name: 'appcenter',
37 | owner: 'elementary',
38 | updated_at: new Date()
39 | })
40 |
41 | await knex('github_repositories').insert({
42 | created_at: new Date(),
43 | deleted_at: null,
44 | id: 'b353ee74-596a-4ec8-8b1c-11589bb8eb36',
45 | is_private: false,
46 | key: 48913751,
47 | name: 'code',
48 | owner: 'elementary',
49 | updated_at: new Date()
50 | })
51 |
52 | await knex('github_repositories').insert({
53 | created_at: new Date(),
54 | deleted_at: null,
55 | id: '274b1d3e-85bd-4ee4-88d9-5ec18f4e87c4',
56 | is_private: false,
57 | key: 49876157,
58 | name: 'terminal',
59 | owner: 'elementary',
60 | updated_at: new Date()
61 | })
62 | }
63 |
--------------------------------------------------------------------------------
/src/lib/database/seed/003-users.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/003-users.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the users table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the users table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('users').del()
18 |
19 | await knex('users').insert({
20 | created_at: new Date(),
21 | deleted_at: null,
22 | email: 'blake@elementary.io',
23 | id: '24ef2115-67e7-4ea9-8e18-ae6c44b63a71',
24 | name: 'Blake Kostner',
25 | updated_at: new Date()
26 | })
27 | }
28 |
--------------------------------------------------------------------------------
/src/lib/database/seed/004-github_users.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/004-github_users.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the Github users table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the Github users table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('github_users').del()
18 |
19 | await knex('github_users').insert({
20 | access_key: 'u9r0nuq083ru880589rnyq29nyvaw4etbaw34vtr',
21 | company: 'elementary',
22 | created_at: new Date(),
23 | email: 'blake@elementary.io',
24 | id: 'da527f7e-b865-46e1-a47e-99542d838298',
25 | key: 6423154,
26 | login: 'btkostner',
27 | name: 'Blake Kostner',
28 | scopes: 'public_repo,repo',
29 | updated_at: new Date(),
30 | user_id: '24ef2115-67e7-4ea9-8e18-ae6c44b63a71'
31 | })
32 | }
33 |
--------------------------------------------------------------------------------
/src/lib/database/seed/005-github_repositories_github_users.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/005-github_repositories_github_users.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the Github repositories to Github users table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the Github repositories to Github users table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('github_repositories_github_users').del()
18 |
19 | await knex('github_repositories_github_users').insert({
20 | github_repository_id: 'b272a75e-5263-4133-b2e1-c8894b29493c',
21 | github_user_id: 'da527f7e-b865-46e1-a47e-99542d838298'
22 | })
23 |
24 | await knex('github_repositories_github_users').insert({
25 | github_repository_id: '14f2dc0d-9648-498e-b06e-a8479e0a7b26',
26 | github_user_id: 'da527f7e-b865-46e1-a47e-99542d838298'
27 | })
28 |
29 | await knex('github_repositories_github_users').insert({
30 | github_repository_id: 'b353ee74-596a-4ec8-8b1c-11589bb8eb36',
31 | github_user_id: 'da527f7e-b865-46e1-a47e-99542d838298'
32 | })
33 |
34 | await knex('github_repositories_github_users').insert({
35 | github_repository_id: '274b1d3e-85bd-4ee4-88d9-5ec18f4e87c4',
36 | github_user_id: 'da527f7e-b865-46e1-a47e-99542d838298'
37 | })
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/database/seed/006-stripe_accounts.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/006-stripe_accounts.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the Stripe accounts table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the Stripe accounts table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('stripe_accounts').del()
18 |
19 | await knex('stripe_accounts').insert({
20 | color: 'FFA500',
21 | created_at: new Date(),
22 | id: '326599e7-97ed-455a-9c38-122651a12be6',
23 | key: 4235823,
24 | name: 'btkostner',
25 | public_key: 'pk_test_uj0fjv0a9u9302fawfa2rasd',
26 | secret_key: 'sk_test_j89j2098vah803cnb83v298r',
27 | updated_at: new Date(),
28 | url: 'https://btkostner.io',
29 | user_id: '24ef2115-67e7-4ea9-8e18-ae6c44b63a71'
30 | })
31 | }
32 |
--------------------------------------------------------------------------------
/src/lib/database/seed/007-projects.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/007-projects.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the projects table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the projects table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('projects').del()
18 |
19 | await knex('projects').insert({
20 | created_at: new Date(1),
21 | deleted_at: null,
22 | id: '24ef2115-67e7-4ea9-8e18-ae6c44b63a71',
23 | name_developer: 'Blake Kostner',
24 | name_domain: 'com.github.btkostner.keymaker',
25 | name_human: 'Keymaker',
26 | projectable_id: 'b272a75e-5263-4133-b2e1-c8894b29493c',
27 | projectable_type: 'github',
28 | stripe_id: '326599e7-97ed-455a-9c38-122651a12be6',
29 | type: 'application',
30 | updated_at: new Date()
31 | })
32 |
33 | await knex('projects').insert({
34 | created_at: new Date(2),
35 | deleted_at: null,
36 | id: '75fa37dc-888d-4905-97bd-73cc9e39be2a',
37 | name_developer: 'elementary LLC',
38 | name_domain: 'com.github.elementary.appcenter',
39 | name_human: 'AppCenter',
40 | projectable_id: '14f2dc0d-9648-498e-b06e-a8479e0a7b26',
41 | projectable_type: 'github',
42 | stripe_id: null,
43 | type: 'application',
44 | updated_at: new Date()
45 | })
46 |
47 | await knex('projects').insert({
48 | created_at: new Date(3),
49 | deleted_at: null,
50 | id: '0086b0d2-be43-45fc-8619-989104705c8a',
51 | name_developer: 'elementary LLC',
52 | name_domain: 'com.github.elementary.code',
53 | name_human: 'Code',
54 | projectable_id: 'b353ee74-596a-4ec8-8b1c-11589bb8eb36',
55 | projectable_type: 'github',
56 | stripe_id: null,
57 | type: 'application',
58 | updated_at: new Date()
59 | })
60 |
61 | await knex('projects').insert({
62 | created_at: new Date(4),
63 | deleted_at: null,
64 | id: '4a9e027d-c27e-483a-a0fc-b2724a19491b',
65 | name_developer: 'elementary LLC',
66 | name_domain: 'com.github.elementary.terminal',
67 | name_human: 'Terminal',
68 | projectable_id: '274b1d3e-85bd-4ee4-88d9-5ec18f4e87c4',
69 | projectable_type: 'github',
70 | stripe_id: null,
71 | type: 'application',
72 | updated_at: new Date()
73 | })
74 | }
75 |
--------------------------------------------------------------------------------
/src/lib/database/seed/009-builds.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/database/seed/009-builds.ts
3 | * Seeds the database
4 | *
5 | * @exports {Function} seed - Seeds the builds table
6 | */
7 |
8 | import * as Knex from 'knex'
9 |
10 | /**
11 | * seed
12 | * Seeds the builds table
13 | *
14 | * @param {Object} knex - An initalized Knex package
15 | */
16 | export async function seed (knex: Knex) {
17 | await knex('builds').del()
18 |
19 | // Keymaker builds
20 | await knex('builds').insert({
21 | appcenter: '{}',
22 | appstream: '{}',
23 | created_at: new Date(),
24 | id: 'dd792007-489f-4742-9f22-bf3eea9c1794',
25 | release_id: '6f3b3345-1b6d-457a-b6ca-5b5a067c4d6c',
26 | status: 'publish',
27 | updated_at: new Date()
28 | })
29 |
30 | // AppCenter builds
31 | await knex('builds').insert({
32 | appcenter: '{}',
33 | appstream: '{}',
34 | created_at: new Date(),
35 | id: 'c575d74a-1402-41ed-85a3-de4ebc5f557c',
36 | release_id: '3d49def5-779a-4e2b-9e8e-2ededdbd9bbe',
37 | status: 'fail',
38 | updated_at: new Date()
39 | })
40 |
41 | await knex('builds').insert({
42 | appcenter: '{}',
43 | appstream: '{}',
44 | created_at: new Date(),
45 | id: '67dc9947-0519-4471-8951-a89426c63963',
46 | release_id: '393c3985-f743-4daf-b868-73ce6458f4e0',
47 | status: 'error',
48 | updated_at: new Date()
49 | })
50 |
51 | await knex('builds').insert({
52 | appcenter: '{}',
53 | appstream: '{}',
54 | created_at: new Date(),
55 | id: 'd63120d9-405e-48e2-91d1-9986730c7ff0',
56 | release_id: '79988df7-60c8-4356-acef-745b8108dfa4',
57 | status: 'publish',
58 | updated_at: new Date()
59 | })
60 |
61 | // Terminal builds
62 | await knex('builds').insert({
63 | appcenter: '{}',
64 | appstream: '{}',
65 | created_at: new Date(),
66 | id: '3dc34b70-521c-46fd-990f-3f4c9ad17e4b',
67 | release_id: '1dc97f10-9de5-4c99-808a-0364939d6a96',
68 | status: 'publish',
69 | updated_at: new Date()
70 | })
71 |
72 | await knex('builds').insert({
73 | appcenter: '{}',
74 | appstream: '{}',
75 | created_at: new Date(),
76 | id: 'fb2ab4e9-1596-40fd-8453-92bd4cc7965c',
77 | release_id: '877b86e8-9b96-4bf7-8243-fe1905cdd00f',
78 | status: 'review',
79 | updated_at: new Date()
80 | })
81 | }
82 |
--------------------------------------------------------------------------------
/src/lib/log/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/index.ts
3 | * Export all the things we could possibly use outside of this module.
4 | */
5 |
6 | export { Level } from './level'
7 | export { Log } from './log'
8 | export { Logger } from './logger'
9 |
--------------------------------------------------------------------------------
/src/lib/log/level.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/level.ts
3 | * Some log levels
4 | */
5 |
6 | /**
7 | * The debug level of logs
8 | *
9 | * @var {Symbol}
10 | */
11 | export const DEBUG = Symbol()
12 |
13 | /**
14 | * The info level of logs
15 | *
16 | * @var {Symbol}
17 | */
18 | export const INFO = Symbol()
19 |
20 | /**
21 | * The warn level of logs
22 | *
23 | * @var {Symbol}
24 | */
25 | export const WARN = Symbol()
26 |
27 | /**
28 | * The error level of logs
29 | *
30 | * @var {Symbol}
31 | */
32 | export const ERROR = Symbol()
33 |
34 | /**
35 | * An enum representing all of the log levels
36 | *
37 | * @var {enum}
38 | */
39 | export enum Level { DEBUG, INFO, WARN, ERROR }
40 |
41 | /**
42 | * Parses a string value for a level symbol
43 | *
44 | * @param {string} level
45 | * @return {Level}
46 | */
47 | export function parseLevel (level: string): Level {
48 | switch (level.toLowerCase().trim()) {
49 | case ('debug'):
50 | return Level.DEBUG
51 | case ('info'):
52 | return Level.INFO
53 | case ('warn'):
54 | return Level.WARN
55 | case ('error'):
56 | return Level.ERROR
57 | default:
58 | return Level.INFO
59 | }
60 | }
61 |
62 | /**
63 | * Returns a string given a level symbol
64 | *
65 | * @param {Level} level
66 | * @return {string}
67 | */
68 | export function levelString (level: Level): string {
69 | switch (level) {
70 | case (Level.DEBUG):
71 | return 'debug'
72 | case (Level.INFO):
73 | return 'info'
74 | case (Level.WARN):
75 | return 'warn'
76 | case (Level.ERROR):
77 | return 'error'
78 | default:
79 | return 'info'
80 | }
81 | }
82 |
83 | /**
84 | * Returns a number index of severity for a level symbol
85 | *
86 | * @param {Level} level
87 | * @return {Number}
88 | */
89 | export function levelIndex (level: Level): number {
90 | switch (level) {
91 | case (Level.DEBUG):
92 | return 0
93 | case (Level.INFO):
94 | return 1
95 | case (Level.WARN):
96 | return 2
97 | case (Level.ERROR):
98 | return 3
99 | default:
100 | return 1
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/lib/log/log.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/log.ts
3 | * A log message with super powers.
4 | *
5 | * @exports {Class} Log - A single log line.
6 | */
7 |
8 | import { injectable } from 'inversify'
9 |
10 | import { Level } from './level'
11 | import { Logger } from './logger'
12 |
13 | /**
14 | * Log
15 | * A single log line.
16 | */
17 | @injectable()
18 | export class Log {
19 |
20 | /**
21 | * The level of the log
22 | *
23 | * @var {Level}
24 | */
25 | public level: Level
26 |
27 | /**
28 | * The log message
29 | *
30 | * @var {String|Null}
31 | */
32 | public message?: string
33 |
34 | /**
35 | * Attached data to the log
36 | *
37 | * @var {Object}
38 | */
39 | public data: object
40 |
41 | /**
42 | * An error attached to the log
43 | *
44 | * @var {Error}
45 | */
46 | public error?: Error
47 |
48 | /**
49 | * The date the log was created
50 | *
51 | * @var {Date}
52 | */
53 | protected date: Date
54 |
55 | /**
56 | * The current logger to use for sending the log.
57 | *
58 | * @var {Logger}
59 | */
60 | protected logger: Logger
61 |
62 | /**
63 | * Creates a new log with default values
64 | *
65 | * @param {Logger} logger
66 | */
67 | public constructor (logger: Logger) {
68 | this.level = Level.DEBUG
69 | this.data = {}
70 | this.date = new Date()
71 |
72 | this.logger = logger
73 | }
74 |
75 | /**
76 | * Sets the log level
77 | *
78 | * @param {Level} level
79 | *
80 | * @return {Log}
81 | */
82 | public setLevel (level: Level): this {
83 | this.level = level
84 |
85 | return this
86 | }
87 |
88 | /**
89 | * Sets the log message
90 | *
91 | * @param {String} message
92 | *
93 | * @return {Log}
94 | */
95 | public setMessage (message: string): this {
96 | this.message = message
97 |
98 | return this
99 | }
100 |
101 | /**
102 | * Sets data in the log
103 | *
104 | * @param {String} key
105 | * @param {*} value
106 | *
107 | * @return {Log}
108 | */
109 | public setData (key: string, value): this {
110 | this.data[key] = value
111 |
112 | return this
113 | }
114 |
115 | /**
116 | * A shorthand for attaching an error message to a log
117 | *
118 | * @param {Error} err
119 | *
120 | * @return {Log}
121 | */
122 | public setError (err: Error): this {
123 | this.error = err
124 |
125 | return this
126 | }
127 |
128 | /**
129 | * Gets the date this log was created.
130 | *
131 | * @return {Date}
132 | */
133 | public getDate (): Date {
134 | return this.date
135 | }
136 |
137 | /**
138 | * Sends the log to what ever services / places it needs to be.
139 | *
140 | * @return {void}
141 | */
142 | public send () {
143 | return this.logger.send(this)
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/src/lib/log/output.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/output.ts
3 | * An abstract class for sending logs somewhere.
4 | */
5 |
6 | // Disabled because of abstract and interfaces are made to be extended.
7 | // tslint:disable:no-unused-variable
8 |
9 | import { injectable } from 'inversify'
10 |
11 | import { Config } from '../config'
12 | import { Log } from './log'
13 |
14 | /**
15 | * A generic abstract class for handling logs.
16 | */
17 | @injectable()
18 | export abstract class Output {
19 | /**
20 | * Checks if we should enable this output
21 | *
22 | * @param {Config} config
23 | *
24 | * @return {boolean}
25 | */
26 | public static enabled (config: Config): boolean {
27 | return true
28 | }
29 |
30 | /**
31 | * Creates a new logger output
32 | *
33 | * @param {Config} config
34 | */
35 | public constructor (config: Config) {
36 | return
37 | }
38 |
39 | /**
40 | * Does something with a debug log.
41 | *
42 | * @param {Log} log
43 | * @return {void}
44 | */
45 | public debug (log: Log) {
46 | return
47 | }
48 |
49 | /**
50 | * Does something with a info log.
51 | *
52 | * @param {Log} log
53 | * @return {void}
54 | */
55 | public info (log: Log) {
56 | return
57 | }
58 |
59 | /**
60 | * Does something with a warn log.
61 | *
62 | * @param {Log} log
63 | * @return {void}
64 | */
65 | public warn (log: Log) {
66 | return
67 | }
68 |
69 | /**
70 | * Does something with a error log.
71 | *
72 | * @param {Log} log
73 | * @return {void}
74 | */
75 | public error (log: Log) {
76 | return
77 | }
78 | }
79 |
80 | /**
81 | * An interface of the Output class as a constructor.
82 | * This is kinda pointless, but it keeps typescript happy when hinting.
83 | */
84 | export interface OutputConstructor {
85 | new (config: Config)
86 | enabled (config: Config): boolean
87 | }
88 |
--------------------------------------------------------------------------------
/src/lib/log/outputs/console.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/services/console.ts
3 | * Outputs logs to the console
4 | */
5 |
6 | // Disabled because this file is all about console logs
7 | // tslint:disable:no-console
8 |
9 | import { Config } from '../../config'
10 | import { Level, parseLevel } from '../level'
11 | import { Log } from '../log'
12 | import { Output } from '../output'
13 |
14 | export class Console extends Output {
15 |
16 | /**
17 | * Configuration to use for console logs.
18 | *
19 | * @var {Config}
20 | */
21 | protected config: Config
22 |
23 | /**
24 | * Checks if this output should be enabled
25 | *
26 | * @param {Config} config
27 | *
28 | * @return {boolean}
29 | */
30 | public static enabled (config: Config): boolean {
31 | if (config.has('log.console') === false) {
32 | return false
33 | }
34 |
35 | return (config.get('log.console') !== 'never')
36 | }
37 |
38 | /**
39 | * Creates a new Sentry output
40 | *
41 | * @param {Config} config
42 | */
43 | public constructor (config: Config) {
44 | super(config)
45 |
46 | this.config = config
47 | }
48 |
49 | /**
50 | * Sends debug info to the console
51 | *
52 | * @param {Log} log
53 | * @return {void}
54 | */
55 | public debug (log: Log) {
56 | console.info(log.message)
57 | }
58 |
59 | /**
60 | * Logs a message to the console
61 | *
62 | * @param {Log} log
63 | * @return {void}
64 | */
65 | public info (log: Log) {
66 | console.info(log.message)
67 | }
68 |
69 | /**
70 | * Logs a warning log to the console
71 | *
72 | * @param {Log} log
73 | * @return {void}
74 | */
75 | public warn (log: Log) {
76 | console.warn(log.message)
77 | }
78 |
79 | /**
80 | * Logs an error to the console
81 | *
82 | * @param {Log} log
83 | * @return {void}
84 | */
85 | public error (log: Log) {
86 | console.error(log.message)
87 | }
88 |
89 | /**
90 | * Checks if the configuration allows a given log level.
91 | *
92 | * @param {Level} level
93 | *
94 | * @return {Boolean}
95 | */
96 | protected allows (level: Level) {
97 | if (this.config.has('log.console') === false) {
98 | return false
99 | }
100 |
101 | const configLevel = parseLevel(this.config.get('log.console'))
102 |
103 | if (level >= configLevel) {
104 | return true
105 | }
106 |
107 | return false
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/lib/log/outputs/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/outputs/index.ts
3 | * A list of outputs we can send logs to
4 | */
5 |
6 | export { Console } from './console'
7 | export { Sentry } from './sentry'
8 |
--------------------------------------------------------------------------------
/src/lib/log/outputs/sentry.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/services/sentry.ts
3 | * Handles logging errors to sentry
4 | */
5 |
6 | import { Config } from '../../config'
7 | import { Log } from '../log'
8 | import { Output } from '../output'
9 |
10 | export class Sentry extends Output {
11 |
12 | /**
13 | * The current application configuration
14 | *
15 | * @var {Config}
16 | */
17 | protected config: Config
18 |
19 | /**
20 | * The sentry dns to use when reporting logs
21 | *
22 | * @var {String}
23 | */
24 | protected dns: string
25 |
26 | /**
27 | * A raven instance for logging to sentry
28 | *
29 | * @var {Raven}
30 | */
31 | protected raven
32 |
33 | /**
34 | * Checks if this output should be enabled
35 | *
36 | * @return {boolean}
37 | */
38 | public static enabled (config: Config): boolean {
39 | if (config.has('log.sentry') === false) {
40 | return false
41 | } else if (config.has('service.sentry.secret') === false) {
42 | return false
43 | }
44 |
45 | try {
46 | require.resolve('raven')
47 | } catch (e) {
48 | return false
49 | }
50 |
51 | return (config.get('log.sentry') !== 'never')
52 | }
53 |
54 | /**
55 | * Creates a new Sentry output
56 | *
57 | * @param {Config} config
58 | */
59 | public constructor (config: Config) {
60 | super(config)
61 |
62 | this.config = config
63 | this.dns = config.get('service.sentry.secret')
64 |
65 | this.raven = this.setup()
66 | }
67 |
68 | /**
69 | * Sends error logs to sentry
70 | *
71 | * @param {Log} log
72 | * @return {void}
73 | */
74 | public error (log: Log) {
75 | this.raven.captureException(this.toError(log))
76 | }
77 |
78 | /**
79 | * Transforms a log message to an error
80 | *
81 | * @param {Log} log
82 | *
83 | * @return {Error}
84 | */
85 | public toError (log: Log): Error {
86 | const error = new Error(log.message)
87 |
88 | // Add a stack trace no including this function
89 | Error.captureStackTrace(error, this.toError)
90 | Object.assign(error, log.data, { error: log.error })
91 |
92 | return error
93 | }
94 |
95 | /**
96 | * Sets up raven with common metadata and things.
97 | *
98 | * @return {Raven}
99 | */
100 | protected setup () {
101 | return require('raven')
102 | .config(this.dns)
103 | .install()
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/lib/log/provider.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * houston/src/lib/log/provider.ts
3 | * Provides the app with the needed Log classes
4 | */
5 |
6 | import { ContainerModule } from 'inversify'
7 |
8 | import { Log } from './log'
9 | import { Logger } from './logger'
10 | import { Output } from './output'
11 | import { Console } from './outputs/console'
12 | import { Sentry } from './outputs/sentry'
13 |
14 | export const provider = new ContainerModule((bind) => {
15 | bind