tungsten 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-complete +1 -0
- package/dist/Components.d.ts +2 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +10 -1
- package/dist/DomRegion.js +1 -1
- package/dist/Framework.d.ts +2 -0
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +68 -57
- package/dist/FrameworkConfig.d.ts +6 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts +2 -0
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +10 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +18 -1
- package/dist/Instance/InstanceConfig.d.ts +1 -0
- package/dist/Instance/InstanceConfig.d.ts.map +1 -1
- package/dist/PopMessage.type.d.ts +6 -0
- package/dist/PopMessage.type.d.ts.map +1 -0
- package/dist/PopMessage.type.js +1 -0
- package/dist/Servers/DevServer.d.ts +4 -0
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +116 -13
- package/dist/Servers/MatchedRouteInfo.d.ts +1 -1
- package/dist/Servers/MatchedRouteInfo.d.ts.map +1 -1
- package/dist/Servers/ProdServer.d.ts +1 -0
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +79 -5
- package/dist/Servers/devErrorPageAutoRetry.d.ts +4 -0
- package/dist/Servers/devErrorPageAutoRetry.d.ts.map +1 -0
- package/dist/Servers/devErrorPageAutoRetry.js +26 -0
- package/dist/Servers/hono/DevServerHono.js +25 -29
- package/dist/Servers/hono/ProdServerHono.js +49 -142
- package/dist/Servers/hono/TungstenServerHono.d.ts +1 -1
- package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
- package/dist/Servers/hono/TungstenServerHono.js +12 -29
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +10 -6
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +0 -3
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -1
- package/dist/Servers/tungstenCorePrivateEnvSchema.js +3 -3
- package/dist/Servers/tungstenCorePublicEnvSchema.d.ts +8 -0
- package/dist/Servers/tungstenCorePublicEnvSchema.d.ts.map +1 -0
- package/dist/Servers/tungstenCorePublicEnvSchema.js +14 -0
- package/dist/Store/InternalStoreSchema.d.ts +2 -0
- package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
- package/dist/Store/InternalStoreSchema.js +1 -0
- package/dist/api/Request.d.ts +1 -1
- package/dist/api/Request.d.ts.map +1 -1
- package/dist/api/Response.d.ts +1 -1
- package/dist/api/Response.d.ts.map +1 -1
- package/dist/api/getExport.d.ts.map +1 -1
- package/dist/api/getExport.js +2 -1
- package/dist/babelPlugins/BabelAddDevCacheBust.d.ts +11 -0
- package/dist/babelPlugins/BabelAddDevCacheBust.d.ts.map +1 -0
- package/dist/babelPlugins/BabelAddDevCacheBust.js +68 -0
- package/dist/babelPlugins/BabelTypes.d.ts +2 -2
- package/dist/babelPlugins/BabelTypes.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTypes.js +0 -1
- package/dist/bin/commands/build.d.ts.map +1 -1
- package/dist/bin/commands/build.js +3 -0
- package/dist/bin/commands/dev.d.ts.map +1 -1
- package/dist/bin/commands/dev.js +16 -3
- package/dist/bin/commands/devmon.d.ts +2 -0
- package/dist/bin/commands/devmon.d.ts.map +1 -0
- package/dist/bin/commands/devmon.js +66 -0
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +6 -0
- package/dist/booleanAttributeValue.d.ts +21 -0
- package/dist/booleanAttributeValue.d.ts.map +1 -0
- package/dist/booleanAttributeValue.js +23 -0
- package/dist/build/compileJavascript.js +1 -1
- package/dist/build/compileUserApp.d.ts +2 -1
- package/dist/build/compileUserApp.d.ts.map +1 -1
- package/dist/build/compileUserApp.js +10 -9
- package/dist/build/createInstanceConfigFile.js +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +6 -1
- package/dist/compat/types.d.ts +1 -1
- package/dist/compat/types.d.ts.map +1 -1
- package/dist/components/PopMessages.d.ts +12 -0
- package/dist/components/PopMessages.d.ts.map +1 -0
- package/dist/components/PopMessages.js +45 -0
- package/dist/defaultConfig.d.ts +3 -0
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +4 -1
- package/dist/env/Interfaces.d.ts +2 -1
- package/dist/env/Interfaces.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.d.ts +1 -1
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.js +2 -1
- package/dist/env/publicEnv.d.ts.map +1 -1
- package/dist/env/publicEnv.js +4 -1
- package/dist/frameworkConfigSchema.d.ts +4 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +2 -1
- package/dist/getComponent.d.ts.map +1 -1
- package/dist/getComponent.js +2 -1
- package/dist/getRoutes.d.ts.map +1 -1
- package/dist/getRoutes.js +2 -1
- package/dist/hmr/applyHmrModule.d.ts +11 -0
- package/dist/hmr/applyHmrModule.d.ts.map +1 -0
- package/dist/hmr/applyHmrModule.js +78 -0
- package/dist/hmr/componentIdentity.d.ts +9 -0
- package/dist/hmr/componentIdentity.d.ts.map +1 -0
- package/dist/hmr/componentIdentity.js +17 -0
- package/dist/hmr/instanceRegistry.d.ts +4 -0
- package/dist/hmr/instanceRegistry.d.ts.map +1 -0
- package/dist/hmr/instanceRegistry.js +6 -0
- package/dist/hmr/liveReloadHub.d.ts +10 -0
- package/dist/hmr/liveReloadHub.d.ts.map +1 -0
- package/dist/{dev → hmr}/liveReloadHub.js +8 -2
- package/dist/hmr/refreshStylesheets.d.ts +2 -0
- package/dist/hmr/refreshStylesheets.d.ts.map +1 -0
- package/dist/hmr/refreshStylesheets.js +26 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useInstance.d.ts +3 -0
- package/dist/hooks/useInstance.d.ts.map +1 -0
- package/dist/hooks/useInstance.js +4 -0
- package/dist/hydrate/hydrate.d.ts +10 -0
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +81 -19
- package/dist/hydrate/reconcileHydratedAttributes.d.ts.map +1 -1
- package/dist/hydrate/reconcileHydratedAttributes.js +14 -5
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts +7 -0
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -0
- package/dist/hydrate/renderHydrationMismatchBanner.js +69 -0
- package/dist/importDevModuleWithRetry.d.ts +3 -0
- package/dist/importDevModuleWithRetry.d.ts.map +1 -0
- package/dist/importDevModuleWithRetry.js +46 -0
- package/dist/indexInner.d.ts +8 -0
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +7 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.js +2 -1
- package/dist/pop.d.ts +10 -0
- package/dist/pop.d.ts.map +1 -0
- package/dist/pop.js +49 -0
- package/dist/rawHtml/filterContentNode.d.ts +20 -0
- package/dist/rawHtml/filterContentNode.d.ts.map +1 -0
- package/dist/rawHtml/filterContentNode.js +96 -0
- package/dist/rawHtml/parseHtml.d.ts +14 -0
- package/dist/rawHtml/parseHtml.d.ts.map +1 -1
- package/dist/rawHtml/parseHtml.js +4 -4
- package/dist/rawHtml/sanitizeHtml.d.ts +17 -0
- package/dist/rawHtml/sanitizeHtml.d.ts.map +1 -0
- package/dist/rawHtml/sanitizeHtml.js +19 -0
- package/dist/render/HeadData.d.ts +2 -0
- package/dist/render/HeadData.d.ts.map +1 -1
- package/dist/render/contentNodeToHtml.d.ts +18 -0
- package/dist/render/contentNodeToHtml.d.ts.map +1 -0
- package/dist/render/contentNodeToHtml.js +66 -0
- package/dist/render/contentToHtml.d.ts.map +1 -1
- package/dist/render/contentToHtml.js +3 -1
- package/dist/render/processHead.d.ts.map +1 -1
- package/dist/render/processHead.js +53 -6
- package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
- package/dist/render/renderingTreeToHtml.js +8 -1
- package/dist/routing/ErrorRouteType.d.ts +6 -0
- package/dist/routing/ErrorRouteType.d.ts.map +1 -0
- package/dist/routing/ErrorRouteType.js +1 -0
- package/dist/routing/RouteTypes.d.ts +2 -1
- package/dist/routing/RouteTypes.d.ts.map +1 -1
- package/dist/routing/Routes.d.ts +5 -0
- package/dist/routing/Routes.d.ts.map +1 -1
- package/dist/routing/TungstenErrorInfo.d.ts +6 -0
- package/dist/routing/TungstenErrorInfo.d.ts.map +1 -0
- package/dist/routing/TungstenErrorInfo.js +6 -0
- package/dist/style/styleContentSxy.js +21 -0
- package/dist/testing/hydrateTestApp.d.ts +38 -0
- package/dist/testing/hydrateTestApp.d.ts.map +1 -0
- package/dist/testing/hydrateTestApp.js +242 -0
- package/dist/testing/index.d.ts +4 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +16 -2
- package/dist/timeProfiler.d.ts +6 -0
- package/dist/timeProfiler.d.ts.map +1 -0
- package/dist/timeProfiler.js +31 -0
- package/dist/update/integrateUpdateVdom.d.ts +16 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +116 -7
- package/dist/warnOnFrameworkChange.d.ts +2 -0
- package/dist/warnOnFrameworkChange.d.ts.map +1 -0
- package/dist/warnOnFrameworkChange.js +27 -0
- package/package.json +18 -16
- package/dist/Instance/gotoRedirect.sxyt.d.ts +0 -2
- package/dist/Instance/gotoRedirect.sxyt.d.ts.map +0 -1
- package/dist/Instance/gotoRedirect.sxyt.js +0 -148
- package/dist/Instance/runTrackedWork.sxyt.d.ts +0 -2
- package/dist/Instance/runTrackedWork.sxyt.d.ts.map +0 -1
- package/dist/Instance/runTrackedWork.sxyt.js +0 -35
- package/dist/_client/cjsHelpers.sxyt.d.ts +0 -2
- package/dist/_client/cjsHelpers.sxyt.d.ts.map +0 -1
- package/dist/_client/cjsHelpers.sxyt.js +0 -45
- package/dist/auth/passwordHashing.sxyt.d.ts +0 -2
- package/dist/auth/passwordHashing.sxyt.d.ts.map +0 -1
- package/dist/auth/passwordHashing.sxyt.js +0 -46
- package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts +0 -2
- package/dist/auth/ref/checkPasswordResetToken.sxyt.d.ts.map +0 -1
- package/dist/auth/ref/checkPasswordResetToken.sxyt.js +0 -40
- package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts +0 -2
- package/dist/auth/ref/createPasswordResetToken.sxyt.d.ts.map +0 -1
- package/dist/auth/ref/createPasswordResetToken.sxyt.js +0 -10
- package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts +0 -2
- package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.d.ts.map +0 -1
- package/dist/babelPlugins/fixImportsInSassErrorMessage.sxyt.js +0 -108
- package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts +0 -2
- package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.d.ts.map +0 -1
- package/dist/babelPlugins/transformPackageImports/resolveBareImport.sxyt.js +0 -104
- package/dist/bin/commands/compile.sxyt.d.ts +0 -2
- package/dist/bin/commands/compile.sxyt.d.ts.map +0 -1
- package/dist/bin/commands/compile.sxyt.js +0 -255
- package/dist/build/modifySassImports.sxyt.d.ts +0 -2
- package/dist/build/modifySassImports.sxyt.d.ts.map +0 -1
- package/dist/build/modifySassImports.sxyt.js +0 -55
- package/dist/build/sassImportParser.sxyt.d.ts +0 -2
- package/dist/build/sassImportParser.sxyt.d.ts.map +0 -1
- package/dist/build/sassImportParser.sxyt.js +0 -110
- package/dist/build/scssImportParserChatgpt.sxyt.d.ts +0 -2
- package/dist/build/scssImportParserChatgpt.sxyt.d.ts.map +0 -1
- package/dist/build/scssImportParserChatgpt.sxyt.js +0 -120
- package/dist/clone.sxyt.d.ts +0 -2
- package/dist/clone.sxyt.d.ts.map +0 -1
- package/dist/clone.sxyt.js +0 -24
- package/dist/componentProxyHandlers.sxyt.d.ts +0 -2
- package/dist/componentProxyHandlers.sxyt.d.ts.map +0 -1
- package/dist/componentProxyHandlers.sxyt.js +0 -130
- package/dist/components/RawHtml.sxyt.d.ts +0 -2
- package/dist/components/RawHtml.sxyt.d.ts.map +0 -1
- package/dist/components/RawHtml.sxyt.js +0 -104
- package/dist/components/bindable/BindableSelect.sxyt.d.ts +0 -2
- package/dist/components/bindable/BindableSelect.sxyt.d.ts.map +0 -1
- package/dist/components/bindable/BindableSelect.sxyt.js +0 -186
- package/dist/dev/liveReloadHub.d.ts +0 -6
- package/dist/dev/liveReloadHub.d.ts.map +0 -1
- package/dist/env/injectEnv.sxyt.d.ts +0 -2
- package/dist/env/injectEnv.sxyt.d.ts.map +0 -1
- package/dist/env/injectEnv.sxyt.js +0 -20
- package/dist/env/parseEnv.sxyt.d.ts +0 -2
- package/dist/env/parseEnv.sxyt.d.ts.map +0 -1
- package/dist/env/parseEnv.sxyt.js +0 -11
- package/dist/findProjectDir.sxyt.d.ts +0 -2
- package/dist/findProjectDir.sxyt.d.ts.map +0 -1
- package/dist/findProjectDir.sxyt.js +0 -82
- package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts +0 -2
- package/dist/hydrate/reconcileHydratedAttributes.sxyt.d.ts.map +0 -1
- package/dist/hydrate/reconcileHydratedAttributes.sxyt.js +0 -173
- package/dist/innerHtmlFromProps.sxyt.d.ts +0 -2
- package/dist/innerHtmlFromProps.sxyt.d.ts.map +0 -1
- package/dist/innerHtmlFromProps.sxyt.js +0 -99
- package/dist/postcssPlugins/parseSelectors.sxyt.d.ts +0 -2
- package/dist/postcssPlugins/parseSelectors.sxyt.d.ts.map +0 -1
- package/dist/postcssPlugins/parseSelectors.sxyt.js +0 -62
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts +0 -2
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.d.ts.map +0 -1
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +0 -155
- package/dist/rawHtml/parseHtml.sxyt.d.ts +0 -2
- package/dist/rawHtml/parseHtml.sxyt.d.ts.map +0 -1
- package/dist/rawHtml/parseHtml.sxyt.js +0 -239
- package/dist/render/getFunctionBodyAsString.sxyt.d.ts +0 -2
- package/dist/render/getFunctionBodyAsString.sxyt.d.ts.map +0 -1
- package/dist/render/getFunctionBodyAsString.sxyt.js +0 -37
- package/dist/render/processProps.sxyt.d.ts +0 -2
- package/dist/render/processProps.sxyt.d.ts.map +0 -1
- package/dist/render/processProps.sxyt.js +0 -90
- package/dist/routing/compareRequestToRegex.sxyt.d.ts +0 -2
- package/dist/routing/compareRequestToRegex.sxyt.d.ts.map +0 -1
- package/dist/routing/compareRequestToRegex.sxyt.js +0 -65
- package/dist/routing/getPathPriority.sxyt.d.ts +0 -2
- package/dist/routing/getPathPriority.sxyt.d.ts.map +0 -1
- package/dist/routing/getPathPriority.sxyt.js +0 -24
- package/dist/routing/matchPath.sxyt.d.ts +0 -2
- package/dist/routing/matchPath.sxyt.d.ts.map +0 -1
- package/dist/routing/matchPath.sxyt.js +0 -41
- package/dist/routing/patternToRegex.sxyt.d.ts +0 -2
- package/dist/routing/patternToRegex.sxyt.d.ts.map +0 -1
- package/dist/routing/patternToRegex.sxyt.js +0 -69
- package/dist/routing/splitRequest.sxyt.d.ts +0 -2
- package/dist/routing/splitRequest.sxyt.d.ts.map +0 -1
- package/dist/routing/splitRequest.sxyt.js +0 -47
- package/dist/style/jssToCss.sxyt.d.ts +0 -2
- package/dist/style/jssToCss.sxyt.d.ts.map +0 -1
- package/dist/style/jssToCss.sxyt.js +0 -17
- package/dist/testing/createTestApp.sxyt.d.ts +0 -2
- package/dist/testing/createTestApp.sxyt.d.ts.map +0 -1
- package/dist/testing/createTestApp.sxyt.js +0 -470
- package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts +0 -2
- package/dist/testing/ensureTestEnvLoaded.sxyt.d.ts.map +0 -1
- package/dist/testing/ensureTestEnvLoaded.sxyt.js +0 -20
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe } from 'sxy-test-runner';
|
|
3
|
-
import { mkdtemp, rm, writeFile } from 'fs/promises';
|
|
4
|
-
import { tmpdir } from 'os';
|
|
5
|
-
import { join } from 'path';
|
|
6
|
-
import { pathToFileURL } from 'url';
|
|
7
|
-
// cjsHelpers is browser code - it installs a `process` shim and a window global as soon as
|
|
8
|
-
// it is imported. Stub the window it expects and put node's own process back afterwards.
|
|
9
|
-
const nodeProcess = Reflect.get(globalThis, 'process');
|
|
10
|
-
Reflect.set(globalThis, 'window', {});
|
|
11
|
-
const {
|
|
12
|
-
loadDeps
|
|
13
|
-
} = await import("./cjsHelpers.js");
|
|
14
|
-
Reflect.set(globalThis, 'process', nodeProcess);
|
|
15
|
-
// a converted CJS module exports its factory as the default and its dependencies as `deps`
|
|
16
|
-
function moduleSource(deps) {
|
|
17
|
-
return `export const deps = ${JSON.stringify(deps)}\n` + 'export default function (module) { module.exports = {} }\n';
|
|
18
|
-
}
|
|
19
|
-
describe('_client/cjsHelpers loadDeps()', ({
|
|
20
|
-
it
|
|
21
|
-
}) => {
|
|
22
|
-
it(`loads a dependency cycle instead of hanging`, async () => {
|
|
23
|
-
const dir = await mkdtemp(join(tmpdir(), 'tungsten-load-deps-'));
|
|
24
|
-
try {
|
|
25
|
-
// .mjs so that node does not have to guess the module type of a file in a
|
|
26
|
-
// temp dir with no package.json
|
|
27
|
-
const a = pathToFileURL(join(dir, 'a.mjs')).href;
|
|
28
|
-
const b = pathToFileURL(join(dir, 'b.mjs')).href;
|
|
29
|
-
const c = pathToFileURL(join(dir, 'c.mjs')).href;
|
|
30
|
-
// a <-> b is circular, and both reach c
|
|
31
|
-
await writeFile(join(dir, 'a.mjs'), moduleSource([b, c]));
|
|
32
|
-
await writeFile(join(dir, 'b.mjs'), moduleSource([a, c]));
|
|
33
|
-
await writeFile(join(dir, 'c.mjs'), moduleSource([]));
|
|
34
|
-
const timeout = new Promise(resolve => setTimeout(() => resolve('timed out'), 5000).unref());
|
|
35
|
-
const loaded = await Promise.race([loadDeps([a]), timeout]);
|
|
36
|
-
expect(loaded).not.to.equal('timed out');
|
|
37
|
-
expect(Object.keys(loaded).sort()).to.deep.equal([a, b, c].sort());
|
|
38
|
-
} finally {
|
|
39
|
-
await rm(dir, {
|
|
40
|
-
recursive: true,
|
|
41
|
-
force: true
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"passwordHashing.sxyt.d.ts","sourceRoot":"","sources":["../../src/auth/passwordHashing.sxyt.ts"],"names":[],"mappings":""}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe } from 'sxy-test-runner';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import { hashPassword, hashPasswordBytes } from "./hashPassword.js";
|
|
4
|
-
import { checkPassword, checkPasswordBytes } from "./checkPassword.js";
|
|
5
|
-
describe('hashPassword()', ({
|
|
6
|
-
it
|
|
7
|
-
}) => {
|
|
8
|
-
it('hashes a password and returns a string', async () => {
|
|
9
|
-
const hashed = await hashPassword('abcd');
|
|
10
|
-
//console.log('hashed: ' + hashed)
|
|
11
|
-
expect(hashed).to.be.a('string');
|
|
12
|
-
expect(hashed.length).to.be.at.least(10);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('hashPasswordBytes()', ({
|
|
16
|
-
it
|
|
17
|
-
}) => {
|
|
18
|
-
it('hashes a password and returns an array of bytes', async () => {
|
|
19
|
-
const hashedBytes = await hashPasswordBytes('abcd');
|
|
20
|
-
expect(hashedBytes).to.be.an.instanceOf(Buffer);
|
|
21
|
-
const hashedString = hashedBytes.toString();
|
|
22
|
-
//console.log('hashedString: ' + hashedString)
|
|
23
|
-
expect(hashedString).to.be.a('string');
|
|
24
|
-
expect(hashedString.length).to.be.at.least(10);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('checkPassword()', ({
|
|
28
|
-
it
|
|
29
|
-
}) => {
|
|
30
|
-
it('It states whether a password matches the input', async () => {
|
|
31
|
-
const password = 'xyz';
|
|
32
|
-
const hashed = await hashPassword(password);
|
|
33
|
-
expect(await checkPassword(password, hashed)).to.equal(true);
|
|
34
|
-
expect(await checkPassword(password + 'NotOurPassword', hashed)).to.equal(false);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe('checkPasswordBytes()', ({
|
|
38
|
-
it
|
|
39
|
-
}) => {
|
|
40
|
-
it('It states whether a password matches the input', async () => {
|
|
41
|
-
const password = 'xyz';
|
|
42
|
-
const hashed = await hashPasswordBytes(password);
|
|
43
|
-
expect(await checkPasswordBytes(password, hashed)).to.equal(true);
|
|
44
|
-
expect(await checkPasswordBytes(password + 'NotOurPassword', hashed)).to.equal(false);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkPasswordResetToken.sxyt.d.ts","sourceRoot":"","sources":["../../../src/auth/ref/checkPasswordResetToken.sxyt.js"],"names":[],"mappings":""}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// import { describe } from 'sxy-test-runner'
|
|
2
|
-
// import crypto from 'crypto'
|
|
3
|
-
export {};
|
|
4
|
-
// import { PasswordResetToken } from '../models/PasswordResetToken'
|
|
5
|
-
// import { prisma } from '../prisma/client'
|
|
6
|
-
// import { checkPasswordResetToken } from './checkPasswordResetToken.js'
|
|
7
|
-
// import { createPasswordResetToken } from './createPasswordResetToken.js'
|
|
8
|
-
// describe('checkPasswordResetToken() function', async ({it}) => {
|
|
9
|
-
// const user = await prisma.user.findFirst({ where: { id: 1 } })
|
|
10
|
-
// it('fails with junk data', async () => {
|
|
11
|
-
// const user = await prisma.user.findFirst({ where: { id: 1 } })
|
|
12
|
-
// const result = await checkPasswordResetToken(user, 'junk')
|
|
13
|
-
// result.success.should.equal(false)
|
|
14
|
-
// result.reason.should.equal('Invalid')
|
|
15
|
-
// })
|
|
16
|
-
// it('succeeds with a valid token', async () => {
|
|
17
|
-
// //const user = await prisma.user.findFirst({ where: { id: 1 } })
|
|
18
|
-
// const token = await createPasswordResetToken(user)
|
|
19
|
-
// //console.log('test token', token)
|
|
20
|
-
// const result = await checkPasswordResetToken(user, token)
|
|
21
|
-
// result.success.should.equal(true)
|
|
22
|
-
// result.reason.should.equal('Valid')
|
|
23
|
-
// })
|
|
24
|
-
// it('fails with an outdated token', async () => {
|
|
25
|
-
// //const user = await prisma.user.findFirst({ where: { id: 1 } })
|
|
26
|
-
// const token = 'abcde'
|
|
27
|
-
// const hash = crypto.createHash('sha256').update(user.id + token).digest('base64url')
|
|
28
|
-
// const passwordResetToken = new PasswordResetToken
|
|
29
|
-
// passwordResetToken.userId = user.id
|
|
30
|
-
// passwordResetToken.hash = hash
|
|
31
|
-
// passwordResetToken.expiresAt = new Date(Date.now() - 99999)
|
|
32
|
-
// await passwordResetToken.create()
|
|
33
|
-
// const result = await checkPasswordResetToken(user, token)
|
|
34
|
-
// result.success.should.equal(false)
|
|
35
|
-
// result.reason.should.equal('Expired')
|
|
36
|
-
// await prisma.passwordResetToken.delete({ where: {
|
|
37
|
-
// id: passwordResetToken.id
|
|
38
|
-
// } })
|
|
39
|
-
// })
|
|
40
|
-
// })
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPasswordResetToken.sxyt.d.ts","sourceRoot":"","sources":["../../../src/auth/ref/createPasswordResetToken.sxyt.js"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// import { describe } from 'sxy-test-runner'
|
|
2
|
-
// import { prisma } from '../prisma/client'
|
|
3
|
-
// import { createPasswordResetToken } from './createPasswordResetToken.js'
|
|
4
|
-
export {};
|
|
5
|
-
// describe('createPasswordResetToken() function', ({it}) => {
|
|
6
|
-
// it('creates a reset token and saves it to the database', async () => {
|
|
7
|
-
// const user = await prisma.user.findFirst({ where: { id: 1 } })
|
|
8
|
-
// createPasswordResetToken(user)
|
|
9
|
-
// })
|
|
10
|
-
// })
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fixImportsInSassErrorMessage.sxyt.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/fixImportsInSassErrorMessage.sxyt.ts"],"names":[],"mappings":""}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { describe } from 'sxy-test-runner';
|
|
2
|
-
// TODO: add control chars to our tests
|
|
3
|
-
// https://stackoverflow.com/questions/10170142/how-to-send-control-char-using-strict-mode-in-javascript
|
|
4
|
-
import { fixImportsInSassErrorMessage } from "./fixImportsInSassErrorMessage.js";
|
|
5
|
-
describe('fixImportInSassErrorMessage()', ({
|
|
6
|
-
it
|
|
7
|
-
}) => {
|
|
8
|
-
const input = `@import '../foo'`;
|
|
9
|
-
const map = [{
|
|
10
|
-
target: 'foo',
|
|
11
|
-
start: 9,
|
|
12
|
-
to: '../foo'
|
|
13
|
-
}];
|
|
14
|
-
it(`modifies sass import 'foo' into 'C:/project/styles/foo' in content '${input}'`, () => {
|
|
15
|
-
const result = fixImportsInSassErrorMessage(input, map);
|
|
16
|
-
//console.log(`result:`, result.message)
|
|
17
|
-
result.message.should.equal(`@import 'foo'`);
|
|
18
|
-
});
|
|
19
|
-
const input2 = `
|
|
20
|
-
@import '../foo'
|
|
21
|
-
^^^^^^^^^^^^^^^^
|
|
22
|
-
`;
|
|
23
|
-
const map2 = [{
|
|
24
|
-
target: 'foo',
|
|
25
|
-
start: 10,
|
|
26
|
-
to: '../foo'
|
|
27
|
-
}];
|
|
28
|
-
it(`corrects marking chevrons too using '${input2}'`, () => {
|
|
29
|
-
const result = fixImportsInSassErrorMessage(input2, map2);
|
|
30
|
-
//console.log('result:', result.message)
|
|
31
|
-
result.message.should.equal(`
|
|
32
|
-
@import 'foo'
|
|
33
|
-
^^^^^^^^^^^^^
|
|
34
|
-
`);
|
|
35
|
-
});
|
|
36
|
-
const input3 = `
|
|
37
|
-
@import '../foo'; @import '../bar';
|
|
38
|
-
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
|
|
39
|
-
`;
|
|
40
|
-
const map3 = [{
|
|
41
|
-
target: 'foo',
|
|
42
|
-
start: 10,
|
|
43
|
-
to: '../foo'
|
|
44
|
-
}, {
|
|
45
|
-
target: 'bar',
|
|
46
|
-
start: 29,
|
|
47
|
-
// might be wrong
|
|
48
|
-
to: '../bar'
|
|
49
|
-
}];
|
|
50
|
-
it(`handles a complex scenario with 2 imports on the same line (SCSS syntax) '${input3}'`, () => {
|
|
51
|
-
const result = fixImportsInSassErrorMessage(input3, map3);
|
|
52
|
-
//console.log('result:', result.message)
|
|
53
|
-
result.message.should.equal(`
|
|
54
|
-
@import 'foo'; @import 'bar';
|
|
55
|
-
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
|
|
56
|
-
`);
|
|
57
|
-
});
|
|
58
|
-
const input4 = `
|
|
59
|
-
@import '../foo'; @import '../bar'; @import '../foo'; @import '../bar';
|
|
60
|
-
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
|
|
61
|
-
`;
|
|
62
|
-
const map4 = [{
|
|
63
|
-
target: 'foo',
|
|
64
|
-
start: 10,
|
|
65
|
-
to: '../foo'
|
|
66
|
-
}, {
|
|
67
|
-
target: 'bar',
|
|
68
|
-
start: 29,
|
|
69
|
-
// might be wrong
|
|
70
|
-
to: '../bar'
|
|
71
|
-
}];
|
|
72
|
-
it(`handles case where error comes after an import without error on the same line using '${input4}'`, () => {
|
|
73
|
-
const result = fixImportsInSassErrorMessage(input4, map4);
|
|
74
|
-
//console.log('result:', result.message)
|
|
75
|
-
result.message.should.equal(`
|
|
76
|
-
@import 'foo'; @import 'bar'; @import 'foo'; @import 'bar';
|
|
77
|
-
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
|
|
78
|
-
`);
|
|
79
|
-
});
|
|
80
|
-
const input5 = `
|
|
81
|
-
3 │ @use '../style/mixins'; @use '../style/variablesss';
|
|
82
|
-
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
83
|
-
`;
|
|
84
|
-
const map5 = [{
|
|
85
|
-
target: 'mixins',
|
|
86
|
-
start: 99,
|
|
87
|
-
to: '../style/mixins'
|
|
88
|
-
}, {
|
|
89
|
-
target: 'variablesss',
|
|
90
|
-
start: 99,
|
|
91
|
-
// might be wrong
|
|
92
|
-
to: '../style/variablesss'
|
|
93
|
-
}];
|
|
94
|
-
it(`handles this real world output '${input5}'`, () => {
|
|
95
|
-
const result = fixImportsInSassErrorMessage(input5, map5);
|
|
96
|
-
//console.log('result:', result.message)
|
|
97
|
-
const expected = `
|
|
98
|
-
3 │ @use 'mixins'; @use 'variablesss';
|
|
99
|
-
│ ^^^^^^^^^^^^^^^^^^
|
|
100
|
-
`;
|
|
101
|
-
//console.log('expect:', expected)
|
|
102
|
-
//for (let i = 0; i <= 90; i++) {
|
|
103
|
-
// console.log(i, result.message[i], expected[i])
|
|
104
|
-
//}
|
|
105
|
-
//console.log(result.message.length, expected.length)
|
|
106
|
-
result.message.should.equal(expected);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBareImport.sxyt.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/transformPackageImports/resolveBareImport.sxyt.ts"],"names":[],"mappings":""}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe } from 'sxy-test-runner';
|
|
3
|
-
import { mkdir, mkdtemp, rm, writeFile } from 'fs/promises';
|
|
4
|
-
import { createRequire } from 'module';
|
|
5
|
-
import { tmpdir } from 'os';
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
import { resolveBareImport } from "./resolveBareImport.js";
|
|
8
|
-
async function makeFixture() {
|
|
9
|
-
const dir = await mkdtemp(join(tmpdir(), 'tungsten-resolve-bare-import-'));
|
|
10
|
-
const modules = join(dir, 'node_modules');
|
|
11
|
-
const dual = join(modules, 'dual-package');
|
|
12
|
-
await mkdir(dual, {
|
|
13
|
-
recursive: true
|
|
14
|
-
});
|
|
15
|
-
await writeFile(join(dual, 'package.json'), JSON.stringify({
|
|
16
|
-
name: 'dual-package',
|
|
17
|
-
version: '1.0.0',
|
|
18
|
-
exports: {
|
|
19
|
-
'.': {
|
|
20
|
-
import: './index.js',
|
|
21
|
-
require: './index.cjs'
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}));
|
|
25
|
-
await writeFile(join(dual, 'index.js'), 'export default 1');
|
|
26
|
-
await writeFile(join(dual, 'index.cjs'), 'module.exports = 1');
|
|
27
|
-
const cjsOnly = join(modules, 'cjs-package');
|
|
28
|
-
await mkdir(cjsOnly, {
|
|
29
|
-
recursive: true
|
|
30
|
-
});
|
|
31
|
-
await writeFile(join(cjsOnly, 'package.json'), JSON.stringify({
|
|
32
|
-
name: 'cjs-package',
|
|
33
|
-
version: '1.0.0',
|
|
34
|
-
main: './main.js'
|
|
35
|
-
}));
|
|
36
|
-
await writeFile(join(cjsOnly, 'main.js'), 'module.exports = 1');
|
|
37
|
-
return {
|
|
38
|
-
dir,
|
|
39
|
-
dual,
|
|
40
|
-
cjsOnly
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
describe('resolveBareImport()', ({
|
|
44
|
-
it
|
|
45
|
-
}) => {
|
|
46
|
-
it(`takes the 'import' condition where require.resolve takes 'require'`, async () => {
|
|
47
|
-
const {
|
|
48
|
-
dir,
|
|
49
|
-
dual
|
|
50
|
-
} = await makeFixture();
|
|
51
|
-
try {
|
|
52
|
-
const require = createRequire(join(dir, '_'));
|
|
53
|
-
expect(require.resolve('dual-package')).to.equal(join(dual, 'index.cjs'));
|
|
54
|
-
expect(resolveBareImport('dual-package', [dir])).to.equal(join(dual, 'index.js'));
|
|
55
|
-
} finally {
|
|
56
|
-
await rm(dir, {
|
|
57
|
-
recursive: true,
|
|
58
|
-
force: true
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
it(`resolves a package that only has a legacy main`, async () => {
|
|
63
|
-
const {
|
|
64
|
-
dir,
|
|
65
|
-
cjsOnly
|
|
66
|
-
} = await makeFixture();
|
|
67
|
-
try {
|
|
68
|
-
expect(resolveBareImport('cjs-package', [dir])).to.equal(join(cjsOnly, 'main.js'));
|
|
69
|
-
} finally {
|
|
70
|
-
await rm(dir, {
|
|
71
|
-
recursive: true,
|
|
72
|
-
force: true
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
it(`returns undefined for a package it cannot resolve, so the caller can fall back`, async () => {
|
|
77
|
-
const {
|
|
78
|
-
dir
|
|
79
|
-
} = await makeFixture();
|
|
80
|
-
try {
|
|
81
|
-
expect(resolveBareImport('not-installed', [dir])).to.equal(undefined);
|
|
82
|
-
} finally {
|
|
83
|
-
await rm(dir, {
|
|
84
|
-
recursive: true,
|
|
85
|
-
force: true
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
it(`tries each of the given directories in turn`, async () => {
|
|
90
|
-
const {
|
|
91
|
-
dir,
|
|
92
|
-
dual
|
|
93
|
-
} = await makeFixture();
|
|
94
|
-
try {
|
|
95
|
-
const missing = join(dir, 'no-such-dir');
|
|
96
|
-
expect(resolveBareImport('dual-package', [missing, dir])).to.equal(join(dual, 'index.js'));
|
|
97
|
-
} finally {
|
|
98
|
-
await rm(dir, {
|
|
99
|
-
recursive: true,
|
|
100
|
-
force: true
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile.sxyt.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/compile.sxyt.ts"],"names":[],"mappings":""}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'child_process';
|
|
2
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'fs/promises';
|
|
3
|
-
import { tmpdir } from 'os';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import { promisify } from 'util';
|
|
6
|
-
import { expect } from 'chai';
|
|
7
|
-
import { describe } from 'sxy-test-runner';
|
|
8
|
-
import { findProjectDir } from "../../findProjectDir.js";
|
|
9
|
-
const execFileAsync = promisify(execFile);
|
|
10
|
-
describe('tungsten compile', ({
|
|
11
|
-
it
|
|
12
|
-
}) => {
|
|
13
|
-
it('exits non-zero and does not report completion when Babel cannot transform a file', async () => {
|
|
14
|
-
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-test-'));
|
|
15
|
-
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
16
|
-
try {
|
|
17
|
-
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
18
|
-
await writeFile(join(projectDir, 'broken.jsx'), 'export const broken = <div>');
|
|
19
|
-
let error;
|
|
20
|
-
try {
|
|
21
|
-
await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--quiet'], {
|
|
22
|
-
cwd: projectDir
|
|
23
|
-
});
|
|
24
|
-
} catch (caught) {
|
|
25
|
-
error = caught;
|
|
26
|
-
}
|
|
27
|
-
expect(error).not.to.equal(undefined);
|
|
28
|
-
expect(error?.code).not.to.equal(0);
|
|
29
|
-
expect(error?.stdout ?? '').not.to.contain('Compile complete');
|
|
30
|
-
} finally {
|
|
31
|
-
await rm(projectDir, {
|
|
32
|
-
recursive: true,
|
|
33
|
-
force: true
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
it('writes all JavaScript and readiness output beneath the selected locations', async () => {
|
|
38
|
-
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-output-test-'));
|
|
39
|
-
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
40
|
-
try {
|
|
41
|
-
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
42
|
-
await writeFile(join(projectDir, 'entry.jsx'), 'export const element = <div />');
|
|
43
|
-
const {
|
|
44
|
-
stdout
|
|
45
|
-
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--ready-file', '.tungsten/test.ready', '--quiet'], {
|
|
46
|
-
cwd: projectDir
|
|
47
|
-
});
|
|
48
|
-
const compiled = await readFile(join(projectDir, '.tungsten/test/code/entry.js'), 'utf8');
|
|
49
|
-
const ready = JSON.parse(await readFile(join(projectDir, '.tungsten/test.ready'), 'utf8'));
|
|
50
|
-
expect(stdout).to.contain('Compile complete');
|
|
51
|
-
expect(compiled).to.contain('export const element');
|
|
52
|
-
expect(ready.ready).to.equal(true);
|
|
53
|
-
expect(ready.output).to.equal(join(projectDir, '.tungsten/test'));
|
|
54
|
-
} finally {
|
|
55
|
-
await rm(projectDir, {
|
|
56
|
-
recursive: true,
|
|
57
|
-
force: true
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
it('reports an unsupported node dependency once and continues compiling', async () => {
|
|
62
|
-
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-node-dependency-test-'));
|
|
63
|
-
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
64
|
-
const packageDir = join(projectDir, 'node_modules', 'fixture-package');
|
|
65
|
-
const sourceDir = join(projectDir, 'src');
|
|
66
|
-
try {
|
|
67
|
-
await mkdir(packageDir, {
|
|
68
|
-
recursive: true
|
|
69
|
-
});
|
|
70
|
-
await mkdir(sourceDir, {
|
|
71
|
-
recursive: true
|
|
72
|
-
});
|
|
73
|
-
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
74
|
-
await writeFile(join(projectDir, 'tungsten.config.js'), 'export default { codeDir: "src", useRootComponent: false }');
|
|
75
|
-
await writeFile(join(sourceDir, 'entry.js'), 'import fixture from \'fixture-package\'; export { fixture }');
|
|
76
|
-
await writeFile(join(packageDir, 'package.json'), '{"name":"fixture-package","version":"1.0.0","main":"index.js"}');
|
|
77
|
-
await writeFile(join(packageDir, 'index.js'), 'module.exports = require(\'missing-native-module\')');
|
|
78
|
-
const {
|
|
79
|
-
stdout
|
|
80
|
-
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
|
|
81
|
-
cwd: projectDir
|
|
82
|
-
});
|
|
83
|
-
expect(stdout).to.contain('Your code that is compiled may depend on a node module - this is not allowed.');
|
|
84
|
-
expect(stdout).to.contain('src/entry.js\n -> fixture-package/index.js\n -> missing-native-module (unresolved)');
|
|
85
|
-
expect(stdout).not.to.contain('Require stack:');
|
|
86
|
-
expect(stdout).not.to.contain('process file err');
|
|
87
|
-
expect(stdout.split('Your code that is compiled may depend on a node module - this is not allowed.')).to.have.length(2);
|
|
88
|
-
expect(stdout).to.contain('Compile complete');
|
|
89
|
-
await readFile(join(projectDir, '.tungsten/test/code/entry.js'), 'utf8');
|
|
90
|
-
} finally {
|
|
91
|
-
await rm(projectDir, {
|
|
92
|
-
recursive: true,
|
|
93
|
-
force: true
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
it('takes the import build of a dual package for an import, and the require build for a require', async () => {
|
|
98
|
-
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-conditions-test-'));
|
|
99
|
-
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
100
|
-
const sourceDir = join(projectDir, 'src');
|
|
101
|
-
const dualDir = join(projectDir, 'node_modules', 'dual-package');
|
|
102
|
-
const cjsDir = join(projectDir, 'node_modules', 'cjs-package');
|
|
103
|
-
async function copiedToPackages(rel) {
|
|
104
|
-
try {
|
|
105
|
-
await readFile(join(projectDir, '.tungsten/test/.packages', rel), 'utf8');
|
|
106
|
-
return true;
|
|
107
|
-
} catch {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
await mkdir(dualDir, {
|
|
113
|
-
recursive: true
|
|
114
|
-
});
|
|
115
|
-
await mkdir(cjsDir, {
|
|
116
|
-
recursive: true
|
|
117
|
-
});
|
|
118
|
-
await mkdir(sourceDir, {
|
|
119
|
-
recursive: true
|
|
120
|
-
});
|
|
121
|
-
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
122
|
-
await writeFile(join(projectDir, 'tungsten.config.js'), 'export default { codeDir: "src", useRootComponent: false }');
|
|
123
|
-
// ships both builds, as @trpc/server and zod do
|
|
124
|
-
await writeFile(join(dualDir, 'package.json'), JSON.stringify({
|
|
125
|
-
name: 'dual-package',
|
|
126
|
-
version: '1.0.0',
|
|
127
|
-
exports: {
|
|
128
|
-
'.': {
|
|
129
|
-
import: './index.mjs',
|
|
130
|
-
require: './index.cjs'
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}));
|
|
134
|
-
await writeFile(join(dualDir, 'index.mjs'), 'export const dual = "esm"');
|
|
135
|
-
await writeFile(join(dualDir, 'index.cjs'), 'module.exports = { dual: "cjs" }');
|
|
136
|
-
// a CJS package that require()s the dual package
|
|
137
|
-
await writeFile(join(cjsDir, 'package.json'), JSON.stringify({
|
|
138
|
-
name: 'cjs-package',
|
|
139
|
-
version: '1.0.0',
|
|
140
|
-
main: './index.js'
|
|
141
|
-
}));
|
|
142
|
-
await writeFile(join(cjsDir, 'index.js'), 'module.exports = require(\'dual-package\')');
|
|
143
|
-
await writeFile(join(sourceDir, 'entry.js'), 'import { dual } from \'dual-package\'\n' + 'import viaCjs from \'cjs-package\'\n' + 'export { dual, viaCjs }');
|
|
144
|
-
const {
|
|
145
|
-
stdout
|
|
146
|
-
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
|
|
147
|
-
cwd: projectDir
|
|
148
|
-
});
|
|
149
|
-
expect(stdout).to.contain('Compile complete');
|
|
150
|
-
// the ESM import took ./index.mjs
|
|
151
|
-
expect(await copiedToPackages('dual-package@1.0.0/index.mjs')).to.equal(true);
|
|
152
|
-
// and the require() inside the CJS package took ./index.cjs, so that the
|
|
153
|
-
// converted require() shim can find it in its deps
|
|
154
|
-
expect(await copiedToPackages('dual-package@1.0.0/index.cjs')).to.equal(true);
|
|
155
|
-
} finally {
|
|
156
|
-
await rm(projectDir, {
|
|
157
|
-
recursive: true,
|
|
158
|
-
force: true
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
it('overrides the ignoreDirs and ignorePatterns config entries from the command line', async () => {
|
|
163
|
-
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-ignore-test-'));
|
|
164
|
-
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
165
|
-
const sourceDir = join(projectDir, 'src');
|
|
166
|
-
async function compiled(rel) {
|
|
167
|
-
try {
|
|
168
|
-
await readFile(join(projectDir, '.tungsten/test/code', rel), 'utf8');
|
|
169
|
-
return true;
|
|
170
|
-
} catch {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
await mkdir(join(sourceDir, 'server'), {
|
|
176
|
-
recursive: true
|
|
177
|
-
});
|
|
178
|
-
await mkdir(join(sourceDir, 'tests'), {
|
|
179
|
-
recursive: true
|
|
180
|
-
});
|
|
181
|
-
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
182
|
-
await writeFile(join(projectDir, 'tungsten.config.js'), 'export default {' + ' codeDir: "src",' + ' useRootComponent: false,' + ' ignoreDirs: "server",' + ' ignorePatterns: "**/*.domTest.js"' + ' }');
|
|
183
|
-
await writeFile(join(sourceDir, 'entry.js'), 'export const entry = 1');
|
|
184
|
-
await writeFile(join(sourceDir, 'server', 'api.js'), 'export const api = 1');
|
|
185
|
-
await writeFile(join(sourceDir, 'tests', 'unit.js'), 'export const unit = 1');
|
|
186
|
-
await writeFile(join(sourceDir, 'component.domTest.js'), 'export const domTest = 1');
|
|
187
|
-
// the config entries alone - server/ and *.domTest.js are left out
|
|
188
|
-
await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
|
|
189
|
-
cwd: projectDir
|
|
190
|
-
});
|
|
191
|
-
expect(await compiled('entry.js')).to.equal(true);
|
|
192
|
-
expect(await compiled('server/api.js')).to.equal(false);
|
|
193
|
-
expect(await compiled('component.domTest.js')).to.equal(false);
|
|
194
|
-
// blank values override both entries away, so everything is compiled
|
|
195
|
-
await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet', '--ignore-dirs', '', '--ignore-patterns', ''], {
|
|
196
|
-
cwd: projectDir
|
|
197
|
-
});
|
|
198
|
-
expect(await compiled('server/api.js')).to.equal(true);
|
|
199
|
-
expect(await compiled('component.domTest.js')).to.equal(true);
|
|
200
|
-
// repeating an option replaces the config entry with all of the given values
|
|
201
|
-
await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet', '--ignore-dirs', 'tests', '--ignore-dirs', 'server'], {
|
|
202
|
-
cwd: projectDir
|
|
203
|
-
});
|
|
204
|
-
expect(await compiled('entry.js')).to.equal(true);
|
|
205
|
-
expect(await compiled('tests/unit.js')).to.equal(false);
|
|
206
|
-
expect(await compiled('server/api.js')).to.equal(false);
|
|
207
|
-
// ignorePatterns was not overridden, so it still applies
|
|
208
|
-
expect(await compiled('component.domTest.js')).to.equal(false);
|
|
209
|
-
} finally {
|
|
210
|
-
await rm(projectDir, {
|
|
211
|
-
recursive: true,
|
|
212
|
-
force: true
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
it('skips package compilation for files selected by a JavaScript glob', async () => {
|
|
217
|
-
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-skip-package-compilation-test-'));
|
|
218
|
-
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
219
|
-
const packageDir = join(projectDir, 'node_modules', 'fixture-package');
|
|
220
|
-
const sourceDir = join(projectDir, 'src');
|
|
221
|
-
try {
|
|
222
|
-
await mkdir(packageDir, {
|
|
223
|
-
recursive: true
|
|
224
|
-
});
|
|
225
|
-
await mkdir(sourceDir, {
|
|
226
|
-
recursive: true
|
|
227
|
-
});
|
|
228
|
-
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
229
|
-
await writeFile(join(projectDir, 'tungsten.config.js'), 'export default {' + ' codeDir: "src",' + ' useRootComponent: false,' + ' skipPackageCompilation: "**/*.domTest.js"' + ' }');
|
|
230
|
-
await writeFile(join(sourceDir, 'component.domTest.js'), "import fixture from 'fixture-package'; export { fixture }");
|
|
231
|
-
await writeFile(join(packageDir, 'package.json'), '{"name":"fixture-package","version":"1.0.0","main":"index.js"}');
|
|
232
|
-
await writeFile(join(packageDir, 'index.js'), 'module.exports = 1');
|
|
233
|
-
const {
|
|
234
|
-
stdout
|
|
235
|
-
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
|
|
236
|
-
cwd: projectDir
|
|
237
|
-
});
|
|
238
|
-
const compiled = await readFile(join(projectDir, '.tungsten/test/code/component.domTest.js'), 'utf8');
|
|
239
|
-
expect(stdout).to.contain('Compile complete');
|
|
240
|
-
expect(compiled).to.contain("from 'fixture-package'");
|
|
241
|
-
let packageWasCopied = true;
|
|
242
|
-
try {
|
|
243
|
-
await readFile(join(projectDir, '.tungsten/test/.packages/fixture-package@1.0.0/index.js'), 'utf8');
|
|
244
|
-
} catch {
|
|
245
|
-
packageWasCopied = false;
|
|
246
|
-
}
|
|
247
|
-
expect(packageWasCopied).to.equal(false);
|
|
248
|
-
} finally {
|
|
249
|
-
await rm(projectDir, {
|
|
250
|
-
recursive: true,
|
|
251
|
-
force: true
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|