Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

begin TypeScript conversion #17

Merged
merged 29 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9873d93
WIP: package.json - typescript conversion
ericcarraway Jun 2, 2021
35e5811
package.json: run `npx sort-package-json`
ericcarraway Jun 2, 2021
1769176
package.json - typescript conversion: bump deps
ericcarraway Jun 2, 2021
cc3ec31
WIP: typescript conversion - `git mv` js files to ts files in `/src`
ericcarraway Jun 2, 2021
c2612ac
extend .gitignore
ericcarraway Jun 2, 2021
204695a
GitHub Actions: add boilerplate main.yml & size.yml from `formium/tsdx`
ericcarraway Jun 2, 2021
1bf5a64
src/*.ts - WIP: typescript conversion
ericcarraway Jun 2, 2021
86b08a8
typescript conversion: remove `mocha` in preparation for `jest`
ericcarraway Jun 2, 2021
c73fa4c
typescript conversion (continued...)
ericcarraway Jun 2, 2021
5337374
add scripts/pre-publish.sh
ericcarraway Jun 2, 2021
4c24ebb
convert smoke tests in `tests/index.spec.js` from `mocha` to `jest`
ericcarraway Jun 2, 2021
77c3dce
disable `no-var-requires` in `examples/` folder
ericcarraway Jun 2, 2021
9d58539
.eslintrc: disable `@typescript-eslint/no-var-requires`
ericcarraway Jun 2, 2021
2be1cc5
scripts/lint.sh: add `examples/` & `tests/` folders
ericcarraway Jun 2, 2021
b2f23a4
add type definition to `paramsObj` for `createSlice`
ericcarraway Jun 2, 2021
9123497
add type definition to `paramsObj` for `createFolder`
ericcarraway Jun 2, 2021
1b8200f
flesh out parameter types, refactor names, add comments
ericcarraway Jun 2, 2021
7cd6ec8
workflows/main.yml: flip oder of "Build" & "Test"
ericcarraway Jun 2, 2021
6e53326
fix(lib/upload-file): import 'fs/promises' differently to support old…
ericcarraway Jun 2, 2021
9f6b438
debugging GitHub Actions - log our `node` & `npm` versions in `build.sh`
ericcarraway Jun 2, 2021
0afefda
debugging GitHub Actions workflow `size.yml` - andresz1/size-limit-ac…
ericcarraway Jun 2, 2021
2a205e3
add example for `getSyncpointsByRecordingId`
ericcarraway Jun 3, 2021
9ef399c
add example for `listSubfoldersByParentId`
ericcarraway Jun 3, 2021
fbe0fcb
examples: use current time when creating or renaming a folder
ericcarraway Jun 3, 2021
687a507
examples/list-slices.js - loop through the `arrayOfSlices` to log them
ericcarraway Jun 3, 2021
22d30d7
refine types - many IDs that are integers can be `number | string`
ericcarraway Jun 3, 2021
cd7ceb3
refine types - many IDs that are integers can be `number | string`
ericcarraway Jun 3, 2021
42db5bb
migrate husky from v4 to v6
ericcarraway Jun 3, 2021
3e0ecf8
skip `.github/workflows/size.yml` for now
ericcarraway Jun 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module.exports = {
env: {
mocha: true,
node: true,
},

extends: [
`eslint:recommended`,

`plugin:@typescript-eslint/eslint-recommended`,
`plugin:@typescript-eslint/recommended`,

// https://www.npmjs.com/package/eslint-config-airbnb-base
// This package provides Airbnb's base JS .eslintrc (without React plugins)
// as an extensible shared config.
Expand All @@ -15,12 +17,18 @@ module.exports = {
`@percuss.io/eslint-config-ericcarraway`,
],

parser: `@typescript-eslint/parser`,

plugins: [`@typescript-eslint`],

// don't continue to look for config files
// in ancestor directories
root: true,

// custom overrides
rules: {
'@typescript-eslint/no-var-requires': `off`,
'import/extensions': `off`,
'no-console': [
`error`,
{
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on: [push]
jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ["10.x", "12.x", "14.x"]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: npm run lint

- name: Build
run: npm run build

- name: Test
run: npm run test --ci --coverage --maxWorkers=2
21 changes: 21 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: size
on: [pull_request]
jobs:
size:
runs-on: ubuntu-latest

# skipping for now
if: ${{ false }}

env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v1

# https://github.com/andresz1/size-limit-action
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# build_script (optional custom npm script)
# skip_step (optionally skip 'install' or 'build')
# directory (optional custom working directory)
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
.env
.vscode
*.log
dist
node_modules
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint

npm run test
3 changes: 0 additions & 3 deletions .mocharc.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/create-folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { apiClient } = require(`./index.js`);
const main = async () => {
const paramsObj = {
// Required - The name of the folder.
name: `New Example Folder`,
name: `New Example Folder ${new Date().toLocaleTimeString()}`,

// Optional - Integer. The folder's parent ID.
// Use this if you want to nest a folder within another one.
Expand Down
10 changes: 10 additions & 0 deletions examples/get-syncpoints-by-recording-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// examples/get-syncpoints-by-recording-id.js

const { apiClient, handleError, handleSuccess } = require(`./index.js`);

const recordingId = `611136`;

apiClient
.getSyncpointsByRecordingId(recordingId)
.then(handleSuccess)
.catch(handleError);
2 changes: 1 addition & 1 deletion examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require(`dotenv`).config({ path: `../.env` });
const { SOUNDSLICE_APPLICATION_ID, SOUNDSLICE_PASSWORD } = process.env;

// instantiate the client
const apiClient = require(`../index.js`)({
const apiClient = require(`../dist/index.js`)({
SOUNDSLICE_APPLICATION_ID,
SOUNDSLICE_PASSWORD,
});
Expand Down
14 changes: 13 additions & 1 deletion examples/list-slices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

// https://www.soundslice.com/help/data-api/#listslices

const { apiClient, handleError, handleSuccess } = require(`./index.js`);
const { apiClient, handleError } = require(`./index.js`);

// retrieves metadata for all slices in your account
apiClient.listSlices().then(handleSuccess).catch(handleError);

function handleSuccess(res) {
const arrayOfSlices = res.data;

console.log(
`arrayOfSlices.length`,
arrayOfSlices.length.toLocaleString(),
`\n`,
);

arrayOfSlices.forEach((slice) => console.log(slice));
}

// returns an array of slices, each with the following shape:
//
// {
Expand Down
10 changes: 10 additions & 0 deletions examples/list-subfolders-by-parent-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// examples/list-subfolders-by-parent-id

const { apiClient, handleError, handleSuccess } = require(`./index.js`);

const parentId = `15303`;

apiClient
.listSubfoldersByParentId(parentId)
.then(handleSuccess)
.catch(handleError);
2 changes: 1 addition & 1 deletion examples/rename-folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const main = async () => {
folderId: `28882`,

// Required - The new name of the folder.
name: `This folder has been renamed`,
name: `This folder has been renamed ${new Date().toLocaleTimeString()}`,
};

let res;
Expand Down
204 changes: 0 additions & 204 deletions index.js

This file was deleted.

Loading