Skip to content

Commit 664faba

Browse files
authored
Update build scripts to support Windows (#1120)
* update scripts to support running on windows * configure prettier to use lf line endings * force git to checkout lf line endings * add windows ci workflow * fix cs-format script * run prettier on tests
1 parent 9abd227 commit 664faba

10 files changed

+246
-26
lines changed

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

Diff for: .github/workflows/windows-ci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
7+
name: Windows Integration
8+
jobs:
9+
chore:
10+
name: Testing on Windows
11+
runs-on: windows-latest
12+
13+
steps:
14+
- uses: actions/checkout@master
15+
16+
- name: Print environment
17+
run: |
18+
node --version
19+
npm --version
20+
python --version
21+
pip --version
22+
- name: Install Node dependencies
23+
run: npm ci
24+
25+
- name: Install Python dependencies
26+
run: pip install kinto kinto-attachment
27+
28+
- name: Run tests
29+
run: npm test

Diff for: .prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"trailingComma": "es5"
2+
"trailingComma": "es5",
3+
"endOfLine": "lf"
34
}

Diff for: bin/dist-fx.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { mkdir, cp, exec, echo, cat, rm } from "shelljs";
2+
import { readFileSync } from "fs";
3+
4+
function getVersionFromPackageJson(): string {
5+
const pkgJson = readFileSync("package.json", "utf8");
6+
const { version } = JSON.parse(pkgJson);
7+
return version;
8+
}
9+
10+
const rollupOutput = "dist/temp.js";
11+
const destination = "dist/moz-kinto-offline-client.js";
12+
13+
mkdir("-p", "dist");
14+
15+
cp("fx-src/jsm_prefix.js", destination);
16+
17+
const gitRev = exec("git rev-parse --short HEAD", {
18+
silent: true,
19+
}).stdout.trim();
20+
const version = getVersionFromPackageJson();
21+
22+
echo(`\n/*\n * Version ${version} - ${gitRev}\n */\n`).toEnd(destination);
23+
cat(rollupOutput).toEnd(destination);
24+
rm(rollupOutput);

Diff for: package-lock.json

