-
Notifications
You must be signed in to change notification settings - Fork 321
Isomorphic PHP, Isomorphic Blueprints #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
79c2bc7
UniversalPHP
adamziel 263aade
Make PHP Isomorphic and universal with respect to Local / Remote runtime
adamziel 7730c98
Extract blueprints to a separate package to decouple them from Playgr…
adamziel 4e27f3b
Add defineSiteUrl and runWpInstallationWizard helpers
adamziel 5b96ff7
Move WordPress patcher to blueprints
adamziel 0a57903
Add playground/node package to run Blueprints in node.js
adamziel 2b11f8c
Settle the API shape
adamziel 1685f64
Build blueprints and php-wasm/universal as both ESM and CJS
adamziel 643bb29
Rename files
adamziel f31a4fe
Revert unnecessary function rename in php-wasm-node
adamziel 4435b92
Rename test.sh to ensure-both-outputs-run-in-node.sh
adamziel 10340e5
Use mkdirSync with recursive: true instead of checking whether fileEx…
adamziel e734f30
Revert changes from packages/php-wasm/node/src/lib/networking/outboun…
adamziel a819f19
Expand STR and NUM to STRING and NUMBER
adamziel 373c233
Remove WithProgress interface
adamziel 94dd955
Adjust doc generation conf
adamziel 9175526
Remove parseWorkerStartupOptions from php-wasm/node
adamziel e44bef0
Spawn node directly in assert-built-esm-and-cjs executor
adamziel 5594e8e
Correct typos in loadPHPRuntime()
adamziel a377bb0
Rename patchFile to updateFile
adamziel 68bbbb0
Prevent defining WP_HOME and WP_SITEURL contants twice
adamziel ad7ffce
Relocate step types to the handler files
adamziel 43d02ca
Document admin_password2
adamziel 364eab9
Export step types
adamziel 7e1c652
Export SemaphoreOptions as a type
adamziel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/nx-extensions/src/executors/assert-built-esm-and-cjs/executor.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ExecutorContext } from '@nrwl/devkit'; | ||
import { spawnSync } from 'child_process'; | ||
import { existsSync, mkdirSync, writeFileSync } from 'fs'; | ||
import * as path from 'path'; | ||
import { AssertBuiltEsmAndCjsExecutorSchema } from './schema'; | ||
|
||
/** | ||
* Test whether a module can be imported as both ESM and CJS. | ||
* | ||
* @param options | ||
* @param context | ||
* @returns | ||
*/ | ||
export default async function runExecutor( | ||
options: AssertBuiltEsmAndCjsExecutorSchema, | ||
context: ExecutorContext | ||
) { | ||
const buildDir = options.outputPath.split('/')[0]; | ||
const testsPath = path.join(context.root, buildDir, 'test-esm-cjs'); | ||
if (!existsSync(testsPath)) { | ||
mkdirSync(testsPath); | ||
} | ||
|
||
writeFileSync( | ||
path.join(testsPath, 'test-esm.mjs'), | ||
`import * as result from '../../${options.outputPath}/index.js';` | ||
); | ||
writeFileSync( | ||
path.join(testsPath, 'test-cjs.cjs'), | ||
`require('../../${options.outputPath}');` | ||
); | ||
writeFileSync( | ||
path.join(testsPath, 'test.sh'), | ||
`#!/bin/sh | ||
set -e | ||
node test-esm.mjs; | ||
node test-cjs.cjs; | ||
echo Success;` | ||
); | ||
adamziel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Run test.sh and check exit code: | ||
const test = spawnSync('sh', ['test.sh'], { | ||
cwd: testsPath, | ||
stdio: 'pipe', | ||
encoding: 'utf-8', | ||
}); | ||
// Trim spaces and newlines | ||
const stdout = test.output.toString(); | ||
const success = | ||
test.status === 0 && stdout.replace(/[^A-Za-z]/g, '') === 'Success'; | ||
if (!success) { | ||
throw `${context.targetName} could not be imported as both ESM and CJS: ${stdout}`; | ||
} | ||
return { | ||
success, | ||
}; | ||
adamziel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
3 changes: 3 additions & 0 deletions
3
packages/nx-extensions/src/executors/assert-built-esm-and-cjs/schema.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface AssertBuiltEsmAndCjsExecutorSchema { | ||
outputPath: string; | ||
} // eslint-disable-line |
15 changes: 15 additions & 0 deletions
15
packages/nx-extensions/src/executors/assert-built-esm-and-cjs/schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"version": 2, | ||
"cli": "nx", | ||
"title": "AssertBuiltEsmAndCjs executor", | ||
"description": "", | ||
"type": "object", | ||
"properties": { | ||
"outputPath": { | ||
"type": "string", | ||
"description": "The path to the built module" | ||
} | ||
}, | ||
"required": ["outputPath"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1 @@ | ||
import { TextEncoder, TextDecoder } from 'util'; | ||
global.TextEncoder = TextEncoder as any; | ||
global.TextDecoder = TextDecoder as any; | ||
|
||
export * from './lib'; | ||
|
||
export { | ||
LatestSupportedPHPVersion, | ||
PHPBrowser, | ||
SupportedPHPVersions, | ||
SupportedPHPVersionsList, | ||
} from '@php-wasm/abstract'; | ||
|
||
// Wildcard re-export of type is unfortunately unsupported by TypeScript. | ||
export type { | ||
DataModule, | ||
EmscriptenOptions, | ||
ErrnoError, | ||
FileInfo, | ||
HTTPMethod, | ||
MountSettings, | ||
PHPLoaderModule, | ||
PHPOutput, | ||
PHPRequest, | ||
PHPRequestHandler, | ||
PHPRequestHeaders, | ||
PHPResponse, | ||
PHPRunOptions, | ||
PHPRuntime, | ||
PHPRuntimeId, | ||
PHPRequestHandlerConfiguration, | ||
RuntimeType, | ||
SupportedPHPVersion, | ||
WithFilesystem, | ||
WithPHPIniBindings, | ||
WorkerStartupOptions, | ||
} from '@php-wasm/abstract'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
packages/php-wasm/node/src/lib/parse-worker-startup-options.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import { WorkerStartupOptions } from '@php-wasm/abstract'; | ||
|
||
export function parseWorkerStartupOptions(): WorkerStartupOptions { | ||
export function parseWorkerStartupOptions(): Record<string, string> { | ||
adamziel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return JSON.parse(process.env['WORKER_OPTIONS'] || '{}'); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.