-
-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wip): components monorepo (#1082)
- Loading branch information
Showing
36 changed files
with
1,294 additions
and
68 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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
node_modules | ||
packages/*/coverage | ||
webpack.config.js | ||
scripts |
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,34 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
if: contains(github.event.head_commit.message, 'chore(release)') == false | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '16.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: yarn install --pure-lockfile | ||
- run: yarn build | ||
- name: Setup git config | ||
run: | | ||
git config --global user.name "standardci" | ||
git config --global user.email "ci@standardnotes.com" | ||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v4 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.PASSPHRASE }} | ||
git_user_signingkey: true | ||
git_commit_gpgsign: true | ||
- run: yarn version-bump |
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ packages/web-server/vendor | |
|
||
packages/web/dist | ||
|
||
/.sass-cache | ||
.sass-cache | ||
|
||
.env | ||
.ssh | ||
|
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.github | ||
codeqldb | ||
CHANGELOG.md |
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 @@ | ||
{ | ||
"org.standardnotes.theme-autobiography": { | ||
"version": "1.0.4", | ||
"base64": "b1df118550bca4ef10b6f8eaeeeddb051cde8171212c5a73a577c834d331725f", | ||
"binary": "8cf9b21daea61b41bde70bfd6a7a4fcb1a8cf5539da52a7f7bcd48f2faa1c748" | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/components/dist/org.standardnotes.theme-autobiography/dist/dist.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
packages/components/dist/org.standardnotes.theme-autobiography/dist/dist.css.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+1.53 KB
...ents/dist/org.standardnotes.theme-autobiography/org.standardnotes.theme-autobiography.zip
Binary file not shown.
26 changes: 26 additions & 0 deletions
26
packages/components/dist/org.standardnotes.theme-autobiography/package.json
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,26 @@ | ||
{ | ||
"name": "@standardnotes/autobiography-theme", | ||
"version": "1.0.4", | ||
"main": "dist/dist.css", | ||
"devDependencies": { | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-sass": "^1.0.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-newer": "^1.2.0" | ||
}, | ||
"scripts": { | ||
"build": "grunt", | ||
"prepublishOnly": "yarn run build" | ||
}, | ||
"sn": { | ||
"main": "dist/dist.css" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/standardnotes/autobiography-theme.git" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"packages": ["src/*"], | ||
"useWorkspaces": true | ||
} |
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,22 @@ | ||
{ | ||
"name": "@standardnotes/components-meta", | ||
"version": "0.0.1", | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"src/*" | ||
] | ||
}, | ||
"scripts": { | ||
"preversion": "lerna run build --parallel", | ||
"version": "node scripts/package-components.mjs" | ||
}, | ||
"dependencies": { | ||
"@standardnotes/autobiography-theme": "1.0.4" | ||
}, | ||
"devDependencies": { | ||
"@standardnotes/deterministic-zip": "^1.2.0", | ||
"@standardnotes/features": "^1.45.1", | ||
"lerna": "*" | ||
} | ||
} |
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,149 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import crypto from 'crypto' | ||
import { spawnSync as spawn } from 'child_process' | ||
import { GetFeatures } from '@standardnotes/features/dist/Domain/Feature/Features.js' | ||
import { GetDeprecatedFeatures } from '@standardnotes/features/dist/Domain/Feature/Lists/DeprecatedFeatures.js' | ||
import zip from '@standardnotes/deterministic-zip' | ||
|
||
console.log('Beginning packaging procedure...') | ||
|
||
const specificFeatureIdentifier = process.argv[2] | ||
if (specificFeatureIdentifier) { | ||
console.log('Processing only', specificFeatureIdentifier) | ||
} | ||
|
||
const SOURCE_FILES_PATH = 'src' | ||
const DistDir = path.join('dist') | ||
|
||
const ChecksumsSrcPath = path.join(DistDir, 'Checksums.json') | ||
const ChecksumsDistPath = path.join(DistDir, 'Checksums.json') | ||
const Checksums = JSON.parse(fs.readFileSync(ChecksumsSrcPath).toString()) | ||
console.log('Loaded existing checksums from', ChecksumsSrcPath) | ||
|
||
async function zipDirectory(sourceDir, outPath) { | ||
return new Promise((resolve) => { | ||
zip(sourceDir, outPath, { cwd: sourceDir }, (err) => { | ||
console.log(`Zipped to ${outPath}`) | ||
resolve(outPath) | ||
}) | ||
}) | ||
} | ||
|
||
const copyFileOrDir = (src, dest) => { | ||
const isDir = fs.lstatSync(src).isDirectory() | ||
if (isDir) { | ||
ensureDirExists(dest) | ||
const entries = fs.readdirSync(src, { withFileTypes: true }) | ||
|
||
for (const entry of entries) { | ||
const srcPath = path.join(src, entry.name) | ||
const destPath = path.join(dest, entry.name) | ||
|
||
entry.isDirectory() ? copyFileOrDir(srcPath, destPath) : fs.copyFileSync(srcPath, destPath) | ||
} | ||
} else { | ||
fs.copyFileSync(src, dest) | ||
} | ||
} | ||
|
||
const doesDirExist = (dir) => { | ||
return fs.existsSync(dir) | ||
} | ||
|
||
const ensureDirExists = (dir) => { | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir, { recursive: true }) | ||
} | ||
} | ||
|
||
const emptyExistingDir = (dir) => { | ||
if (fs.existsSync(dir)) { | ||
fs.rmSync(dir, { recursive: true }) | ||
} | ||
} | ||
|
||
const copyToDist = async (feature) => { | ||
const srcComponentPath = path.join(SOURCE_FILES_PATH, feature.identifier) | ||
|
||
if (!doesDirExist(srcComponentPath)) { | ||
return | ||
} | ||
|
||
const targetComponentPath = `${path.join(DistDir, feature.identifier)}` | ||
|
||
emptyExistingDir(targetComponentPath) | ||
ensureDirExists(targetComponentPath) | ||
|
||
for (const file of feature.static_files) { | ||
const srcFilePath = path.join(srcComponentPath, file) | ||
|
||
if (!fs.existsSync(srcFilePath)) { | ||
continue | ||
} | ||
|
||
const targetFilePath = path.join(targetComponentPath, file) | ||
copyFileOrDir(srcFilePath, targetFilePath) | ||
} | ||
|
||
return targetComponentPath | ||
} | ||
|
||
const computeChecksum = async (zipPath, version) => { | ||
const zipData = fs.readFileSync(zipPath, 'base64') | ||
const base64 = crypto.createHash('sha256').update(zipData).digest('hex') | ||
const checksumProcess = spawn('sha256sum', [zipPath]) | ||
const checksumString = checksumProcess.stdout.toString() | ||
const binary = checksumString.split(' ')[0] | ||
return { | ||
version, | ||
base64, | ||
binary, | ||
} | ||
} | ||
|
||
const zipAndChecksumFeature = async (feature) => { | ||
console.log('Processing feature', feature.identifier, '...') | ||
|
||
const distPath = await copyToDist(feature) | ||
|
||
if (!distPath) { | ||
return | ||
} | ||
|
||
const outZip = `${distPath}/${feature.identifier}.zip` | ||
await zipDirectory(distPath, outZip) | ||
|
||
const checksum = await computeChecksum(outZip, feature.version) | ||
Checksums[feature.identifier] = checksum | ||
console.log(`Computed checksums for ${feature.identifier}:`, checksum) | ||
} | ||
|
||
await (async () => { | ||
const featuresToProcess = specificFeatureIdentifier | ||
? [GetFeatures().find((feature) => feature.identifier === specificFeatureIdentifier)] | ||
: GetFeatures().concat(GetDeprecatedFeatures()) | ||
|
||
let index = 0 | ||
for (const feature of featuresToProcess) { | ||
if (index === 0) { | ||
console.log('\n---\n') | ||
} | ||
|
||
if (feature.download_url) { | ||
await zipAndChecksumFeature(feature) | ||
} else { | ||
console.log('Feature does not have download_url, not packaging', feature.identifier) | ||
} | ||
|
||
if (index !== featuresToProcess.length - 1) { | ||
console.log('\n---\n') | ||
} | ||
|
||
index++ | ||
} | ||
|
||
fs.writeFileSync(ChecksumsSrcPath, JSON.stringify(Checksums, undefined, 2)) | ||
console.log('Succesfully wrote checksums to', ChecksumsSrcPath) | ||
copyFileOrDir(ChecksumsSrcPath, ChecksumsDistPath) | ||
})() |
1 change: 1 addition & 0 deletions
1
packages/components/src/org.standardnotes.theme-autobiography/.gitignore
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 @@ | ||
dist |
31 changes: 31 additions & 0 deletions
31
packages/components/src/org.standardnotes.theme-autobiography/Gruntfile.js
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,31 @@ | ||
module.exports = function(grunt) { | ||
|
||
grunt.initConfig({ | ||
watch: { | ||
css: { | ||
files: ['src/**/*.scss'], | ||
tasks: ['sass'], | ||
options: { | ||
spawn: false, | ||
}, | ||
} | ||
}, | ||
|
||
sass: { | ||
dist: { | ||
options: { | ||
style: 'expanded' | ||
}, | ||
files: { | ||
'dist/dist.css': 'src/main.scss' | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-newer'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('grunt-contrib-sass'); | ||
|
||
grunt.registerTask('default', ['sass']); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/components/src/org.standardnotes.theme-autobiography/README.md
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 @@ | ||
# Autobiography Theme |
19 changes: 19 additions & 0 deletions
19
packages/components/src/org.standardnotes.theme-autobiography/package.json
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,19 @@ | ||
{ | ||
"name": "@standardnotes/autobiography-theme", | ||
"version": "1.0.4", | ||
"main": "dist/dist.css", | ||
"private": true, | ||
"scripts": { | ||
"build": "grunt", | ||
"prepublishOnly": "yarn run build" | ||
}, | ||
"sn": { | ||
"main": "dist/dist.css" | ||
}, | ||
"devDependencies": { | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-sass": "^1.0.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-newer": "^1.2.0" | ||
} | ||
} |
Oops, something went wrong.