forked from facebook/lexical
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into refactor-npm-package-…
…process-facebookgh-5869
- Loading branch information
Showing
10 changed files
with
185 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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,40 @@ | ||
name: Publish DevTools extension to stores | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
if: github.repository_owner == 'facebook' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Configure Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
cache: 'npm' | ||
|
||
- uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: | | ||
node_modules | ||
~/.cache/ms-playwright | ||
key: ${{ runner.os }}-v${{ secrets.CACHE_VERSION }}-${{ hashFiles('package-lock.json') }} | ||
|
||
- name: Install dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Zip & submit to stores | ||
run: npm run publish-extension | ||
env: | ||
EDGE_ACCESS_TOKEN_URL: ${{ secrets.EXTENSION_EDGE_ACCESS_TOKEN_URL }} | ||
EDGE_CLIENT_SECRET: ${{ secrets.EXTENSION_EDGE_CLIENT_SECRET }} | ||
EDGE_PRODUCT_ID: ${{ secrets.EXTENSION_EDGE_PRODUCT_ID }} | ||
EDGE_CLIENT_ID: ${{ secrets.EXTENSION_EDGE_CLIENT_ID }} | ||
FIREFOX_EXTENSION_ID: ${{ secrets.EXTENSION_FIREFOX_EXTENSION_ID }} | ||
FIREFOX_JWT_ISSUER: ${{ secrets.EXTENSION_FIREFOX_JWT_ISSUER }} | ||
FIREFOX_JWT_SECRET: ${{ secrets.EXTENSION_FIREFOX_JWT_SECRET }} |
This file contains 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 |
---|---|---|
|
@@ -18,6 +18,7 @@ npm | |
e2e-screenshots | ||
test-results | ||
playwright-report | ||
/SOURCE_CODE_REVIEW.md | ||
|
||
npm-debug.log* | ||
|
||
|
This file contains 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 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 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,7 @@ | ||
# Lexical Developer Tools review instructions: | ||
|
||
1. Install latest LTS version of Node.js & Chrome | ||
2. Use local copy of the source code or obtain one from https://github.com/facebook/lexical | ||
3. Run `npm i` | ||
4. Navigate to `/packages/lexical-devtools` | ||
5. Run `npm run dev` |
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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,88 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
// @ts-check | ||
'use strict'; | ||
|
||
const fs = require('fs-extra'); | ||
const glob = require('glob'); | ||
const ts = require('typescript'); | ||
|
||
const pretty = process.env.CI !== 'true'; | ||
|
||
/** @type {ts.FormatDiagnosticsHost} */ | ||
const diagnosticsHost = { | ||
getCanonicalFileName: (fn) => fn, | ||
getCurrentDirectory: () => './', | ||
getNewLine: () => '\n', | ||
}; | ||
|
||
/** | ||
* Validate that the published .d.ts types do not have dependencies | ||
* on any private module (currently shared/*). | ||
* | ||
* `process.exit(1)` on failure. | ||
*/ | ||
function validateTscTypes() { | ||
const dtsFilesPattern = './.ts-temp/{lexical,lexical-*}/**/*.d.ts'; | ||
const dtsFiles = glob.sync(dtsFilesPattern); | ||
if (dtsFiles.length === 0) { | ||
console.error( | ||
`Missing ${dtsFilesPattern}, \`npm run build-prod\` or \`npm run build-release\` first`, | ||
); | ||
process.exit(1); | ||
} | ||
/** @type {ts.Diagnostic[]} */ | ||
const diagnostics = []; | ||
for (const fn of dtsFiles) { | ||
// console.log(fn); | ||
const ast = ts.createSourceFile( | ||
fn, | ||
fs.readFileSync(fn, 'utf-8'), | ||
ts.ScriptTarget.Latest, | ||
); | ||
const checkSpecifier = (/** @type {ts.Node | undefined} */ node) => { | ||
if (!node || node.kind !== ts.SyntaxKind.StringLiteral) { | ||
return; | ||
} | ||
const specifier = /** @type {import('typescript').StringLiteral} */ ( | ||
node | ||
); | ||
if (/^shared(\/|$)/.test(specifier.text)) { | ||
const start = specifier.getStart(ast); | ||
diagnostics.push({ | ||
category: ts.DiagnosticCategory.Error, | ||
code: Infinity, | ||
file: ast, | ||
length: specifier.getEnd() - start, | ||
messageText: `Published .d.ts files must not import private module '${specifier.text}'.`, | ||
start, | ||
}); | ||
} | ||
}; | ||
ast.forEachChild((node) => { | ||
if (node.kind === ts.SyntaxKind.ExportDeclaration) { | ||
const exportNode = | ||
/** @type {import('typescript').ExportDeclaration} */ (node); | ||
checkSpecifier(exportNode.moduleSpecifier); | ||
} else if (node.kind === ts.SyntaxKind.ImportDeclaration) { | ||
const importNode = | ||
/** @type {import('typescript').ImportDeclaration} */ (node); | ||
checkSpecifier(importNode.moduleSpecifier); | ||
} | ||
}); | ||
} | ||
if (diagnostics.length > 0) { | ||
const msg = ( | ||
pretty ? ts.formatDiagnosticsWithColorAndContext : ts.formatDiagnostics | ||
)(diagnostics, diagnosticsHost); | ||
console.error(msg.replace(/ TSInfinity:/g, ':')); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
validateTscTypes(); |