+128
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"build": "npm run build:es && npm run build:cjs-es5",
1010
"build:es": "tsc -p .",
1111
"build:cjs-es5": "tsc -p . --outDir lib/cjs-es5 --module commonjs --target es5",
12-
"build-demo": "npm run dist && cp dist/kinto.min.js demo/kinto.min.js && cp dist/kinto.min.js.map demo/kinto.min.js.map",
12+
"build-demo": "npm run dist && shx cp dist/kinto.min.js demo/kinto.min.js && shx cp dist/kinto.min.js.map demo/kinto.min.js.map",
1313
"compute-sri": "version=$(npm view kinto version); printf \"| Filename %-14s | Hash %-66s |\\n\" \"\" \"(for version $version)\"; printf \"|-------------------------|-------------------------------------------------------------------------|\\n\"; cd dist; for file in kinto*.js; do printf \"| %-23s | %-71s |\\n\" ${file} $(echo -n 'sha384-' && curl --silent https://unpkg.com/kinto@$version/dist/${file} | openssl dgst -sha384 -binary | openssl enc -base64); done",
14-
"cs-check": "prettier '{src,test}/**/*.js'",
15-
"cs-format": "prettier '{src,test}/**/*.js' --write",
14+
"cs-check": "prettier -l \"{src,test,bin}/**/*.{js,ts}\"",
15+
"cs-format": "prettier \"{src,test,bin}/**/*.{js,ts}\" --write",
1616
"demo": "npm run build-demo && http-server demo",
17-
"dist": "NODE_ENV=production rollup -c && npm run dist:fx",
17+
"dist": "cross-env NODE_ENV=production rollup -c && npm run dist:fx",
1818
"dist:dev": "rollup -c && npm run dist:fx",
19-
"dist:fx": "mkdir -p dist && cp fx-src/jsm_prefix.js dist/moz-kinto-offline-client.js && echo \"\n/*\n * Version $npm_package_version - $(git rev-parse --short HEAD)\n */\n\" >> dist/moz-kinto-offline-client.js && cat dist/temp.js >> dist/moz-kinto-offline-client.js && rm dist/temp.js && echo >> dist/moz-kinto-offline-client.js",
19+
"dist:fx": "ts-node --skip-project bin/dist-fx.ts",
2020
"lint": "eslint src test",
2121
"publish-demo": "npm run dist-prod && cp dist/kinto.js demo/kinto.js && gh-pages -d demo",
2222
"publish-to-npm": "npm run dist && npm run build && npm publish",
@@ -25,9 +25,8 @@
2525
"test": "npm run lint && npm run test-nocover",
2626
"test-cover": "nyc --reporter=lcov --reporter=text-summary --report-dir=coverage npm run test-nocover",
2727
"test-cover-html": "nyc --reporter=html --report-dir=coverage npm run test-nocover && open coverage/index.html",
28-
"test-nocover": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\",\"sourceMap\":true}' mocha -r ts-node/register --require source-map-support/register --full-trace --bail --require ./test/_setup.js 'test/**/*_test.js'"
28+
"test-nocover": "cross-env TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\":\\\"commonjs\\\",\\\"sourceMap\\\":true}\" mocha -r ts-node/register --require source-map-support/register --full-trace --bail --require ./test/_setup.js \"test/**/*_test.{js,ts}\""
2929
},
30-
"prettierOptions": "--trailing-comma es5",
3130
"repository": {
3231
"type": "git",
3332
"url": "https://github.com/Kinto/kinto.js.git"
@@ -140,12 +139,14 @@
140139
"uuid": "^3.0.0"
141140
},
142141
"devDependencies": {
142+
"@types/shelljs": "^0.8.6",
143143
"@typescript-eslint/eslint-plugin": "^2.2.0",
144144
"@typescript-eslint/parser": "^2.2.0",
145145
"chai": "^4.0.1",
146146
"chai-as-promised": "^7.0.0",
147147
"co-task": "^1.0.0",
148148
"coveralls": "^3.0.0",
149+
"cross-env": "^6.0.3",
149150
"esdoc": "^1.0.1",
150151
"esdoc-accessor-plugin": "^1.0.0",
151152
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
@@ -173,6 +174,8 @@
173174
"rollup-plugin-node-resolve": "^5.2.0",
174175
"rollup-plugin-terser": "^5.1.1",
175176
"rollup-plugin-typescript": "^1.0.1",
177+
"shelljs": "^0.8.3",
178+
"shx": "^0.3.2",
176179
"sinon": "^7.2.3",
177180
"source-map-support": "^0.5.13",
178181
"ts-node": "^8.3.0",

Diff for: test/adapters/IDB_test.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,10 @@ describe("adapter.IDB", () => {
396396

397397
describe("multiple values", () => {
398398
it("should filter the list on a single pre-indexed column", () => {
399-
return db
400-
.list({ filters: { id: [5, 4] } })
401-
.should.eventually.eql([
402-
{ id: 4, name: "#4" },
403-
{ id: 5, name: "#5" },
404-
]);
399+
return db.list({ filters: { id: [5, 4] } }).should.eventually.eql([
400+
{ id: 4, name: "#4" },
401+
{ id: 5, name: "#5" },
402+
]);
405403
});
406404

407405
it("should filter the list combined with other filters", () => {
@@ -504,15 +502,24 @@ describe("adapter.IDB", () => {
504502
describe("#importBulk", () => {
505503
it("should import a list of records.", () => {
506504
return db
507-
.importBulk([{ id: 1, foo: "bar" }, { id: 2, foo: "baz" }])
505+
.importBulk([
506+
{ id: 1, foo: "bar" },
507+
{ id: 2, foo: "baz" },
508+
])
508509
.should.eventually.have.length(2);
509510
});
510511

511512
it("should override existing records.", () => {
512513
return db
513-
.importBulk([{ id: 1, foo: "bar" }, { id: 2, foo: "baz" }])
514+
.importBulk([
515+
{ id: 1, foo: "bar" },
516+
{ id: 2, foo: "baz" },
517+
])
514518
.then(() => {
515-
return db.importBulk([{ id: 1, foo: "baz" }, { id: 3, foo: "bab" }]);
519+
return db.importBulk([
520+
{ id: 1, foo: "baz" },
521+
{ id: 3, foo: "bab" },
522+
]);
516523
})
517524
.then(() => db.list())
518525
.should.eventually.eql([

Diff for: test/collection_test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,10 @@ describe("Collection", () => {
419419
it("should deduplicate added entries with same id", () => {
420420
const result = new SyncResultObject();
421421

422-
result.add("created", [{ id: 1, name: "a" }, { id: 1, name: "b" }]);
422+
result.add("created", [
423+
{ id: 1, name: "a" },
424+
{ id: 1, name: "b" },
425+
]);
423426
expect(result.created).eql([{ id: 1, name: "b" }]);
424427
});
425428

0 commit comments

Comments
 (0)