Skip to content

Commit

Permalink
fix: Update dependencies and fix typescript errors (#211)
Browse files Browse the repository at this point in the history
* Adapt code to the new version of ts

* Fix the default import

* Fix the default import

* Fix Listr import

* Remove debugger
  • Loading branch information
Khaledgarbaya committed Jul 30, 2019
1 parent df609a9 commit bf9bcf7
Show file tree
Hide file tree
Showing 29 changed files with 3,444 additions and 4,338 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as axios from '@contentful/axios'
import axios from 'axios'

export interface Movement {
toTheTop(): void
Expand Down
7,712 changes: 3,405 additions & 4,307 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"all": true
},
"dependencies": {
"axios": "^0.19.0",
"bluebird": "^3.5.0",
"callsites": "^2.0.0",
"cardinal": "^1.0.0",
Expand All @@ -96,7 +97,7 @@
"@types/chai": "^4.0.4",
"@types/chai-as-promised": "^7.1.0",
"@types/hoek": "^4.1.3",
"@types/joi": "^10.4.4",
"@types/joi": "^10.6.5",
"@types/lodash": "^4.14.77",
"@types/mocha": "^2.2.43",
"@types/node": "^8.0.46",
Expand All @@ -117,18 +118,18 @@
"nyc": "^11.2.1",
"rewire": "^2.5.2",
"rimraf": "^2.6.2",
"semantic-release": "^15.13.19",
"sinon": "^2.4.1",
"sinon-chai": "^2.13.0",
"source-map-support": "^0.5.0",
"strip-ansi": "^4.0.0",
"travis-deploy-once": "^5.0.8",
"ts-node": "^3.3.0",
"tslint": "^5.7.0",
"tslint-config-standard": "^6.0.1",
"typescript": "^2.5.3",
"uuid": "^3.3.2",
"zlib": "^1.0.5",
"semantic-release": "^15.9.16",
"travis-deploy-once": "^5.0.8"
"zlib": "^1.0.5"
},
"bin": {
"contentful-migration": "./bin/contentful-migration"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path'

import chalk from 'chalk'
import * as inquirer from 'inquirer'
import * as Listr from 'listr'
import Listr from 'listr'
import { createManagementClient } from './lib/contentful-client'
const { version } = require('../../package.json')
const {
Expand Down
8 changes: 6 additions & 2 deletions src/bin/lib/contentful-client/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import * as HttpsProxyAgent from 'https-proxy-agent'
import HttpsProxyAgent from 'https-proxy-agent'
import * as _ from 'lodash'
import * as url from 'url'
import { RequestOptions } from 'http'

type ProxyAuthConfig = {
username?: string
password?: string
}
type ProxyConfig = RequestOptions | {
isHttps: boolean
// auth: ProxyAuthConfig
auth?: ProxyAuthConfig
}

function parseAuth (authString: string): { username: string, password: string } {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/action/entry-derive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EntryDeriveAction extends APIAction {
targetEntry.setField(fieldId, {})
}

for (const [locale, localizedValue] of _.entries(localizedField)) {
for (const [locale, localizedValue] of _.entries((localizedField as object))) {
targetEntry.setFieldForLocale(fieldId, locale, localizedValue)
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/action/entry-transform-to-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class EntryTransformToTypeAction extends APIAction {
targetEntry.setField(fieldId, {})
}

for (const [locale, localizedValue] of _.entries(localizedField)) {
for (const [locale, localizedValue] of _.entries((localizedField as object))) {
targetEntry.setFieldForLocale(fieldId, locale, localizedValue)
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { APIContentType, APIEditorInterfaces } from '../lib/interfaces/content-t
import APIEntry from '../lib/interfaces/api-entry'
import { ContentType } from '../lib/entities/content-type'
import * as _ from 'lodash'
import * as Bluebird from 'bluebird'
import Bluebird from 'bluebird'
import APIFetcher from './interfaces/api-fetcher'

export default class Fetcher implements APIFetcher {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/intent-validator/content-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ContentTransformIntentValidator extends SchemaValidator {
from: Joi.array().items(Joi.string()).required(),
to: Joi.array().items(Joi.string()).required(),
transformEntryForLocale: Joi.func().required(),
shouldPublish: Joi.alternatives().try(Joi.boolean(), Joi.string().valid('preserve'))
shouldPublish: Joi.alternatives().try([Joi.boolean(), Joi.string().valid(['preserve'])])
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/intent-validator/field-movement.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FieldMoveIntent from '../intent/field-move'
import * as Joi from 'joi'
import * as didYouMean from 'didyoumean2'
import * as kindOf from 'kind-of'
import didYouMean from 'didyoumean2'
import kindOf from 'kind-of'

import IntentValidator from '../interfaces/intent-validator'
import ValidationError from '../interfaces/errors'
Expand Down
4 changes: 2 additions & 2 deletions src/lib/intent-validator/schema-validator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as Joi from 'joi'
import * as didYouMean from 'didyoumean2'
import * as kindOf from 'kind-of'
import didYouMean from 'didyoumean2'
import kindOf from 'kind-of'

import IntentValidator from '../interfaces/intent-validator'
import ValidationError from '../interfaces/errors'
Expand Down
1 change: 0 additions & 1 deletion src/lib/intent/composed-intent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export default class ComposedIntent implements Intent {
}
createSections.push(nextUpdateSection)
}
debugger
for (const createIntent of fieldCreates) {
const fieldId = createIntent.getFieldId()
const [createSection] = createIntent.toPlanMessage().sections
Expand Down
4 changes: 2 additions & 2 deletions src/lib/migration-chunks/validation/content-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ export default function (intents: Intent[], contentTypes: ContentType[]): Invali

let context = {
remote: new Set(remote), // all currently (in the current iteration step) existing content types
created: new Set(), // all by now (in previous iteration steps) created content types
deleted: new Set(), // all by now (in previous iteration steps) deleted content types
created: new Set<string>(), // all by now (in previous iteration steps) created content types
deleted: new Set<string>(), // all by now (in previous iteration steps) deleted content types
toBeCreated: new Set(toBeCreated), // all future (in remaining iteration steps) created content types
remoteContentTypes: contentTypes
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/migration-steps/dispatch-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import * as getFirstExternalCaller from './first-external-caller'
import getFirstExternalCaller from './first-external-caller'

/*
Base class that dynamically dispatches property update messages based on the function being called
Expand Down
4 changes: 2 additions & 2 deletions src/lib/migration-steps/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

import * as Bluebird from 'bluebird'
import Bluebird from 'bluebird'
import actionCreators from './action-creators'
import * as getFirstExternalCaller from './first-external-caller'
import getFirstExternalCaller from './first-external-caller'
import Intent from '../intent'
import DispatchProxy from './dispatch-proxy'
import { omit } from 'lodash'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/offline-api/validator/schema/schema-validation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Joi from 'joi'
import * as _ from 'lodash'
import { reach } from 'hoek'
import * as kindOf from 'kind-of'
import kindOf from 'kind-of'
import errorMessages from '../errors'
import { PayloadValidationError } from '../../../interfaces/errors'
import { ContentType } from '../../../entities/content-type'
Expand Down
1 change: 0 additions & 1 deletion test/end-to-end/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ module.exports = {
apply: function () {
return result => {
expect(result.stdout).not.to.be.empty();

const withoutAnsiCodes = stripAnsi(result.stdout);
expect(withoutAnsiCodes).to.include(`The following migration has been planned`);
expect(withoutAnsiCodes).to.include(`? Do you want to apply the migration Yes`);
Expand Down
1 change: 0 additions & 1 deletion test/end-to-end/content-transform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ describe('apply content transformation', function () {
.end(async function () {
const res = await getEntries(SOURCE_TEST_SPACE, environmentId, 'newsArticle');
const entriesWithoutSys = res.items.map(i => _.omit(i, 'sys'));

const expected = [
{
fields: {
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/migration-scripts/empty-migration.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* tslint:disable */
module.exports = function () {};
2 changes: 1 addition & 1 deletion test/unit/bin/lib/render-migrations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai'
import * as sinon from 'sinon'
import sinon from 'sinon'
import renderSetup from './render-setup'

import { renderPlan } from '../../../../src/bin/lib/render-migration'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/content-types-in-chunks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

import { expect } from 'chai'
import * as sinon from 'sinon'
import sinon from 'sinon'

import { migration as migrationSteps } from '../../../src/lib/migration-steps'
import IntentList from '../../../src/lib/intent-list'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/deleted-ct-entries.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
import { migration as migrationSteps } from '../../../src/lib/migration-steps'
import IntentList from '../../../src/lib/intent-list'
import * as sinon from 'sinon'
import sinon from 'sinon'
import Fetcher from '../../../src/lib/fetcher'
import makeApiContentType from '../../helpers/make-api-content-type'
import { ContentType } from '../../../src/lib/entities/content-type'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/fetcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai'
import * as sinon from 'sinon'
import sinon from 'sinon'

import { migration as buildIntents } from '../../../src/lib/migration-steps'
import IntentList from '../../../src/lib/intent-list'
Expand Down
1 change: 0 additions & 1 deletion test/unit/lib/intent-validator/content-transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ describe('Content transformation', function () {
const validationErrors = await validateSteps(function up (migration) {
migration.transformEntries(properties)
})

expect(validationErrors).to.eql([
{
details: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe('payload validation', function () {
.name(`menu${i}`)
}
}, [])

expect(errors).to.eql([
[
{
Expand Down
2 changes: 2 additions & 0 deletions test/unit/lib/step-validator/updates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ describe('migration-steps validation', function () {

describe('when passing the wrong type for a prop', function () {
it('returns all the validation errors', Bluebird.coroutine(function * () {
/* tslint:disable */
const invalidFunction = function () {};
/* tslint:enable */
const validationErrors = yield validateSteps(function up (migration) {
const person = migration.createContentType('person', {
description: ['Array']
Expand Down
1 change: 1 addition & 0 deletions tsconfig-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"outDir": "./built",
"allowJs": true,
"target": "es2017",
"esModuleInterop":true,
"module": "commonjs",
"lib": [
"es2015",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"outDir": "./built",
"allowJs": true,
"target": "es2017",
"esModuleInterop":true,
"module": "commonjs",
"lib": [
"es2015",
Expand Down
3 changes: 3 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"defaultSeverity": "error",
"extends": "tslint-config-standard",
"jsRules": {
"no-empty": true
},
"rules": {
"await-promise": false,
"return-undefined": false
Expand Down

0 comments on commit bf9bcf7

Please sign in to comment.