Skip to content

Commit 9b10841

Browse files
authored
Merge pull request #1835 from nodeSolidServer/esm2
- convert NSS from CJS to ESM - eslint@9 - oidc - add scope WebID - rfc7902 : display iss in response
2 parents 7828cb6 + bb4f708 commit 9b10841

File tree

271 files changed

+29295
-26443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+29295
-26443
lines changed

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Force bash scripts to have unix line endings
2+
*.sh text eol=lf
3+
4+
# Force bin files (executable scripts) to have unix line endings
5+
bin/* text eol=lf
6+
7+
# Ensure batch files on Windows keep CRLF line endings
8+
*.bat text eol=crlf
9+
10+
# Binary files should not be modified
11+
*.png binary
12+
*.jpg binary
13+
*.jpeg binary
14+
*.gif binary
15+
*.ico binary
16+
*.pdf binary
17+
*.zip binary
18+
*.tar.gz binary
19+
*.tgz binary

.github/workflows/ci.yml

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,67 @@ jobs:
5151
node-version: ${{ matrix.node-version }}
5252
- run: npm ci
5353
# test code
54-
- run: npm run standard
54+
- run: npm run lint
5555
- run: npm run validate
56-
- run: npm run nyc
56+
- run: npm run c8
5757
# Test global install of the package
5858
- run: npm pack .
5959
- run: npm install -g solid-server-*.tgz
6060
# Run the Solid test-suite
6161
- run: bash test/surface/run-solid-test-suite.sh $BRANCH_NAME $REPO_NAME
62+
- name: Save build
63+
# if: matrix.node-version == '20.x'
64+
uses: actions/upload-artifact@v5
65+
with:
66+
name: build
67+
path: |
68+
.
69+
!node_modules
70+
retention-days: 1
71+
72+
# The pipeline automate publication to npm, so that the docker build gets the correct version
73+
npm-publish-build:
74+
needs: [build]
75+
name: Publish to npm
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/download-artifact@v6
79+
with:
80+
name: build
81+
- uses: actions/setup-node@v6
82+
with:
83+
node-version: 22.x
84+
- uses: rlespinasse/github-slug-action@v3.x
85+
- name: Append commit hash to package version
86+
run: 'sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json'
87+
- name: Disable pre- and post-publish actions
88+
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
89+
- uses: JS-DevTools/npm-publish@v4.1.0
90+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
91+
with:
92+
token: ${{ secrets.NPM_TOKEN }}
93+
tag: ${{ env.GITHUB_REF_SLUG }}
94+
95+
npm-publish-latest:
96+
needs: [build, npm-publish-build]
97+
runs-on: ubuntu-latest
98+
if: github.ref == 'refs/heads/main'
99+
steps:
100+
- uses: actions/download-artifact@v6
101+
with:
102+
name: build
103+
- uses: actions/setup-node@v6
104+
with:
105+
node-version: 20.x
106+
- name: Disable pre- and post-publish actions
107+
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
108+
- uses: JS-DevTools/npm-publish@v4.1.0
109+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
110+
with:
111+
token: ${{ secrets.NPM_TOKEN }}
112+
tag: latest
62113

63-
# TODO: The pipeline should automate publication to npm, so that the docker build gets the correct version
64-
# This job will only dockerize solid-server@latest / solid-server@<tag-name> from npmjs.com!
114+
# This job will only dockerize solid-server@latest / solid-server@<tag-name> from npmjs.com!
65115
docker-hub:
66116
needs: build
67117
name: Publish to docker hub

bin/lib/cli-utils.js

Lines changed: 0 additions & 85 deletions
This file was deleted.

bin/lib/cli-utils.mjs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import fs from 'fs-extra'
2+
import { red, cyan, bold } from 'colorette'
3+
import { URL } from 'url'
4+
import LDP from '../../lib/ldp.mjs'
5+
import AccountManager from '../../lib/models/account-manager.mjs'
6+
import SolidHost from '../../lib/models/solid-host.mjs'
7+
8+
export function getAccountManager (config, options = {}) {
9+
const ldp = options.ldp || new LDP(config)
10+
const host = options.host || SolidHost.from({ port: config.port, serverUri: config.serverUri })
11+
return AccountManager.from({
12+
host,
13+
store: ldp,
14+
multiuser: config.multiuser
15+
})
16+
}
17+
18+
export function loadConfig (program, options) {
19+
let argv = {
20+
...options,
21+
version: program.version()
22+
}
23+
const configFile = argv.configFile || './config.json'
24+
try {
25+
const file = fs.readFileSync(configFile)
26+
const config = JSON.parse(file)
27+
argv = { ...config, ...argv }
28+
} catch (err) {
29+
if (typeof argv.configFile !== 'undefined') {
30+
if (!fs.existsSync(configFile)) {
31+
console.log(red(bold('ERR')), 'Config file ' + configFile + " doesn't exist.")
32+
process.exit(1)
33+
}
34+
}
35+
if (fs.existsSync(configFile)) {
36+
console.log(red(bold('ERR')), 'config file ' + configFile + " couldn't be parsed: " + err)
37+
process.exit(1)
38+
}
39+
console.log(cyan(bold('TIP')), 'create a config.json: `$ solid init`')
40+
}
41+
return argv
42+
}
43+
44+
export function loadAccounts ({ root, serverUri, hostname }) {
45+
const files = fs.readdirSync(root)
46+
hostname = hostname || new URL(serverUri).hostname
47+
const isUserDirectory = new RegExp(`.${hostname}$`)
48+
return files.filter(file => isUserDirectory.test(file))
49+
}
50+
51+
export function loadUsernames ({ root, serverUri }) {
52+
const hostname = new URL(serverUri).hostname
53+
return loadAccounts({ root, hostname }).map(userDirectory => userDirectory.substr(0, userDirectory.length - hostname.length - 1))
54+
}

bin/lib/cli.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

bin/lib/cli.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Command } from 'commander'
2+
import loadInit from './init.mjs'
3+
import loadStart from './start.mjs'
4+
import loadInvalidUsernames from './invalidUsernames.mjs'
5+
import loadMigrateLegacyResources from './migrateLegacyResources.mjs'
6+
import loadUpdateIndex from './updateIndex.mjs'
7+
import { spawnSync } from 'child_process'
8+
import path from 'path'
9+
import fs from 'fs'
10+
import { fileURLToPath } from 'url'
11+
12+
const __filename = fileURLToPath(import.meta.url)
13+
const __dirname = path.dirname(__filename)
14+
15+
export default function startCli (server) {
16+
const program = new Command()
17+
program.version(getVersion())
18+
19+
loadInit(program)
20+
loadStart(program, server)
21+
loadInvalidUsernames(program)
22+
loadMigrateLegacyResources(program)
23+
loadUpdateIndex(program)
24+
25+
program.parse(process.argv)
26+
if (program.args.length === 0) program.help()
27+
}
28+
29+
function getVersion () {
30+
try {
31+
const options = { cwd: __dirname, encoding: 'utf8' }
32+
const { stdout } = spawnSync('git', ['describe', '--tags'], options)
33+
const { stdout: gitStatusStdout } = spawnSync('git', ['status'], options)
34+
const version = stdout.trim()
35+
if (version === '' || gitStatusStdout.match('Not currently on any branch')) {
36+
throw new Error('No git version here')
37+
}
38+
return version
39+
} catch (e) {
40+
const pkgPath = path.join(__dirname, '../../package.json')
41+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
42+
return pkg.version
43+
}
44+
}

0 commit comments

Comments
 (0)