Get tests passing again
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
import { renderToString, renderToStaticMarkup } from 'react-dom/server';
|
||||
import semver from 'semver';
|
||||
|
||||
import AutoIndexApp from '../client/autoIndex/App';
|
||||
import AutoIndexApp from '../client/autoIndex/App.js';
|
||||
|
||||
import createElement from './utils/createElement';
|
||||
import createHTML from './utils/createHTML';
|
||||
import createScript from './utils/createScript';
|
||||
import getEntryPoint from './utils/getEntryPoint';
|
||||
import getGlobalScripts from './utils/getGlobalScripts';
|
||||
import MainTemplate from './utils/MainTemplate';
|
||||
import MainTemplate from './utils/MainTemplate.js';
|
||||
import createElement from './utils/createElement.js';
|
||||
import createHTML from './utils/createHTML.js';
|
||||
import createScript from './utils/createScript.js';
|
||||
import getEntryPoint from './utils/getEntryPoint.js';
|
||||
import getGlobalScripts from './utils/getGlobalScripts.js';
|
||||
|
||||
const doctype = '<!DOCTYPE html>';
|
||||
const globalURLs =
|
||||
|
@ -1,7 +1,7 @@
|
||||
import serveAutoIndexPage from './serveAutoIndexPage';
|
||||
import serveMetadata from './serveMetadata';
|
||||
import serveModule from './serveModule';
|
||||
import serveStaticFile from './serveStaticFile';
|
||||
import serveAutoIndexPage from './serveAutoIndexPage.js';
|
||||
import serveMetadata from './serveMetadata.js';
|
||||
import serveModule from './serveModule.js';
|
||||
import serveStaticFile from './serveStaticFile.js';
|
||||
|
||||
/**
|
||||
* Send the file, JSON metadata, or HTML directory listing.
|
||||
|
@ -1,8 +1,8 @@
|
||||
import etag from 'etag';
|
||||
import cheerio from 'cheerio';
|
||||
|
||||
import getContentTypeHeader from '../utils/getContentTypeHeader';
|
||||
import rewriteBareModuleIdentifiers from '../utils/rewriteBareModuleIdentifiers';
|
||||
import getContentTypeHeader from '../utils/getContentTypeHeader.js';
|
||||
import rewriteBareModuleIdentifiers from '../utils/rewriteBareModuleIdentifiers.js';
|
||||
|
||||
export default function serveHTMLModule(req, res) {
|
||||
try {
|
||||
@ -40,9 +40,7 @@ export default function serveHTMLModule(req, res) {
|
||||
.status(500)
|
||||
.type('text')
|
||||
.send(
|
||||
`Cannot generate module for ${req.packageSpec}${
|
||||
req.filename
|
||||
}\n\n${debugInfo}`
|
||||
`Cannot generate module for ${req.packageSpec}${req.filename}\n\n${debugInfo}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import etag from 'etag';
|
||||
|
||||
import getContentTypeHeader from '../utils/getContentTypeHeader';
|
||||
import rewriteBareModuleIdentifiers from '../utils/rewriteBareModuleIdentifiers';
|
||||
import getContentTypeHeader from '../utils/getContentTypeHeader.js';
|
||||
import rewriteBareModuleIdentifiers from '../utils/rewriteBareModuleIdentifiers.js';
|
||||
|
||||
export default function serveJavaScriptModule(req, res) {
|
||||
try {
|
||||
@ -34,9 +34,7 @@ export default function serveJavaScriptModule(req, res) {
|
||||
.status(500)
|
||||
.type('text')
|
||||
.send(
|
||||
`Cannot generate module for ${req.packageSpec}${
|
||||
req.filename
|
||||
}\n\n${debugInfo}`
|
||||
`Cannot generate module for ${req.packageSpec}${req.filename}\n\n${debugInfo}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { renderToString, renderToStaticMarkup } from 'react-dom/server';
|
||||
|
||||
import MainApp from '../client/main/App';
|
||||
import MainApp from '../client/main/App.js';
|
||||
|
||||
import createElement from './utils/createElement';
|
||||
import createHTML from './utils/createHTML';
|
||||
import createScript from './utils/createScript';
|
||||
import getEntryPoint from './utils/getEntryPoint';
|
||||
import getGlobalScripts from './utils/getGlobalScripts';
|
||||
import MainTemplate from './utils/MainTemplate';
|
||||
import MainTemplate from './utils/MainTemplate.js';
|
||||
import createElement from './utils/createElement.js';
|
||||
import createHTML from './utils/createHTML.js';
|
||||
import createScript from './utils/createScript.js';
|
||||
import getEntryPoint from './utils/getEntryPoint.js';
|
||||
import getGlobalScripts from './utils/getGlobalScripts.js';
|
||||
|
||||
const doctype = '<!DOCTYPE html>';
|
||||
const globalURLs =
|
||||
|
@ -1,6 +1,6 @@
|
||||
import path from 'path';
|
||||
|
||||
import addLeadingSlash from '../utils/addLeadingSlash';
|
||||
import addLeadingSlash from '../utils/addLeadingSlash.js';
|
||||
|
||||
function getMatchingEntries(entry, entries) {
|
||||
const dirname = entry.name || '.';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import serveHTMLModule from './serveHTMLModule';
|
||||
import serveJavaScriptModule from './serveJavaScriptModule';
|
||||
import serveHTMLModule from './serveHTMLModule.js';
|
||||
import serveJavaScriptModule from './serveJavaScriptModule.js';
|
||||
|
||||
export default function serveModule(req, res) {
|
||||
if (req.entry.contentType === 'application/javascript') {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import etag from 'etag';
|
||||
|
||||
import getContentTypeHeader from '../utils/getContentTypeHeader';
|
||||
import getContentTypeHeader from '../utils/getContentTypeHeader.js';
|
||||
|
||||
export default function serveStaticFile(req, res) {
|
||||
const tags = ['file'];
|
||||
|
@ -1,8 +1,8 @@
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import e from './createElement';
|
||||
import h from './createHTML';
|
||||
import x from './createScript';
|
||||
import e from './createElement.js';
|
||||
import h from './createHTML.js';
|
||||
import x from './createScript.js';
|
||||
|
||||
const promiseShim =
|
||||
'window.Promise || document.write(\'\\x3Cscript src="/es6-promise@4.2.5/dist/es6-promise.min.js">\\x3C/script>\\x3Cscript>ES6Promise.polyfill()\\x3C/script>\')';
|
||||
@ -11,12 +11,12 @@ const fetchShim =
|
||||
'window.fetch || document.write(\'\\x3Cscript src="/whatwg-fetch@3.0.0/dist/fetch.umd.js">\\x3C/script>\')';
|
||||
|
||||
export default function MainTemplate({
|
||||
title,
|
||||
description,
|
||||
favicon,
|
||||
title = 'UNPKG',
|
||||
description = 'The CDN for everything on npm',
|
||||
favicon = '/favicon.ico',
|
||||
data,
|
||||
content,
|
||||
elements
|
||||
content = h(''),
|
||||
elements = []
|
||||
}) {
|
||||
return e(
|
||||
'html',
|
||||
@ -47,14 +47,6 @@ export default function MainTemplate({
|
||||
);
|
||||
}
|
||||
|
||||
MainTemplate.defaultProps = {
|
||||
title: 'UNPKG',
|
||||
description: 'The CDN for everything on npm',
|
||||
favicon: '/favicon.ico',
|
||||
content: h(''),
|
||||
elements: []
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const htmlType = PropTypes.shape({
|
||||
__html: PropTypes.string
|
||||
|
@ -1,16 +1,18 @@
|
||||
import fetch from 'isomorphic-fetch';
|
||||
import invariant from 'invariant';
|
||||
|
||||
const cloudflareURL = 'https://api.cloudflare.com/client/v4';
|
||||
const cloudflareEmail = process.env.CLOUDFLARE_EMAIL;
|
||||
const cloudflareKey = process.env.CLOUDFLARE_KEY;
|
||||
|
||||
invariant(
|
||||
cloudflareEmail,
|
||||
'Missing the $CLOUDFLARE_EMAIL environment variable'
|
||||
);
|
||||
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
||||
if (!cloudflareEmail) {
|
||||
throw new Error('Missing the $CLOUDFLARE_EMAIL environment variable');
|
||||
}
|
||||
|
||||
invariant(cloudflareKey, 'Missing the $CLOUDFLARE_KEY environment variable');
|
||||
if (!cloudflareKey) {
|
||||
throw new Error('Missing the $CLOUDFLARE_KEY environment variable');
|
||||
}
|
||||
}
|
||||
|
||||
function get(path, headers) {
|
||||
return fetch(`${cloudflareURL}${path}`, {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import createElement from './createElement';
|
||||
import createHTML from './createHTML';
|
||||
import createElement from './createElement.js';
|
||||
import createHTML from './createHTML.js';
|
||||
|
||||
export default function createScript(script) {
|
||||
return createElement('script', {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Virtual module id; see rollup.config.js
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import entryManifest from 'entry-manifest';
|
||||
|
||||
export default function getEntryPoint(name, format) {
|
||||
|
@ -1,10 +1,13 @@
|
||||
import invariant from 'invariant';
|
||||
|
||||
import createElement from './createElement';
|
||||
import createElement from './createElement.js';
|
||||
|
||||
export default function getGlobalScripts(entryPoint, globalURLs) {
|
||||
return entryPoint.globalImports.map(id => {
|
||||
invariant(globalURLs[id], 'Missing global URL for id "%s"', id);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!globalURLs[id]) {
|
||||
throw new Error('Missing global URL for id "%s"', id);
|
||||
}
|
||||
}
|
||||
|
||||
return createElement('script', { src: globalURLs[id] });
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as cloudflare from './cloudflare.js';
|
||||
import { getZones, getZoneAnalyticsDashboard } from './cloudflare.js';
|
||||
|
||||
function extractPublicInfo(data) {
|
||||
return {
|
||||
@ -28,12 +28,8 @@ function extractPublicInfo(data) {
|
||||
const DomainNames = ['unpkg.com', 'npmcdn.com'];
|
||||
|
||||
export default async function getStats(since, until) {
|
||||
const zones = await cloudflare.getZones(DomainNames);
|
||||
const dashboard = await cloudflare.getZoneAnalyticsDashboard(
|
||||
zones,
|
||||
since,
|
||||
until
|
||||
);
|
||||
const zones = await getZones(DomainNames);
|
||||
const dashboard = await getZoneAnalyticsDashboard(zones, since, until);
|
||||
|
||||
return {
|
||||
timeseries: dashboard.timeseries.map(extractPublicInfo),
|
||||
|
Reference in New Issue
Block a user