Skip to content

Commit

Permalink
fix: bump dependency versions
Browse files Browse the repository at this point in the history
Its been some time since the last release, so this is just a quick
version bump to update everything to the latest version.

BREAKING CHANGE: Minimum supported version of Node.js is now 15

Closes GabeDuarteM#94
  • Loading branch information
GabeDuarteM committed Jul 5, 2022
1 parent 8807c86 commit 5f7efef
Show file tree
Hide file tree
Showing 12 changed files with 4,080 additions and 6,388 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js

This file was deleted.

16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": {
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"]
}
6 changes: 5 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
module.exports = require('gd-scripts/prettier')
module.exports = {
semi: false,
singleQuote: true,
trailingComma: 'all',
}
25 changes: 25 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
},
"loose": true,
"exclude": [
"proposal-dynamic-import"
]
}
],
["@babel/preset-typescript"]
],
"ignore": [
"**/*.test.js",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.d.ts",
"__mocks__",
"@types"
]
}
48 changes: 28 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "semantic-release-chrome",
"version": "0.0.0-development",
"main": "dist/index.js",
"author": "Gabriel Duarte (https://www.gabrielduarte.tech)",
"exports": "./dist/index.js",
"author": "Gabriel Duarte (https://www.gabrielduarte.dev)",
"license": "MIT",
"description": "Set of semantic-release plugins for publishing a Chrome extension release",
"engines": {
"node": ">=8.3"
"node": ">=15"
},
"keywords": [
"semantic-release",
Expand All @@ -21,28 +21,36 @@
"dist"
],
"scripts": {
"start": "gd-scripts start",
"build": "gd-scripts build",
"ci": "gd-scripts ci",
"lint": "gd-scripts lint",
"typecheck": "gd-scripts typecheck",
"start": "yarn build --watch",
"build": "rimraf ./dist && tsc && babel src --out-dir dist --extensions .js,.jsx,.ts,.tsx",
"lint": "eslint src",
"ci": "yarn lint && yarn build",
"typecheck": "tsc --noEmit",
"release": "semantic-release"
},
"devDependencies": {
"@types/adm-zip": "0.4.32",
"@types/archiver": "2.1.3",
"@types/fs-extra": "5.0.5",
"@types/node": "11.13.9",
"gd-scripts": "5.0.3",
"prettier": "1.16.4",
"semantic-release": "15.13.3"
"@babel/cli": "7.18.6",
"@babel/core": "7.18.6",
"@babel/preset-env": "7.18.6",
"@babel/preset-typescript": "7.18.6",
"@types/archiver": "5.3.1",
"@types/fs-extra": "9.0.13",
"@types/node": "18.0.1",
"@types/semantic-release": "17.2.3",
"@typescript-eslint/eslint-plugin": "5.30.5",
"@typescript-eslint/parser": "5.30.5",
"eslint": "8.19.0",
"eslint-config-prettier": "8.5.0",
"prettier": "2.7.1",
"rimraf": "3.0.2",
"semantic-release": "19.0.3",
"typescript": "4.7.4"
},
"dependencies": {
"@semantic-release/error": "2.2.0",
"aggregate-error": "3.0.0",
"archiver": "3.0.0",
"chrome-webstore-upload": "0.2.2",
"fs-extra": "7.0.1"
"@semantic-release/error": "3.0.0",
"archiver": "5.3.1",
"chrome-webstore-upload": "1.0.0",
"fs-extra": "10.1.0"
},
"repository": {
"type": "git",
Expand Down
12 changes: 11 additions & 1 deletion release.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
module.exports = require('gd-scripts/semver')
module.exports = {
analyzeCommits: {
releaseRules: [
{
type: 'docs',
scope: 'README',
release: 'patch',
},
],
},
}
13 changes: 0 additions & 13 deletions src/@types/context.ts

This file was deleted.

15 changes: 10 additions & 5 deletions src/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { readJsonSync, writeJsonSync } from 'fs-extra'
import { createWriteStream } from 'fs'
import { resolve } from 'path'

import Context, { Logger } from './@types/context'
import PluginConfig from './@types/pluginConfig'
import type PluginConfig from './@types/pluginConfig'
import { Context } from 'semantic-release'

const prepareManifest = (
manifestPath: string,
version: string,
logger: Logger,
logger: Context['logger'],
) => {
const manifest = readJsonSync(manifestPath)

Expand All @@ -24,7 +24,7 @@ const zipFolder = (
asset: string,
distFolder: string,
version: string,
logger: Logger,
logger: Context['logger'],
) => {
const zipPath = resolve(asset)
const output = createWriteStream(zipPath)
Expand All @@ -51,7 +51,12 @@ const prepare = (
)
}

const version = nextRelease.version
const version = nextRelease?.version
if (!version) {
throw new SemanticReleaseError(
'Could not determine the version from semantic release.',
)
}

const normalizedDistFolder = distFolder || 'dist'

Expand Down
35 changes: 23 additions & 12 deletions src/publish.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import SemanticReleaseError from '@semantic-release/error'
import AggregateError from 'aggregate-error'
import cwu from 'chrome-webstore-upload'
import { createReadStream } from 'fs-extra'
import { Context } from 'semantic-release'

import Context from './@types/context'
import PluginConfig from './@types/pluginConfig'
import type PluginConfig from './@types/pluginConfig'

const errorWhitelist = ['PUBLISHED_WITH_FRICTION_WARNING']

const modulesCache: { [keyof: string]: any } = {}

const getEsModule = async (module: string) => {
if (modulesCache[module]) {
return modulesCache[module]
}

const esModule = await import(module)
modulesCache[module] = esModule.default || esModule

return modulesCache[module]
}

const publish = async (
{ extensionId, target, asset }: PluginConfig,
{ logger }: Context,
Expand All @@ -32,17 +43,17 @@ const publish = async (
)
}

const webStore = await cwu({
const webStore = await (
await getEsModule('chrome-webstore-upload')
)({
clientId,
clientSecret,
extensionId,
refreshToken,
})

const token = await webStore.fetchToken()

const zipFile = createReadStream(asset)
const uploadRes = await webStore.uploadExisting(zipFile, token)
const uploadRes = await webStore.uploadExisting(zipFile)

if (uploadRes.uploadState === 'FAILURE') {
const errors: SemanticReleaseError[] = []
Expand All @@ -53,25 +64,25 @@ const publish = async (
)
errors.push(semanticError)
})
throw new AggregateError(errors)
throw new AggregateError(errors).errors
}

const publishRes = await webStore.publish(target || 'default', token)
const publishRes = await webStore.publish(target || 'default')

if (!publishRes.status.includes('OK')) {
const errors: SemanticReleaseError[] = []
for (let i = 0; i < publishRes.status.length; i += 1) {
const code = publishRes.status[i]
const message = publishRes.statusDetail[i]
if (errorWhitelist.includes(code)) {
logger.warn(`${code}: ${message}`)
logger.log(`${code}: ${message}`)
} else {
const err = new SemanticReleaseError(message, code)
errors.push(err)
}
}
if (errors.length > 0) {
throw new AggregateError(errors)
throw new AggregateError(errors).errors
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/verifyConditions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SemanticReleaseError from '@semantic-release/error'
import AggregateError from 'aggregate-error'

const configMessage = 'Check the README.md for config info.'

Expand Down Expand Up @@ -30,7 +29,7 @@ const verifyConditions = () => {
}

if (errors.length > 0) {
throw new AggregateError(errors)
throw new AggregateError(errors).errors
}
}

Expand Down
22 changes: 21 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
{
"extends": "./node_modules/gd-scripts/typescript.json"
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"strict": true,
"lib": ["esnext"],
"typeRoots": ["./node_modules/@types", "./src/types"],
"outDir": "./dist",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["./src/**/*"],
"exclude": [
"./node_modules/**/*",
"./dist/**/*",
"./src/**/*.test.ts",
"./src/**/*.test.js"
]
}

0 comments on commit 5f7efef

Please sign in to comment.