Skip to content

Commit

Permalink
feat!: make into es module (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian authored Nov 21, 2023
1 parent 054a534 commit a1dc5cd
Show file tree
Hide file tree
Showing 22 changed files with 7,718 additions and 184 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy plugin

on:
push:
branches: [main, beta, alpha]

jobs:
deploy-git-tag-and-push-npm:
runs-on: ubuntu-latest
permissions:
contents: write # to create git tag
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm ci

- name: Deploy git tag via semantic-release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: latest # since our plugin has a devDependency on semantic-release, using latest keyword here will upgrade node_modules/ copy to the latest version for deployment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUSH_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run tests

on: [pull_request, push]

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run test

run-plugin-in-semantic-release:
if: github.event_name == 'push' # semantic-release only seems to work when running on push, not on pull_request because of temp branch made during PRs.
runs-on: macos-latest # because cocoapods is already installed on these machines
permissions:
contents: write # to set permissions for semantic-release dry-run to pass
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm ci

- name: install self to run it in semantic-release
run: |
npm pack
npm install --no-save semantic-release-cocoapods-0.0.0.tgz
- name: setup git user to run semantic-release
run: |
git config --global user.email "user@example.com"
git config --global user.name "Example User"
- name: Create config file used just for testing
run: cp .releaserc.testing.json .releaserc.json

- name: Run semantic-release in dry run
run: unset GITHUB_ACTIONS && npx semantic-release --dry-run --no-ci --branches "${{ github.ref_name }},main"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
139 changes: 69 additions & 70 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,55 +1,14 @@

# Created by https://www.gitignore.io/api/macos,windows,linux,node

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
Expand All @@ -62,11 +21,12 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
Expand All @@ -75,22 +35,34 @@ bower_components
# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

Expand All @@ -100,32 +72,59 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Docusaurus cache and generated files
.docusaurus

# Folder config file
Desktop.ini
# Serverless directories
.serverless/

# Recycle Bin used on file shares
$RECYCLE.BIN/
# FuseBox cache
.fusebox/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# DynamoDB Local files
.dynamodb/

# Windows shortcuts
*.lnk
# TernJS port file
.tern-port

# End of https://www.gitignore.io/api/macos,windows,linux,node
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

package-lock.json
yarn.lock
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
7 changes: 7 additions & 0 deletions .releaserc.testing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": [
["semantic-release-cocoapods", {
"podLint": false
}]
]
}
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[![Travis](https://travis-ci.com/levibostian/semantic-release-cocoapods.svg?branch=master)](https://travis-ci.org/levibostian/semantic-release-cocoapods)
[![npm latest version](https://img.shields.io/npm/v/semantic-release-cocoapods/latest.svg)](https://www.npmjs.com/package/semantic-release-cocoapods)

# semantic-release-cocoapods
Expand All @@ -21,25 +20,20 @@ $ npm install semantic-release-cocoapods -D

First, make sure that [cocoapods is installed on your machine](https://guides.cocoapods.org/using/getting-started.html#installation).

The plugin is recommended be configured in the [**semantic-release** configuration file](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration). This is because this plugin must exist *after* [@semantic-release/github](https://github.com/semantic-release/github). Cocoapods requires a GitHub tag exists to make a release.
Next, add the plugin to your [**semantic-release** configuration file](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration).

```json
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
"semantic-release-cocoapods"
]
}
```

## Configuration

### Cocoapods authentication

The npm authentication configuration is **required** and can be set via [environment variables](#environment-variables).

### Environment variables

To use this plugin and ultimately publish a cocoapods package, you must set these environment variables.
Expand Down
29 changes: 14 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
const {defaultTo} = require('lodash');
const AggregateError = require('aggregate-error');
const verifyPluginConfig = require('./lib/verify-config');
const verifyPodAuth = require('./lib/verify-auth');
const verifyCliInstalled = require('./lib/verify-cli-installed');
const verifyPodLint = require('./lib/verify-pod-lint');
const preparePod = require('./lib/prepare');
const publishPod = require('./lib/publish');
import {defaultTo} from 'lodash-es';
import AggregateError from 'aggregate-error';
import verifyPluginConfig from './lib/verify-config.js';
import verifyPodAuth from './lib/verify-auth.js';
import verifyCliInstalled from './lib/verify-cli-installed.js';
import verifyPodLint from './lib/verify-pod-lint.js';
import preparePod from './lib/prepare.js';
import publishPod from './lib/publish.js';

// Let verified;
let prepared;

async function verifyConditions(pluginConfig, context) {
export async function verifyConditions(pluginConfig, context) {
// Set default values for config
pluginConfig.podLint = defaultTo(pluginConfig.podLint, true);
pluginConfig.podLintArgs = defaultTo(pluginConfig.podLintArgs, '');
pluginConfig.podPushArgs = defaultTo(pluginConfig.podPushArgs, '');

const errors = verifyPluginConfig(pluginConfig);
const errors = []
errors.push(...await verifyPluginConfig(pluginConfig, context));

try {
// 1. Verify `pod` command exists
Expand All @@ -29,7 +30,7 @@ async function verifyConditions(pluginConfig, context) {
// 4. Verify `pod lib lint` is successful
await verifyPodLint(pluginConfig, context);
} catch (error) {
errors.push(...error);
errors.push(error);
}

if (errors.length > 0) {
Expand All @@ -39,17 +40,15 @@ async function verifyConditions(pluginConfig, context) {
// Verified = true;
}

async function prepare(pluginConfig, context) {
export async function prepare(pluginConfig, context) {
await preparePod(pluginConfig, context);
prepared = true;
}

async function publish(pluginConfig, context) {
export async function publish(pluginConfig, context) {
if (!prepared) {
await preparePod(pluginConfig, context);
}

return publishPod(pluginConfig, context);
}

module.exports = {verifyConditions, prepare, publish};
Loading

0 comments on commit a1dc5cd

Please sign in to comment.