Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
64 changes: 32 additions & 32 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,38 +124,38 @@ jobs:
retention-days: 1
if: ${{ github.event_name == 'pull_request' }}

# dangerbot:
# runs-on: ubuntu-latest
# if: github.repository == 'DefinitelyTyped/DefinitelyTyped' && github.event_name == 'pull_request'

# needs:
# - test

# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# - uses: ./.github/actions/setup-for-scripts

# - name: Get suggestions dir
# id: suggestions-dir
# run: echo "path=$(node ./scripts/get-suggestions-dir.js)" >> "$GITHUB_OUTPUT"

# - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
# with:
# path: ${{ steps.suggestions-dir.outputs.path }}
# merge-multiple: true

# - name: 'Run Danger'
# env:
# # See https://github.com/danger/danger-js/issues/1042
# DANGER_GITHUB_API_BASE_URL: 'https://api.github.com'

# # Danger failing (for example through rate-limiting) shouldn't fail the build
# run: |
# # Exposing this token is safe because the user of it has no other public repositories
# # and has no permission to modify this repository. See #62638 for the discussion.
# TOKEN='ghp_i5wtj1l2AbpFv3OU96w6R'
# TOKEN+='On3bHOkcV2AmVY6'
# DANGER_GITHUB_API_TOKEN=$TOKEN pnpm danger ci || $( exit 0 )
dangerbot:
runs-on: ubuntu-latest
if: github.repository == 'DefinitelyTyped/DefinitelyTyped' && github.event_name == 'pull_request'

needs:
- test

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./.github/actions/setup-for-scripts

- name: Get suggestions dir
id: suggestions-dir
run: echo "path=$(node ./scripts/get-suggestions-dir.js)" >> "$GITHUB_OUTPUT"

- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
path: ${{ steps.suggestions-dir.outputs.path }}
merge-multiple: true

- name: 'Run Danger'
env:
# See https://github.com/danger/danger-js/issues/1042
DANGER_GITHUB_API_BASE_URL: 'https://api.github.com'

# Danger failing (for example through rate-limiting) shouldn't fail the build
run: |
# Exposing this token is safe because the user of it has no other public repositories
# and has no permission to modify this repository. See #62638 for the discussion.
TOKEN='ghp_i5wtj1l2AbpFv3OU96w6R'
TOKEN+='On3bHOkcV2AmVY6'
DANGER_GITHUB_API_TOKEN=$TOKEN pnpm danger ci || $( exit 0 )

scripts:
runs-on: ubuntu-latest
Expand Down
10 changes: 5 additions & 5 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs = require("fs");
import os = require("os");
import path = require("path");
import cp = require("child_process");
import { mangleScopedPackage, suggestionsDir } from "@definitelytyped/utils";
import { danger, fail, markdown } from "danger";
import cp from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
const lines: string[] = [];
const missingProperty = /module exports a property named '(.+?)', which is missing/;

Expand Down Expand Up @@ -129,7 +129,7 @@ if (dprintErrors.length > 0) {
"## Formatting errors",
"",
codeBlock,
...dprintErrors.join("\n\n"),
dprintErrors.join("\n\n"),
codeBlock,
];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@definitelytyped/header-parser": "latest",
"@definitelytyped/typescript-versions": "latest",
"@definitelytyped/utils": "latest",
"danger": "^11.2.3",
"danger": "^13.0.5",
"dprint": "^0.49.0",
"eslint-plugin-jsdoc": "^44.2.7",
"husky": "^8.0.3",
Expand Down
25 changes: 25 additions & 0 deletions types/meteor/meteor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,31 @@ declare module 'meteor/meteor' {
* @param func The function to run
*/
function defer(func: Function): void;

/**
* Wrap a function so that it only runs in background in specified environments..
* @param func The function to wrap
* @param options An object with an `on` property that is an array of environment names: `"development"`, `"production"`, and/or `"test"`.
*/
function deferrable<T>(
func: () => T,
options: { on: Array<"development" | "production" | "test"> }
): T | void;

/**
* Wrap a function to run in the background in development (similar to Meteor.isDevelopment ? Meteor.defer(fn) : Meteor.startup(fn)).
* @param func The function to wrap
*/
function deferDev<T>(
func: () => T
): T | void;
/**
* Wrap a function to run in the background in production (similar to Meteor.isProduction ? Meteor.defer(fn) : Meteor.startup(fn)).
* @param func The function to wrap
*/
function deferProd<T>(
func: () => T
): T | void;
/** Timeout **/

/** utils **/
Expand Down
15 changes: 15 additions & 0 deletions types/meteor/test/meteor-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ namespace MeteorTests {
.aggregate([{ $group: { _id: null, names: { $addToSet: '$name' } } }])
.toArray()
.then();

Meteor.deferrable(
() => console.log('This is deferred until after startup.'),
{on: ['development', 'test']},
)

});
}

Expand Down Expand Up @@ -398,6 +404,7 @@ namespace MeteorTests {
if (Meteor.isServer) {
Logs.remove({});
Players.remove({ karma: { $lt: -2 } });
Meteor.defer(() => console.log('Old low-karma players removed from the Players collection.'));
}
});

Expand Down Expand Up @@ -1203,6 +1210,14 @@ namespace MeteorTests {
Rooms._dropIndex('indexName');
}

Meteor.deferDev(() => {
console.log('This is a development-only deferred function.');
});

Meteor.deferProd(() => {
console.log('This is a production-only deferred function.');
});

(async function() {
await Rooms.dropIndexAsync('indexName');
})();
Expand Down