Set dist/index as entrypoint

This commit is contained in:
Nick Alteen 2023-08-23 13:37:14 -04:00
parent 4ddc52349f
commit 0e82f80ee6
8 changed files with 4452 additions and 3351 deletions

2
.gitignore vendored
View File

@ -96,4 +96,4 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*
lib/**/*
dist/**/*

View File

@ -1,3 +1,3 @@
dist/
lib/
node_modules/
node_modules/
coverage/

View File

@ -1,29 +0,0 @@
import {wait} from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import {expect, test} from '@jest/globals'
test('throws invalid number', async () => {
const input = parseInt('foo', 10)
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
})
test('wait 500 ms', async () => {
const start = new Date()
await wait(500)
const end = new Date()
var delta = Math.abs(end.getTime() - start.getTime())
expect(delta).toBeGreaterThan(450)
})
// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['INPUT_MILLISECONDS'] = '500'
const np = process.execPath
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecFileSyncOptions = {
env: process.env
}
console.log(cp.execFileSync(np, [ip], options).toString())
})

View File

@ -1,11 +1,22 @@
# When creating your own action from this template, update this file with
# information about your action, such as the name, description, inputs, outputs,
# and any other relevant details.
name: 'Your name here'
description: 'Provide a description here'
author: 'Your name or organization here'
# Define your inputs here.
inputs:
milliseconds: # change this
milliseconds:
description: 'Your input description here'
required: true
description: 'input description here'
default: 'default value if applicable'
default: '1000'
# Define your outputs here.
outputs:
time:
description: 'Your output description here'
runs:
using: 'node16'
main: 'dist/index.js'
using: node16
main: dist/index.js

7629
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,83 @@
{
"name": "typescript-action",
"description": "GitHub Actions TypeScript template",
"version": "0.0.0",
"author": "",
"private": true,
"description": "TypeScript template action",
"main": "lib/main.js",
"scripts": {
"build": "tsc",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
},
"homepage": "https://github.com/actions/typescript-action",
"repository": {
"type": "git",
"url": "git+https://github.com/actions/typescript-action.git"
},
"bugs": {
"url": "https://github.com/actions/typescript-action/issues"
},
"keywords": [
"actions",
"node",
"setup"
],
"author": "",
"main": "dist/index.js",
"scripts": {
"bundle": "npm run format:write && npm run package",
"ci-test": "jest",
"format:write": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'",
"lint": "eslint -c ./.github/linters/.eslintrc.yml src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "(jest && make-coverage-badge --output-path ./badges/coverage.svg) || make-coverage-badge --output-path ./badges/coverage.svg",
"all": "npm run format:write && npm run lint && npm run test && npm run package"
},
"license": "MIT",
"jest": {
"preset": "ts-jest",
"verbose": true,
"clearMocks": true,
"testEnvironment": "node",
"moduleFileExtensions": [
"js",
"ts"
],
"testMatch": [
"**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/"
],
"transform": {
"^.+\\.ts$": "ts-jest"
},
"coverageReporters": [
"json-summary",
"text",
"lcov"
],
"collectCoverage": true,
"collectCoverageFrom": [
"./src/**"
]
},
"dependencies": {
"@actions/core": "^1.10.0"
},
"devDependencies": {
"@types/node": "^18.16.3",
"@typescript-eslint/parser": "^5.59.2",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.3",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.39.0",
"eslint-plugin-github": "^4.7.0",
"eslint-plugin-jest": "^27.2.1",
"jest": "^29.5.0",
"eslint": "^8.47.0",
"eslint-plugin-github": "^4.9.2",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-jsonc": "^2.9.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.3",
"js-yaml": "^4.1.0",
"prettier": "^2.8.8",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
"make-coverage-badge": "^1.2.0",
"prettier": "^3.0.2",
"prettier-eslint": "^15.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
}
}

View File

@ -1,19 +0,0 @@
import * as core from '@actions/core'
import {wait} from './wait'
async function run(): Promise<void> {
try {
const ms: string = core.getInput('milliseconds')
core.debug(`Waiting ${ms} milliseconds ...`) // debug is only output if you set the secret `ACTIONS_STEP_DEBUG` to true
core.debug(new Date().toTimeString())
await wait(parseInt(ms, 10))
core.debug(new Date().toTimeString())
core.setOutput('time', new Date().toTimeString())
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}
}
run()

View File

@ -1,12 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"target": "es6",
"module": "commonjs",
"outDir": "./dist",
"rootDirs": ["src", "__tests__"],
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "**/*.test.ts"]
"exclude": ["node_modules"]
}