mirror of
https://github.com/caprover/caprover
synced 2026-05-03 10:10:29 +00:00
Updated packages (#2165)
* Updated packages * Updated packages * Fixed formatting * Fixed tests
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
# don't ever lint node_modules
|
||||
node_modules
|
||||
# don't lint build output (make sure it's set to your correct build folder name)
|
||||
built
|
||||
# don't lint nyc coverage output
|
||||
coverage
|
||||
@@ -1,23 +0,0 @@
|
||||
// eslint-disable-next-line no-undef
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-this-alias": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"no-case-declarations": "off",
|
||||
"no-useless-escape": "off",
|
||||
|
||||
}
|
||||
};
|
||||
Vendored
+2
-1
@@ -9,7 +9,8 @@
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": "explicit",
|
||||
"source.fixAll.eslint": "explicit"
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.addMissingImports": "explicit"
|
||||
},
|
||||
"typescript.referencesCodeLens.enabled": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import pluginJs from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default [
|
||||
{ languageOptions: { globals: globals.browser } },
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-this-alias': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'no-useless-escape': 'off',
|
||||
},
|
||||
},
|
||||
]
|
||||
@@ -1,5 +1,7 @@
|
||||
/* eslint-disable no-undef */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
"^.+\\.tsx?$": "ts-jest",
|
||||
"^.+\\.ts?$": "ts-jest",
|
||||
|
||||
Generated
+3775
-2616
File diff suppressed because it is too large
Load Diff
+36
-32
@@ -6,78 +6,82 @@
|
||||
"disable-otp": "node ./built/scripts/disable-otp.js",
|
||||
"dev": "sudo 'echo' && npm run build && sudo ./dev-scripts/dev-reset-service.sh",
|
||||
"clean": "npm run build && sudo ./dev-scripts/dev-clean-run-as-dev.sh",
|
||||
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
|
||||
"lint-fix": "eslint --fix -c .eslintrc.js --ext .ts ./src",
|
||||
"lint": "eslint 'src/**/*.ts'",
|
||||
"lint-fix": "eslint --fix 'src/**/*.ts'",
|
||||
"formatter": "prettier --check './src/**/*.ts'",
|
||||
"formatter-write": "prettier --write './src/**/*.ts'",
|
||||
"build": "echo 'RECOMPILING' && npx madge --circular --extensions ts ./ && rm -rf ./built && npx tsc && echo 'Build successful'",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"axios": "^1.7.7",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"body-parser": "^1.20.2",
|
||||
"body-parser": "^1.20.3",
|
||||
"configstore": "^5.0.1",
|
||||
"cookie-parser": "~1.4.6",
|
||||
"cookie-parser": "~1.4.7",
|
||||
"cron": "^3.1.7",
|
||||
"debug": "~4.3.6",
|
||||
"dockerode": "^3.3.5",
|
||||
"debug": "~4.3.7",
|
||||
"dockerode": "^4.0.2",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"fs-extra": "^10.1.0",
|
||||
"express": "^4.21.1",
|
||||
"fs-extra": "^11.2.0",
|
||||
"http-proxy": "^1.18.1",
|
||||
"is-valid-path": "^0.1.1",
|
||||
"js-base64": "^3.7.7",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"moment": "^2.30.1",
|
||||
"morgan": "^1.10.0",
|
||||
"multer": "^1.4.4",
|
||||
"on-finished": "^2.4.1",
|
||||
"prettier": "2.8.8",
|
||||
"public-ip": "^4.0.4",
|
||||
"prettier": "3.3.3",
|
||||
"public-ip": "^7.0.1",
|
||||
"recursive-readdir": "^2.2.3",
|
||||
"request": "^2.88.2",
|
||||
"require-from-string": "^2.0.2",
|
||||
"serve-favicon": "~2.5.0",
|
||||
"shell-quote": "^1.8.1",
|
||||
"simple-git": "^2.48.0",
|
||||
"ssh2": "^1.15.0",
|
||||
"tar": "^6.2.1",
|
||||
"typescript": "^4.9.5",
|
||||
"uuid": "^8.3.2",
|
||||
"simple-git": "^3.27.0",
|
||||
"ssh2": "^1.16.0",
|
||||
"tar": "^7.4.3",
|
||||
"typescript": "^5.6.3",
|
||||
"uuid": "^10.0.0",
|
||||
"validator": "^13.12.0",
|
||||
"yaml": "^1.10.2"
|
||||
"yaml": "^2.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.12.0",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/configstore": "^5.0.1",
|
||||
"@types/cookie-parser": "^1.4.7",
|
||||
"@types/debug": "^4.1.12",
|
||||
"@types/dockerode": "^3.3.31",
|
||||
"@types/ejs": "^3.1.5",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/http-proxy": "^1.17.15",
|
||||
"@types/is-valid-path": "^0.1.2",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/jest": "^29.5.13",
|
||||
"@types/js-base64": "^3.3.1",
|
||||
"@types/jsonwebtoken": "^8.5.9",
|
||||
"@types/jsonwebtoken": "^9.0.7",
|
||||
"@types/moment": "^2.13.0",
|
||||
"@types/morgan": "^1.9.9",
|
||||
"@types/multer": "^1.4.11",
|
||||
"@types/multer": "^1.4.12",
|
||||
"@types/on-finished": "^2.3.4",
|
||||
"@types/request": "^2.48.12",
|
||||
"@types/require-from-string": "^1.2.3",
|
||||
"@types/serve-favicon": "^2.5.7",
|
||||
"@types/shell-quote": "^1.7.5",
|
||||
"@types/ssh2": "^0.5.52",
|
||||
"@types/ssh2": "^1.15.1",
|
||||
"@types/tar": "^6.1.13",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@types/validator": "^13.12.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"eslint": "^7.32.0",
|
||||
"jest": "^27.5.1",
|
||||
"madge": "^5.0.2",
|
||||
"ts-jest": "^27.1.5"
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@types/validator": "^13.12.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
||||
"@typescript-eslint/parser": "^8.10.0",
|
||||
"eslint": "^9.12.0",
|
||||
"globals": "^15.11.0",
|
||||
"jest": "^29.7.0",
|
||||
"madge": "^8.0.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript-eslint": "^8.10.0"
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
class BaseApi {
|
||||
public data: any
|
||||
|
||||
constructor(public status: number, public description: string) {
|
||||
constructor(
|
||||
public status: number,
|
||||
public description: string
|
||||
) {
|
||||
this.data = {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import {
|
||||
AppDeployTokenConfig,
|
||||
IAllAppDefinitions,
|
||||
IAppDef,
|
||||
IAppDefSaved,
|
||||
IAppEnvVar,
|
||||
IAppPort,
|
||||
IAppTag,
|
||||
IAppVersion,
|
||||
IAppVolume,
|
||||
IHttpAuth,
|
||||
RepoInfo,
|
||||
} from '../models/AppDefinition'
|
||||
import { IBuiltImage } from '../models/IBuiltImage'
|
||||
import Authenticator from '../user/Authenticator'
|
||||
import ApacheMd5 from '../utils/ApacheMd5'
|
||||
@@ -31,7 +44,10 @@ function isPortValid(portNumber: number) {
|
||||
class AppsDataStore {
|
||||
private encryptor: CaptainEncryptor
|
||||
|
||||
constructor(private data: configstore, private namepace: string) {}
|
||||
constructor(
|
||||
private data: configstore,
|
||||
private namepace: string
|
||||
) {}
|
||||
|
||||
setEncryptor(encryptor: CaptainEncryptor) {
|
||||
this.encryptor = encryptor
|
||||
|
||||
@@ -15,6 +15,7 @@ import AppsDataStore from './AppsDataStore'
|
||||
import ProDataStore from './ProDataStore'
|
||||
import ProjectsDataStore from './ProjectsDataStore'
|
||||
import RegistriesDataStore from './RegistriesDataStore'
|
||||
import { NetDataInfo } from '../models/NetDataInfo'
|
||||
|
||||
// keys:
|
||||
const NAMESPACE = 'namespace'
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
import CaptainConstants from '../utils/CaptainConstants'
|
||||
import DataStore from './DataStore'
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import configstore = require('configstore')
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import Utils from '../utils/Utils'
|
||||
import AppsDataStore from './AppsDataStore'
|
||||
import { ProjectDefinition } from '../models/ProjectDefinition'
|
||||
|
||||
const PROJECTS_DEFINITIONS = 'projectsDefinitions'
|
||||
|
||||
@@ -124,9 +125,9 @@ class ProjectsDataStore {
|
||||
projectId = `${projectId || ''}`.trim()
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.data.get(
|
||||
`${PROJECTS_DEFINITIONS}.${projectId}`
|
||||
) as ProjectDefinition | undefined
|
||||
return self.data.get(`${PROJECTS_DEFINITIONS}.${projectId}`) as
|
||||
| ProjectDefinition
|
||||
| undefined
|
||||
})
|
||||
.then(function (project) {
|
||||
if (!project) {
|
||||
|
||||
@@ -15,7 +15,10 @@ const DEFAULT_DOCKER_REGISTRY_ID = 'defaultDockerRegId'
|
||||
class RegistriesDataStore {
|
||||
private encryptor: CaptainEncryptor
|
||||
|
||||
constructor(private data: configstore, public namepace: string) {}
|
||||
constructor(
|
||||
private data: configstore,
|
||||
public namepace: string
|
||||
) {}
|
||||
|
||||
setEncryptor(encryptor: CaptainEncryptor) {
|
||||
this.encryptor = encryptor
|
||||
|
||||
+24
-13
@@ -1,20 +1,30 @@
|
||||
import Base64Provider = require('js-base64')
|
||||
import Docker = require('dockerode')
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import {
|
||||
IAppDef,
|
||||
IAppEnvVar,
|
||||
IAppPort,
|
||||
IAppVolume,
|
||||
} from '../models/AppDefinition'
|
||||
import { DockerAuthObj, DockerRegistryConfig } from '../models/DockerAuthObj'
|
||||
import { DockerSecret } from '../models/DockerSecret'
|
||||
import DockerService from '../models/DockerService'
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
import {
|
||||
IDockerApiPort,
|
||||
IDockerContainerResource,
|
||||
PreDeployFunction,
|
||||
VolumesTypes,
|
||||
} from '../models/OtherTypes'
|
||||
import { ServerDockerInfo } from '../models/ServerDockerInfo'
|
||||
import BuildLog from '../user/BuildLog'
|
||||
import CaptainConstants from '../utils/CaptainConstants'
|
||||
import EnvVars from '../utils/EnvVars'
|
||||
import Logger from '../utils/Logger'
|
||||
import Utils from '../utils/Utils'
|
||||
import Dockerode = require('dockerode')
|
||||
// @ts-ignore
|
||||
// @ts-expect-error "TODO"
|
||||
import dockerodeUtils = require('dockerode/lib/util')
|
||||
|
||||
const Base64 = Base64Provider.Base64
|
||||
@@ -1425,11 +1435,11 @@ class DockerApi {
|
||||
|
||||
switch (updateOrder) {
|
||||
case IDockerUpdateOrders.AUTO:
|
||||
const existingVols =
|
||||
updatedData.TaskTemplate.ContainerSpec.Mounts ||
|
||||
[]
|
||||
updatedData.UpdateConfig.Order =
|
||||
existingVols.length > 0
|
||||
(
|
||||
updatedData.TaskTemplate.ContainerSpec
|
||||
.Mounts || []
|
||||
).length > 0
|
||||
? 'stop-first'
|
||||
: 'start-first'
|
||||
break
|
||||
@@ -1440,6 +1450,7 @@ class DockerApi {
|
||||
updatedData.UpdateConfig.Order = 'stop-first'
|
||||
break
|
||||
default:
|
||||
// eslint-disable-next-line
|
||||
const neverHappens: never = updateOrder
|
||||
throw new Error(
|
||||
`Unknown update order! ${updateOrder}${neverHappens}`
|
||||
@@ -1687,14 +1698,14 @@ const connectionParams: Docker.DockerOptions =
|
||||
socketPath: CaptainConstants.dockerSocketPath,
|
||||
}
|
||||
: dockerApiAddressSplited.length === 2
|
||||
? {
|
||||
host: dockerApiAddressSplited[0],
|
||||
port: Number(dockerApiAddressSplited[1]),
|
||||
}
|
||||
: {
|
||||
host: `${dockerApiAddressSplited[0]}:${dockerApiAddressSplited[1]}`,
|
||||
port: Number(dockerApiAddressSplited[2]),
|
||||
}
|
||||
? {
|
||||
host: dockerApiAddressSplited[0],
|
||||
port: Number(dockerApiAddressSplited[1]),
|
||||
}
|
||||
: {
|
||||
host: `${dockerApiAddressSplited[0]}:${dockerApiAddressSplited[1]}`,
|
||||
port: Number(dockerApiAddressSplited[2]),
|
||||
}
|
||||
|
||||
connectionParams.version = CaptainConstants.configs.dockerApiVersion
|
||||
const dockerApiInstance = new DockerApi(connectionParams)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Response } from 'express'
|
||||
import { UserInjected } from '../models/InjectionInterfaces'
|
||||
import { UserManager } from '../user/UserManager'
|
||||
import { IAppDef } from '../models/AppDefinition'
|
||||
|
||||
class InjectionExtractor {
|
||||
static extractUserFromInjected(res: Response) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import { UserManagerProvider } from '../user/UserManagerProvider'
|
||||
import CaptainConstants from '../utils/CaptainConstants'
|
||||
import Logger from '../utils/Logger'
|
||||
import InjectionExtractor from './InjectionExtractor'
|
||||
import { IAppDef } from '../models/AppDefinition'
|
||||
|
||||
const dockerApi = DockerApiProvider.get()
|
||||
|
||||
|
||||
+16
-14
@@ -1,18 +1,20 @@
|
||||
type IAllAppDefinitions = IHashMapGeneric<IAppDef>
|
||||
import { IHashMapGeneric } from './ICacheGeneric'
|
||||
|
||||
interface IAppEnvVar {
|
||||
export type IAllAppDefinitions = IHashMapGeneric<IAppDef>
|
||||
|
||||
export interface IAppEnvVar {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
interface IAppVolume {
|
||||
export interface IAppVolume {
|
||||
containerPath: string
|
||||
volumeName?: string
|
||||
hostPath?: string
|
||||
mode?: string
|
||||
}
|
||||
|
||||
interface IAppPort {
|
||||
export interface IAppPort {
|
||||
containerPort: number
|
||||
hostPort: number
|
||||
protocol?: 'udp' | 'tcp'
|
||||
@@ -20,7 +22,7 @@ interface IAppPort {
|
||||
publishMode?: 'ingress' | 'host'
|
||||
}
|
||||
|
||||
interface RepoInfo {
|
||||
export interface RepoInfo {
|
||||
repo: string
|
||||
branch: string
|
||||
user: string
|
||||
@@ -28,7 +30,7 @@ interface RepoInfo {
|
||||
password: string
|
||||
}
|
||||
|
||||
interface RepoInfoEncrypted {
|
||||
export interface RepoInfoEncrypted {
|
||||
repo: string
|
||||
branch: string
|
||||
user: string
|
||||
@@ -36,23 +38,23 @@ interface RepoInfoEncrypted {
|
||||
passwordEncrypted: string
|
||||
}
|
||||
|
||||
interface IAppVersion {
|
||||
export interface IAppVersion {
|
||||
version: number
|
||||
deployedImageName?: string // empty if the deploy is not completed
|
||||
timeStamp: string
|
||||
gitHash: string | undefined
|
||||
}
|
||||
|
||||
interface IAppCustomDomain {
|
||||
export interface IAppCustomDomain {
|
||||
publicDomain: string
|
||||
hasSsl: boolean
|
||||
}
|
||||
|
||||
interface IAppTag {
|
||||
export interface IAppTag {
|
||||
tagName: string
|
||||
}
|
||||
|
||||
interface IAppDefinitionBase {
|
||||
export interface IAppDefinitionBase {
|
||||
projectId?: string | undefined
|
||||
description: string
|
||||
deployedVersion: number
|
||||
@@ -79,18 +81,18 @@ interface IAppDefinitionBase {
|
||||
appDeployTokenConfig?: AppDeployTokenConfig
|
||||
}
|
||||
|
||||
interface IHttpAuth {
|
||||
export interface IHttpAuth {
|
||||
user: string
|
||||
password?: string
|
||||
passwordHashed?: string
|
||||
}
|
||||
|
||||
interface AppDeployTokenConfig {
|
||||
export interface AppDeployTokenConfig {
|
||||
enabled: boolean
|
||||
appDeployToken?: string
|
||||
}
|
||||
|
||||
interface IAppDef extends IAppDefinitionBase {
|
||||
export interface IAppDef extends IAppDefinitionBase {
|
||||
appPushWebhook?: {
|
||||
tokenVersion: string
|
||||
repoInfo: RepoInfo
|
||||
@@ -101,7 +103,7 @@ interface IAppDef extends IAppDefinitionBase {
|
||||
isAppBuilding?: boolean
|
||||
}
|
||||
|
||||
interface IAppDefSaved extends IAppDefinitionBase {
|
||||
export interface IAppDefSaved extends IAppDefinitionBase {
|
||||
appPushWebhook:
|
||||
| {
|
||||
tokenVersion: string
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { ServerDockerInfo } from './ServerDockerInfo'
|
||||
|
||||
export interface RestoringNode {
|
||||
oldIp: string
|
||||
newIp: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface DockerAuthObj {
|
||||
export interface DockerAuthObj {
|
||||
serveraddress: string
|
||||
username: string
|
||||
password: string
|
||||
@@ -17,7 +17,7 @@ interface DockerAuthObj {
|
||||
}
|
||||
}
|
||||
*/
|
||||
interface DockerRegistryConfig {
|
||||
export interface DockerRegistryConfig {
|
||||
[serveraddress: string]: {
|
||||
username: string
|
||||
password: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface DockerSecret {
|
||||
export interface DockerSecret {
|
||||
secretName: string
|
||||
secretId: string
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
interface IHashMapGeneric<T> {
|
||||
export interface IHashMapGeneric<T> {
|
||||
[id: string]: T
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface ICaptainDefinition {
|
||||
export interface ICaptainDefinition {
|
||||
schemaVersion: number
|
||||
dockerfileLines?: string[]
|
||||
dockerfilePath?: string
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
interface IImageSource {
|
||||
import { RepoInfo } from './AppDefinition'
|
||||
|
||||
export interface IImageSource {
|
||||
uploadedTarPathSource?: { uploadedTarPath: string; gitHash: string }
|
||||
captainDefinitionContentSource?: {
|
||||
captainDefinitionContent: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface IServerBlockDetails {
|
||||
export interface IServerBlockDetails {
|
||||
hasSsl: boolean
|
||||
forceSsl: boolean
|
||||
websocketSupport: boolean
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class NetDataInfo {
|
||||
export class NetDataInfo {
|
||||
public isEnabled: boolean
|
||||
public data: {
|
||||
smtp: {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IAppDef } from './AppDefinition'
|
||||
|
||||
export type CaptainError = {
|
||||
captainErrorType: number
|
||||
apiMessage: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface ProjectDefinition {
|
||||
export interface ProjectDefinition {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface ServerDockerInfo {
|
||||
export interface ServerDockerInfo {
|
||||
nodeId: string
|
||||
type: 'manager' | 'worker'
|
||||
isLeader: boolean
|
||||
|
||||
@@ -4,6 +4,7 @@ import ApiStatusCodes from '../../api/ApiStatusCodes'
|
||||
import BaseApi from '../../api/BaseApi'
|
||||
import InjectionExtractor from '../../injection/InjectionExtractor'
|
||||
import Logger from '../../utils/Logger'
|
||||
import { ProjectDefinition } from '../../models/ProjectDefinition'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import ProjectsRouter from './ProjectsRouter'
|
||||
import RegistriesRouter from './registeries/RegistriesRouter'
|
||||
import SystemRouter from './system/SystemRouter'
|
||||
import onFinished = require('on-finished')
|
||||
import { IHashMapGeneric } from '../../models/ICacheGeneric'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import CaptainManager from '../../../../user/system/CaptainManager'
|
||||
import CaptainConstants from '../../../../utils/CaptainConstants'
|
||||
import Logger from '../../../../utils/Logger'
|
||||
import Utils from '../../../../utils/Utils'
|
||||
import { IAppDef, AppDeployTokenConfig } from '../../../../models/AppDefinition'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import CaptainConstants from '../utils/CaptainConstants'
|
||||
import EnvVar from '../utils/EnvVars'
|
||||
import Logger from '../utils/Logger'
|
||||
import bcrypt = require('bcryptjs')
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
|
||||
const captainDefaultPassword = EnvVar.DEFAULT_PASSWORD || 'captain42'
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import DataStore from '../datastore/DataStore'
|
||||
import RegistriesDataStore from '../datastore/RegistriesDataStore'
|
||||
import DockerApi from '../docker/DockerApi'
|
||||
import { DockerAuthObj, DockerRegistryConfig } from '../models/DockerAuthObj'
|
||||
import {
|
||||
IRegistryInfo,
|
||||
IRegistryType,
|
||||
@@ -14,7 +15,10 @@ import BuildLog from './BuildLog'
|
||||
|
||||
class DockerRegistryHelper {
|
||||
private registriesDataStore: RegistriesDataStore
|
||||
constructor(dataStore: DataStore, private dockerApi: DockerApi) {
|
||||
constructor(
|
||||
dataStore: DataStore,
|
||||
private dockerApi: DockerApi
|
||||
) {
|
||||
this.registriesDataStore = dataStore.getRegistriesDataStore()
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,12 @@ export default class FeatureFlags {
|
||||
Logger.e(error)
|
||||
})
|
||||
.then(function () {
|
||||
setTimeout(() => {
|
||||
self.refreshFeatureFlags()
|
||||
}, 1000 * 3600 * 19.3) // some random hour to avoid constant traffic
|
||||
setTimeout(
|
||||
() => {
|
||||
self.refreshFeatureFlags()
|
||||
},
|
||||
1000 * 3600 * 19.3
|
||||
) // some random hour to avoid constant traffic
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,11 @@ import tar = require('tar')
|
||||
import path = require('path')
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import DockerApi from '../docker/DockerApi'
|
||||
import { IAppEnvVar } from '../models/AppDefinition'
|
||||
import { IBuiltImage } from '../models/IBuiltImage'
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
import { ICaptainDefinition } from '../models/ICaptainDefinition'
|
||||
import { IImageSource } from '../models/IImageSource'
|
||||
import { AnyError } from '../models/OtherTypes'
|
||||
import CaptainConstants from '../utils/CaptainConstants'
|
||||
import GitHelper from '../utils/GitHelper'
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import DataStore from '../datastore/DataStore'
|
||||
import DockerApi, { IDockerUpdateOrders } from '../docker/DockerApi'
|
||||
import {
|
||||
AppDeployTokenConfig,
|
||||
IAppDef,
|
||||
IAppEnvVar,
|
||||
IAppPort,
|
||||
IAppTag,
|
||||
IAppVolume,
|
||||
IHttpAuth,
|
||||
RepoInfo,
|
||||
} from '../models/AppDefinition'
|
||||
import { DockerAuthObj } from '../models/DockerAuthObj'
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
import { IImageSource } from '../models/IImageSource'
|
||||
import { PreDeployFunction } from '../models/OtherTypes'
|
||||
import CaptainConstants from '../utils/CaptainConstants'
|
||||
import Logger from '../utils/Logger'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
import CaptainConstants from '../utils/CaptainConstants'
|
||||
import { UserManager } from './UserManager'
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ import { TwoFactorAuthResponse } from '../../models/IProFeatures'
|
||||
import ProManager from './ProManager'
|
||||
|
||||
export default class OtpAuthenticator {
|
||||
constructor(private dataStore: DataStore, private proManager: ProManager) {}
|
||||
constructor(
|
||||
private dataStore: DataStore,
|
||||
private proManager: ProManager
|
||||
) {}
|
||||
|
||||
set2fa(
|
||||
doEnable: boolean,
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import SshClientImport = require('ssh2')
|
||||
import { exec } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import * as moment from 'moment'
|
||||
import moment from 'moment'
|
||||
import * as path from 'path'
|
||||
import * as tar from 'tar'
|
||||
import ApiStatusCodes from '../../api/ApiStatusCodes'
|
||||
import DockerApi from '../../docker/DockerApi'
|
||||
import DockerUtils from '../../docker/DockerUtils'
|
||||
import { IAppDefSaved } from '../../models/AppDefinition'
|
||||
import { BackupMeta, RestoringInfo } from '../../models/BackupMeta'
|
||||
import { IHashMapGeneric } from '../../models/ICacheGeneric'
|
||||
import { ServerDockerInfo } from '../../models/ServerDockerInfo'
|
||||
import CaptainConstants from '../../utils/CaptainConstants'
|
||||
import Logger from '../../utils/Logger'
|
||||
import Utils from '../../utils/Utils'
|
||||
@@ -717,13 +720,16 @@ export default class BackupManager {
|
||||
)}-${now.valueOf()}`}${`-ip-${mainIP}.tar`}`
|
||||
fs.moveSync(tarFilePath, newName)
|
||||
|
||||
setTimeout(() => {
|
||||
try {
|
||||
fs.removeSync(newName)
|
||||
} catch (err) {
|
||||
// nom nom
|
||||
}
|
||||
}, 1000 * 3600 * 2)
|
||||
setTimeout(
|
||||
() => {
|
||||
try {
|
||||
fs.removeSync(newName)
|
||||
} catch (err) {
|
||||
// nom nom
|
||||
}
|
||||
},
|
||||
1000 * 3600 * 2
|
||||
)
|
||||
|
||||
return Authenticator.getAuthenticator(
|
||||
namespace
|
||||
|
||||
@@ -25,6 +25,7 @@ import LoadBalancerManager from './LoadBalancerManager'
|
||||
import SelfHostedDockerRegistry from './SelfHostedDockerRegistry'
|
||||
import request = require('request')
|
||||
import fs = require('fs-extra')
|
||||
import { NetDataInfo } from '../../models/NetDataInfo'
|
||||
|
||||
const DEBUG_SALT = 'THIS IS NOT A REAL CERTIFICATE'
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ import Logger from '../../utils/Logger'
|
||||
|
||||
export default class DiskCleanupManager {
|
||||
private job: CronJob | undefined
|
||||
constructor(private dataStore: DataStore, private dockerApi: DockerApi) {
|
||||
constructor(
|
||||
private dataStore: DataStore,
|
||||
private dockerApi: DockerApi
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { v4 as uuid } from 'uuid'
|
||||
import ApiStatusCodes from '../../api/ApiStatusCodes'
|
||||
import DataStore from '../../datastore/DataStore'
|
||||
import DockerApi from '../../docker/DockerApi'
|
||||
import { IServerBlockDetails } from '../../models/IServerBlockDetails'
|
||||
import LoadBalancerInfo from '../../models/LoadBalancerInfo'
|
||||
import { AnyError } from '../../models/OtherTypes'
|
||||
import CaptainConstants from '../../utils/CaptainConstants'
|
||||
@@ -850,12 +851,15 @@ class LoadBalancerManager {
|
||||
// this random schedule helps to avoid retrying at the same time of
|
||||
// the day in case if that's our super high traffic time
|
||||
|
||||
setTimeout(function () {
|
||||
self.renewAllCertsAndReload() //
|
||||
.catch((err) => {
|
||||
Logger.e(err)
|
||||
})
|
||||
}, 1000 * 3600 * 20.3)
|
||||
setTimeout(
|
||||
function () {
|
||||
self.renewAllCertsAndReload() //
|
||||
.catch((err) => {
|
||||
Logger.e(err)
|
||||
})
|
||||
},
|
||||
1000 * 3600 * 20.3
|
||||
)
|
||||
|
||||
return self.certbotManager
|
||||
.renewAllCerts() //
|
||||
|
||||
@@ -96,7 +96,6 @@ export default class ApacheMd5 {
|
||||
let final = crypto
|
||||
.createHash('md5')
|
||||
.update(password + salt + password, 'ascii')
|
||||
//@ts-ignore
|
||||
.digest(DIGEST_ENCODING)
|
||||
|
||||
for (let pl = password.length; pl > 0; pl -= 16) {
|
||||
@@ -111,11 +110,9 @@ export default class ApacheMd5 {
|
||||
}
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
final = crypto
|
||||
.createHash('md5')
|
||||
.update(ctx, 'ascii')
|
||||
//@ts-ignore
|
||||
.digest(DIGEST_ENCODING)
|
||||
|
||||
// 1000 loop.
|
||||
@@ -147,7 +144,6 @@ export default class ApacheMd5 {
|
||||
final = crypto
|
||||
.createHash('md5')
|
||||
.update(ctxl, 'ascii')
|
||||
//@ts-ignore
|
||||
.digest(DIGEST_ENCODING)
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ function overrideConfigFromFile(fileName: string) {
|
||||
}
|
||||
|
||||
console.log(`Overriding ${prop} from ${fileName}`)
|
||||
// @ts-ignore
|
||||
// @ts-expect-error "this actually works"
|
||||
configs[prop] = overridingValuesConfigs[prop]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import externalIp = require('public-ip')
|
||||
import DockerApi from '../docker/DockerApi'
|
||||
import { IAppEnvVar, IAppPort } from '../models/AppDefinition'
|
||||
import BackupManager from '../user/system/BackupManager'
|
||||
import CaptainConstants from './CaptainConstants'
|
||||
import EnvVar from './EnvVars'
|
||||
@@ -198,6 +198,11 @@ function printTroubleShootingUrl() {
|
||||
|
||||
let myIp4: string
|
||||
|
||||
async function initializeExternalIp() {
|
||||
const externalIp = await import('public-ip')
|
||||
return externalIp
|
||||
}
|
||||
|
||||
export function install() {
|
||||
const backupManger = new BackupManager()
|
||||
|
||||
@@ -222,12 +227,15 @@ export function install() {
|
||||
return checkSystemReq()
|
||||
})
|
||||
.then(function () {
|
||||
return initializeExternalIp()
|
||||
})
|
||||
.then(function (externalIp) {
|
||||
if (EnvVar.MAIN_NODE_IP_ADDRESS) {
|
||||
return EnvVar.MAIN_NODE_IP_ADDRESS
|
||||
}
|
||||
|
||||
try {
|
||||
const externalIpFetched = externalIp.v4()
|
||||
const externalIpFetched = externalIp.publicIpv4()
|
||||
if (externalIpFetched) {
|
||||
return externalIpFetched
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as childProcess from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import * as path from 'path'
|
||||
import * as git from 'simple-git/promise'
|
||||
import git from 'simple-git'
|
||||
import * as util from 'util'
|
||||
import * as uuid from 'uuid'
|
||||
import CaptainConstants from './CaptainConstants'
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import * as moment from 'moment'
|
||||
import moment from 'moment'
|
||||
import { AnyError } from '../models/OtherTypes'
|
||||
import CaptainConstants from './CaptainConstants'
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as fs from 'fs-extra'
|
||||
import * as path from 'path'
|
||||
import DataStore from '../datastore/DataStore'
|
||||
import DockerApi from '../docker/DockerApi'
|
||||
import { IAppVersion } from '../models/AppDefinition'
|
||||
import { IRegistryTypes } from '../models/IRegistryInfo'
|
||||
import Authenticator from '../user/Authenticator'
|
||||
import CaptainConstants from './CaptainConstants'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import request = require('request')
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import { IHashMapGeneric } from '../models/ICacheGeneric'
|
||||
import { ITemplate } from '../models/OtherTypes'
|
||||
import Logger from './Logger'
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as configstore from 'configstore'
|
||||
import configstore from 'configstore'
|
||||
import AppsDataStore from '../src/datastore/AppsDataStore'
|
||||
import ProjectsDataStore from '../src/datastore/ProjectsDataStore'
|
||||
import { ProjectDefinition } from '../src/models/ProjectDefinition'
|
||||
|
||||
describe('ProjectsDataStore', () => {
|
||||
let projectsDataStore: ProjectsDataStore
|
||||
|
||||
+6
-7
@@ -1,16 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./built",
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true,
|
||||
"noUnusedLocals": true,
|
||||
"target": "es6"
|
||||
"target": "ES2018"
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*"
|
||||
]
|
||||
}
|
||||
"include": ["./src/**/*"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user