Merge branch 'release-3.1.0' into underscore/deprecate-underscore

This commit is contained in:
Harry Adel
2024-10-17 17:06:42 +03:00
committed by GitHub
16 changed files with 102 additions and 58 deletions

View File

@@ -13,7 +13,6 @@ Npm.depends({
Package.onTest(function (api) {
api.use('ecmascript');
api.use([
'underscore',
'tinytest',
'boilerplate-generator'
], 'server');

View File

@@ -1,6 +1,5 @@
import { parse, serialize } from 'parse5';
import { generateHTMLForArch } from './test-lib';
import { _ } from 'meteor/underscore';
Tinytest.addAsync(
"boilerplate-generator-tests - web.browser - basic output",
@@ -66,10 +65,6 @@ Tinytest.addAsync(
async function (test) {
const newHtml = await generateHTMLForArch("web.browser", false);
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
test.matches(newHtml, /foo="foobar"/);
test.matches(newHtml, /<link[^<>]*href="[^<>]*bootstrap[^<>]*">/);
test.matches(newHtml, /<script[^<>]*src="[^<>]*templating[^<>]*">/);

View File

@@ -1,6 +1,5 @@
import { parse, serialize } from 'parse5';
import { generateHTMLForArch } from './test-lib';
import { _ } from 'meteor/underscore';
Tinytest.addAsync(
"boilerplate-generator-tests - web.cordova - basic output",
@@ -60,9 +59,7 @@ Tinytest.addAsync(
async function (test) {
const newHtml = await generateHTMLForArch('web.cordova', false);
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
test.matches(newHtml, /<link[^<>]*href="[^<>]*bootstrap[^<>]*">/);
test.matches(newHtml, /<script[^<>]*src="[^<>]*templating[^<>]*">/);
test.matches(newHtml, /<script>var a/);

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Make HTTP calls to remote servers",
version: '3.0.0-beta300.7',
version: '3.0.0',
deprecated: 'Please use the fetch package'
});

View File

@@ -52,32 +52,32 @@ var ExpectationManager = function (test, onComplete) {
self.outstanding = 0;
};
_.extend(ExpectationManager.prototype, {
expect: function (/* arguments */) {
Object.assign(ExpectationManager.prototype, {
expect: function (...args) {
var self = this;
if (typeof arguments[0] === "function")
var expected = arguments[0];
if (typeof args[0] === "function")
var expected = args[0];
else
var expected = _.toArray(arguments);
var expected = args;
if (self.closed)
throw new Error("Too late to add more expectations to the test");
self.outstanding++;
return async function (/* arguments */) {
return async function (...args) {
if (self.dead)
return;
if (typeof expected === "function") {
try {
await expected.apply({}, arguments);
await expected.apply({}, args);
} catch (e) {
if (self.cancel())
self.test.exception(e);
}
} else {
self.test.equal(_.toArray(arguments), expected);
self.test.equal(args, expected);
}
self.outstanding--;
@@ -115,12 +115,12 @@ testAsyncMulti = function (name, funcs, { isOnly = false } = {}) {
const addFunction = isOnly ? Tinytest.onlyAsync : Tinytest.addAsync;
addFunction(name, function (test, onComplete) {
var remaining = _.clone(funcs);
var remaining = Object.assign({}, funcs);
var context = {};
var i = 0;
var runNext = function () {
var func = remaining.shift();
var func = Object.values(remaining).shift();
if (!func) {
delete test.extraDetails.asyncBlock;
onComplete();
@@ -142,7 +142,7 @@ testAsyncMulti = function (name, funcs, { isOnly = false } = {}) {
test.extraDetails.asyncBlock = i++;
new Promise(resolve => {
const result = func.apply(context, [test, _.bind(em.expect, em)]);
const result = func.apply(context, [test, em.expect.bind(em)]);
if (result && typeof result.then === "function") {
return result.then((r) => resolve(r))
}

View File

@@ -1,3 +1,6 @@
import isEmpty from 'lodash.isempty';
import isEqual from 'lodash.isequal';
// This file allows you to write tests that expect certain callbacks to be
// called in certain orders, or optionally in groups where the order does not
// matter. It can be set up in either a synchronous manner, so that each
@@ -21,9 +24,10 @@ var CallbackLogger = function (test, callbackNames) {
var self = this;
self._log = [];
self._test = test;
_.each(callbackNames, function (callbackName) {
self._yielded = false;
callbackNames.forEach(function (callbackName) {
self[callbackName] = function () {
var args = _.toArray(arguments);
var args = Array.from(arguments);
self._log.push({callback: callbackName, args: args});
};
});
@@ -32,7 +36,7 @@ var CallbackLogger = function (test, callbackNames) {
CallbackLogger.prototype.expectResult = async function (callbackName, args) {
var self = this;
await self._waitForLengthOrTimeout(1);
if (_.isEmpty(self._log)) {
if (isEmpty(self._log)) {
self._test.fail(["Expected callback " + callbackName + " got none"]);
return;
}
@@ -74,13 +78,13 @@ CallbackLogger.prototype.expectResultUnordered = async function (list) {
await self._waitForLengthOrTimeout(list.length);
list = _.clone(list); // shallow copy.
list = [...list]; // shallow copy.
var i = list.length;
while (i > 0) {
var found = false;
var dequeued = self._log.shift();
for (var j = 0; j < list.length; j++) {
if (_.isEqual(list[j], dequeued)) {
if (isEqual(list[j], dequeued)) {
list.splice(j, 1);
found = true;
break;
@@ -110,4 +114,4 @@ CallbackLogger.prototype.expectNoResult = async function (fn) {
await self._waitForLengthOrTimeout(0);
self._expectNoResultImpl();
};
};

View File

@@ -1,3 +1,5 @@
import isString from 'lodash.isstring';
// Establish a connection from the server to the server, and wait
// until the client side of the connection has received the session
// id. On success call `succeeded` with two arguments, the client
@@ -13,7 +15,7 @@ makeTestConnection = function (test, succeeded, failed) {
// Add incoming connections to `serverConns`.
var onConnectionHandle = Meteor.onConnection(function (serverConn) {
test.isTrue(_.isString(serverConn.id), "connection handle id exists and is a string");
test.isTrue(isString(serverConn.id), "connection handle id exists and is a string");
if (serverConns[serverConn.id]) {
test.fail("onConnection callback called multiple times for same session id");
failed();

View File

@@ -9,11 +9,11 @@ simulateEvent = function (node, event, args, options) {
if (document.createEvent) {
var e = document.createEvent("Event");
e.initEvent(event, bubbles, true);
_.extend(e, args);
Object.assign(e, args);
node.dispatchEvent(e);
} else {
var e = document.createEventObject();
_.extend(e, args);
Object.assign(e, args);
node.fireEvent("on" + event, e);
}
};

View File

@@ -3,10 +3,15 @@ Package.describe({
version: "2.0.1",
});
Npm.depends({
'lodash.isequal': '4.5.0',
'lodash.isempty': '4.4.0',
'lodash.isstring': '4.0.1'
});
Package.onUse(function (api) {
api.use([
"ecmascript",
"underscore",
"tracker",
"ejson",
"tinytest",
@@ -64,7 +69,7 @@ Package.onUse(function (api) {
Package.onTest(function (api) {
api.use("tinytest");
api.use(["test-helpers", "underscore"]);
api.use(["test-helpers"]);
api.addFiles("try_all_permutations_test.js", "client");
api.addFiles("seeded_random_test.js");
});

View File

@@ -39,7 +39,7 @@ try_all_permutations = function () {
var expand_next_set = function () {
if (current_set === args.length) {
_.each(chosen, function (f) { f(); });
chosen.forEach(function (f) { f(); });
} else {
var set = args[current_set];
if (typeof set === "function")

View File

@@ -61,7 +61,7 @@ Tinytest.add("test-helpers - try_all_permutations", function (test) {
var seen = {};
for (var i = 0; i < n; i++)
fs.push(_.bind(function (x) { seq += x + "_"; }, null, i));
fs.push(function (x) { seq += x + "_"; }.bind(null, i));
try_all_permutations(
function () {seq = "";},
fs,
@@ -75,7 +75,7 @@ Tinytest.add("test-helpers - try_all_permutations", function (test) {
var expected_count = 1;
for (var i = n; i >= 1; i--)
expected_count *= i;
test.equal(_.keys(seen).length, expected_count);
test.equal(Object.keys(seen).length, expected_count);
};
for (var i = 1; i <= 5; i++)

View File

@@ -294,6 +294,11 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
},
"lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g=="
},
"lru-cache": {
"version": "7.18.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
@@ -509,6 +514,11 @@
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
},
"undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",

View File

@@ -13,6 +13,7 @@ Npm.depends({
send: "1.1.0",
"stream-to-string": "1.2.1",
qs: "6.13.0",
'lodash.has': '4.5.2',
"useragent-ng": "2.4.3",
"tmp": "0.2.3",
});
@@ -31,14 +32,13 @@ Package.onUse(function (api) {
api.use("ecmascript");
api.use(
[
"logging",
"underscore",
"routepolicy",
"modern-browsers",
"boilerplate-generator",
"webapp-hashing",
"inter-process-messaging",
"callback-hook",
'logging',
'routepolicy',
'modern-browsers',
'boilerplate-generator',
'webapp-hashing',
'inter-process-messaging',
'callback-hook',
],
"server"
);
@@ -66,7 +66,6 @@ Package.onTest(function (api) {
"ecmascript",
"webapp",
"http",
"underscore",
"fetch",
"test-helpers",
]);

View File

@@ -19,6 +19,7 @@ import {
} from './socket_file.js';
import cluster from 'cluster';
import { execSync } from 'child_process';
import has from 'lodash.has';
var SHORT_SOCKET_TIMEOUT = 5 * 1000;
var LONG_SOCKET_TIMEOUT = 120 * 1000;
@@ -210,12 +211,12 @@ WebApp.categorizeRequest = function(req) {
var htmlAttributeHooks = [];
var getHtmlAttributes = function(request) {
var combinedAttributes = {};
_.each(htmlAttributeHooks || [], function(hook) {
(htmlAttributeHooks || []).forEach(function(hook) {
var attributes = hook(request);
if (attributes === null) return;
if (typeof attributes !== 'object')
throw Error('HTML attribute hook must return null or object');
_.extend(combinedAttributes, attributes);
Object.assign(combinedAttributes, attributes);
});
return combinedAttributes;
};
@@ -298,7 +299,7 @@ WebApp._timeoutAdjustmentRequestCallback = function(req, res) {
res.on('finish', function() {
res.setTimeout(SHORT_SOCKET_TIMEOUT);
});
_.each(finishListeners, function(l) {
Object.values(finishListeners).forEach(function(l) {
res.on('finish', l);
});
};
@@ -452,13 +453,14 @@ async function getBoilerplateAsync(request, arch) {
return true;
});
runtimeConfig.isUpdatedByArch[arch] = false;
const { dynamicHead, dynamicBody } = request;
const data = Object.assign(
{},
boilerplate.baseData,
{
htmlAttributes: getHtmlAttributes(request),
},
_.pick(request, 'dynamicHead', 'dynamicBody')
{ dynamicHead, dynamicBody }
);
let madeChanges = false;
@@ -542,9 +544,8 @@ WebAppInternals.generateBoilerplateInstance = function(
return pathJoin(archPath[arch], itemPath);
},
baseDataExtension: {
additionalStaticJs: _.map(additionalStaticJs || [], function(
contents,
pathname
additionalStaticJs: (Object.entries(additionalStaticJs) || []).map(function(
[pathname, contents]
) {
return {
pathname: pathname,
@@ -621,7 +622,7 @@ WebAppInternals.staticFilesMiddleware = async function(
};
if (
_.has(additionalStaticJs, pathname) &&
has(additionalStaticJs, pathname) &&
!WebAppInternals.inlineScriptsAllowed()
) {
serveStaticJs(additionalStaticJs[pathname]);
@@ -1363,7 +1364,7 @@ async function runWebAppServer() {
let warnedAboutConnectUsage = false;
// start up app
_.extend(WebApp, {
Object.assign(WebApp, {
connectHandlers: packageAndAppHandlers,
handlers: packageAndAppHandlers,
rawConnectHandlers: rawExpressHandlers,

View File

@@ -55,16 +55,15 @@ const asyncGet =
));
Tinytest.addAsync("webapp - content-type header", async function (test) {
const staticFiles = WebAppInternals.staticFilesByArch["web.browser"];
const staticFilesKeys = Object.keys(staticFiles);
const cssResource = _.find(
_.keys(staticFiles),
const cssResource = staticFilesKeys.find(
function (url) {
return staticFiles[url].type === "css";
}
);
const jsResource = _.find(
_.keys(staticFiles),
const jsResource = staticFilesKeys.find(
function (url) {
return staticFiles[url].type === "js";
}

View File

@@ -0,0 +1,33 @@
## v3.1.0, 2024-xx-xx
### Highlights
N/A
#### Breaking Changes
N/A
#### Internal API changes
N/A
#### Migration Steps
Please run the following command to update your project:
```bash
meteor update --release 3.1.0
```
#### Meteor Version Release
N/A
#### Special thanks to
N/A