ol-stac 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.github/workflows/deploy.yml +67 -0
- package/.github/workflows/publish.yml +32 -0
- package/.github/workflows/release.yml +21 -0
- package/.github/workflows/test.yml +85 -0
- package/CHANGELOG.md +14 -0
- package/DEVELOPING.md +104 -0
- package/LICENSE.md +201 -0
- package/README.md +43 -0
- package/config/jsdoc/api/conf.json +38 -0
- package/config/jsdoc/api/index.md +1 -0
- package/config/jsdoc/api/readme.md +65 -0
- package/config/jsdoc/api/template/README.md +3 -0
- package/config/jsdoc/api/template/publish.js +743 -0
- package/config/jsdoc/api/template/static/scripts/linenumber.js +11 -0
- package/config/jsdoc/api/template/static/scripts/main.js +305 -0
- package/config/jsdoc/api/template/static/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/config/jsdoc/api/template/static/scripts/prettify/lang-css.js +2 -0
- package/config/jsdoc/api/template/static/scripts/prettify/prettify.js +28 -0
- package/config/jsdoc/api/template/static/styles/carbon.css +65 -0
- package/config/jsdoc/api/template/static/styles/jaguar.css +512 -0
- package/config/jsdoc/api/template/static/styles/prettify-jsdoc.css +111 -0
- package/config/jsdoc/api/template/static/styles/prettify-tomorrow.css +132 -0
- package/config/jsdoc/api/template/static/theme +1 -0
- package/config/jsdoc/api/template/tmpl/container.tmpl +205 -0
- package/config/jsdoc/api/template/tmpl/details.tmpl +84 -0
- package/config/jsdoc/api/template/tmpl/example.tmpl +2 -0
- package/config/jsdoc/api/template/tmpl/examples.tmpl +16 -0
- package/config/jsdoc/api/template/tmpl/exceptions.tmpl +30 -0
- package/config/jsdoc/api/template/tmpl/layout.tmpl +92 -0
- package/config/jsdoc/api/template/tmpl/mainpage.tmpl +14 -0
- package/config/jsdoc/api/template/tmpl/members.tmpl +38 -0
- package/config/jsdoc/api/template/tmpl/method.tmpl +132 -0
- package/config/jsdoc/api/template/tmpl/navigation.tmpl +59 -0
- package/config/jsdoc/api/template/tmpl/observables.tmpl +39 -0
- package/config/jsdoc/api/template/tmpl/params.tmpl +109 -0
- package/config/jsdoc/api/template/tmpl/properties.tmpl +85 -0
- package/config/jsdoc/api/template/tmpl/returns.tmpl +72 -0
- package/config/jsdoc/api/template/tmpl/source.tmpl +8 -0
- package/config/jsdoc/api/template/tmpl/stability.tmpl +7 -0
- package/config/jsdoc/api/template/tmpl/tutorial.tmpl +19 -0
- package/config/jsdoc/api/template/tmpl/type.tmpl +7 -0
- package/config/jsdoc/info/conf.json +22 -0
- package/config/jsdoc/info/publish.js +175 -0
- package/config/jsdoc/package.json +4 -0
- package/config/jsdoc/plugins/api.cjs +181 -0
- package/config/jsdoc/plugins/default-export.cjs +35 -0
- package/config/jsdoc/plugins/define-plugin.cjs +33 -0
- package/config/jsdoc/plugins/events.cjs +39 -0
- package/config/jsdoc/plugins/inline-options.cjs +102 -0
- package/config/jsdoc/plugins/markdown.cjs +119 -0
- package/config/jsdoc/plugins/observable.cjs +69 -0
- package/config/jsdoc/plugins/virtual-plugin.cjs +16 -0
- package/config/rollup-full-build.js +24 -0
- package/config/tsconfig-build.json +25 -0
- package/examples/.eslintrc +29 -0
- package/examples/index.html +100 -0
- package/examples/index.js +109 -0
- package/examples/planetary-computer.html +14 -0
- package/examples/planetary-computer.js +53 -0
- package/examples/resources/Jugl.js +15 -0
- package/examples/resources/common.js +111 -0
- package/examples/stac-collection-webmaplinks.html +9 -0
- package/examples/stac-collection-webmaplinks.js +55 -0
- package/examples/stac-item-from-object.html +9 -0
- package/examples/stac-item-from-object.js +102 -0
- package/examples/stac-item-tileserver.html +9 -0
- package/examples/stac-item-tileserver.js +34 -0
- package/examples/stac-item.html +9 -0
- package/examples/stac-item.js +45 -0
- package/examples/stac-itemcollection.html +11 -0
- package/examples/stac-itemcollection.js +39 -0
- package/examples/templates/example.html +206 -0
- package/examples/templates/readme.md +3 -0
- package/examples/webpack/config.mjs +69 -0
- package/examples/webpack/example-builder.js +410 -0
- package/package.json +107 -0
- package/site/build.js +26 -0
- package/site/layouts/default.hbs +78 -0
- package/site/src/doc/faq.md +8 -0
- package/site/src/doc/index.md +22 -0
- package/site/src/doc/quickstart.md +121 -0
- package/site/src/doc/tutorials/index.md +8 -0
- package/site/src/download/index.hbs +62 -0
- package/site/src/favicon.ico +0 -0
- package/site/src/index.hbs +71 -0
- package/site/src/theme/index.css +26 -0
- package/site/src/theme/site.css +531 -0
- package/src/ol/events/ErrorEvent.js +25 -0
- package/src/ol/layer/STAC.js +780 -0
- package/src/ol/layer/stacUtil.js +169 -0
- package/src/ol/source/GeoTIFF2.js +47 -0
- package/tasks/.eslintrc +5 -0
- package/tasks/build-website.sh +90 -0
- package/tasks/create-release.js +107 -0
- package/tasks/generate-index.js +125 -0
- package/tasks/generate-info.js +189 -0
- package/tasks/get-latest-release.js +36 -0
- package/tasks/newest-tag.js +52 -0
- package/tasks/prepare-package.js +46 -0
- package/tasks/publish.sh +90 -0
- package/test/README.md +56 -0
- package/test/browser/.eslintrc +14 -0
- package/test/browser/karma.config.cjs +94 -0
- package/test/browser/spec/ol/layer/STAC.test.js +18 -0
- package/test/browser/test-extensions.js +419 -0
- package/tsconfig.json +62 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import esMain from 'es-main';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import path, {dirname} from 'path';
|
|
4
|
+
import {fileURLToPath} from 'url';
|
|
5
|
+
import {spawn} from 'child_process';
|
|
6
|
+
import {walk} from 'walk';
|
|
7
|
+
|
|
8
|
+
const isWindows = process.platform.startsWith('win');
|
|
9
|
+
const baseDir = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
const sourceDir = path.join(baseDir, '..', 'src');
|
|
12
|
+
const infoPath = path.join(baseDir, '..', 'build', 'info.json');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get checked path of a binary.
|
|
16
|
+
* @param {string} binaryName Binary name of the binary path to find.
|
|
17
|
+
* @return {string} Path.
|
|
18
|
+
*/
|
|
19
|
+
function getBinaryPath(binaryName) {
|
|
20
|
+
if (isWindows) {
|
|
21
|
+
binaryName += '.cmd';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const jsdocResolved = path.join(
|
|
25
|
+
baseDir,
|
|
26
|
+
'..',
|
|
27
|
+
'node_modules',
|
|
28
|
+
'jsdoc',
|
|
29
|
+
'jsdoc.js'
|
|
30
|
+
);
|
|
31
|
+
const expectedPaths = [
|
|
32
|
+
path.join(baseDir, '..', 'node_modules', '.bin', binaryName),
|
|
33
|
+
path.resolve(
|
|
34
|
+
path.join(path.dirname(jsdocResolved), '..', '.bin', binaryName)
|
|
35
|
+
),
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < expectedPaths.length; i++) {
|
|
39
|
+
const expectedPath = expectedPaths[i];
|
|
40
|
+
if (fse.existsSync(expectedPath)) {
|
|
41
|
+
return expectedPath;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw Error(
|
|
46
|
+
'JsDoc binary was not found in any of the expected paths: ' + expectedPaths
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const jsdoc = getBinaryPath('jsdoc');
|
|
51
|
+
|
|
52
|
+
const jsdocConfig = path.join(
|
|
53
|
+
baseDir,
|
|
54
|
+
'..',
|
|
55
|
+
'config',
|
|
56
|
+
'jsdoc',
|
|
57
|
+
'info',
|
|
58
|
+
'conf.json'
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Generate a list of all .js paths in the source directory.
|
|
63
|
+
* @return {Promise<Array>} Resolves to an array of source paths.
|
|
64
|
+
*/
|
|
65
|
+
function getPaths() {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
let paths = [];
|
|
68
|
+
|
|
69
|
+
const walker = walk(sourceDir);
|
|
70
|
+
walker.on('file', (root, stats, next) => {
|
|
71
|
+
const sourcePath = path.join(root, stats.name);
|
|
72
|
+
if (sourcePath.endsWith('.js')) {
|
|
73
|
+
paths.push(sourcePath);
|
|
74
|
+
}
|
|
75
|
+
next();
|
|
76
|
+
});
|
|
77
|
+
walker.on('errors', () => {
|
|
78
|
+
reject(new Error(`Trouble walking ${sourceDir}`));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
walker.on('end', () => {
|
|
82
|
+
/**
|
|
83
|
+
* Windows has restrictions on length of command line, so passing all the
|
|
84
|
+
* changed paths to a task will fail if this limit is exceeded.
|
|
85
|
+
* To get round this, if this is Windows and there are newer files, just
|
|
86
|
+
* pass the sourceDir to the task so it can do the walking.
|
|
87
|
+
*/
|
|
88
|
+
if (isWindows) {
|
|
89
|
+
paths = [sourceDir];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
resolve(paths);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Parse the JSDoc output.
|
|
99
|
+
* @param {string} output JSDoc output
|
|
100
|
+
* @return {Object} Symbol and define info.
|
|
101
|
+
*/
|
|
102
|
+
function parseOutput(output) {
|
|
103
|
+
if (!output) {
|
|
104
|
+
throw new Error('Expected JSON output');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let info;
|
|
108
|
+
try {
|
|
109
|
+
info = JSON.parse(String(output));
|
|
110
|
+
} catch (err) {
|
|
111
|
+
throw new Error('Failed to parse output as JSON: ' + output);
|
|
112
|
+
}
|
|
113
|
+
if (!Array.isArray(info.symbols)) {
|
|
114
|
+
throw new Error('Expected symbols array: ' + output);
|
|
115
|
+
}
|
|
116
|
+
if (!Array.isArray(info.defines)) {
|
|
117
|
+
throw new Error('Expected defines array: ' + output);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return info;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Spawn JSDoc.
|
|
125
|
+
* @param {Array<string>} paths Paths to source files.
|
|
126
|
+
* @return {Promise<string>} Resolves with the JSDoc output (new metadata).
|
|
127
|
+
* If provided with an empty list of paths, resolves with null.
|
|
128
|
+
*/
|
|
129
|
+
function spawnJSDoc(paths) {
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
let output = '';
|
|
132
|
+
let errors = '';
|
|
133
|
+
const cwd = path.join(baseDir, '..');
|
|
134
|
+
const child = spawn(jsdoc, ['-c', jsdocConfig].concat(paths), {cwd: cwd});
|
|
135
|
+
|
|
136
|
+
child.stdout.on('data', (data) => {
|
|
137
|
+
output += String(data);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
child.stderr.on('data', (data) => {
|
|
141
|
+
errors += String(data);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
child.on('exit', (code) => {
|
|
145
|
+
if (code) {
|
|
146
|
+
reject(new Error(errors || 'JSDoc failed with no output'));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
let info;
|
|
151
|
+
try {
|
|
152
|
+
info = parseOutput(output);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
reject(err);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
resolve(info);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Writes the info.json file.
|
|
164
|
+
* @param {Object} info The info.
|
|
165
|
+
* @return {Promise} Resolves on completion.
|
|
166
|
+
*/
|
|
167
|
+
async function write(info) {
|
|
168
|
+
await fse.outputJson(infoPath, info, {spaces: 2});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Generate info from the sources.
|
|
173
|
+
* @return {Promise<Error>} Resolves with the info object.
|
|
174
|
+
*/
|
|
175
|
+
export default async function main() {
|
|
176
|
+
const paths = await getPaths();
|
|
177
|
+
return await spawnJSDoc(paths);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* If running this module directly, generate and write out the info.json file.
|
|
182
|
+
*/
|
|
183
|
+
if (esMain(import.meta)) {
|
|
184
|
+
main()
|
|
185
|
+
.then(write)
|
|
186
|
+
.catch((err) => {
|
|
187
|
+
process.stderr.write(`${err.message}\n`, () => process.exit(1));
|
|
188
|
+
});
|
|
189
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import esMain from 'es-main';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import {Octokit} from '@octokit/rest';
|
|
4
|
+
|
|
5
|
+
export async function getLatestRelease() {
|
|
6
|
+
const client = new Octokit();
|
|
7
|
+
|
|
8
|
+
let latest = '0.0.0';
|
|
9
|
+
await client.paginate(
|
|
10
|
+
client.rest.repos.listReleases,
|
|
11
|
+
{
|
|
12
|
+
owner: 'm-mohr',
|
|
13
|
+
repo: 'ol-stac',
|
|
14
|
+
},
|
|
15
|
+
(response) => {
|
|
16
|
+
for (const release of response.data) {
|
|
17
|
+
const version = semver.valid(release.name);
|
|
18
|
+
if (version && semver.gt(version, latest)) {
|
|
19
|
+
latest = version;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return latest;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (esMain(import.meta)) {
|
|
29
|
+
getLatestRelease()
|
|
30
|
+
.then((latest) => {
|
|
31
|
+
process.stdout.write(`v${latest}\n`, () => process.exit(0));
|
|
32
|
+
})
|
|
33
|
+
.catch((err) => {
|
|
34
|
+
process.stderr.write(`${err.message}\n`, () => process.exit(1));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import esMain from 'es-main';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import yargs from 'yargs';
|
|
4
|
+
import {getLatestRelease} from './get-latest-release.js';
|
|
5
|
+
import {hideBin} from 'yargs/helpers';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} Options
|
|
9
|
+
* @property {string} tag The tag.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if a tag is ahead of the latest release.
|
|
14
|
+
* @param {Options} options The options.
|
|
15
|
+
* @return {boolean} The provided tag is ahead of or equal to the latest release.
|
|
16
|
+
*/
|
|
17
|
+
async function main(options) {
|
|
18
|
+
const version = semver.valid(options.tag);
|
|
19
|
+
if (!version) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const parsed = semver.parse(version);
|
|
24
|
+
if (parsed.prerelease.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const latest = await getLatestRelease();
|
|
29
|
+
return semver.gte(version, latest);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (esMain(import.meta)) {
|
|
33
|
+
const options = yargs(hideBin(process.argv))
|
|
34
|
+
.option('tag', {
|
|
35
|
+
describe: 'The tag to test (e.g. v1.2.3)',
|
|
36
|
+
type: 'string',
|
|
37
|
+
})
|
|
38
|
+
.demandOption('tag')
|
|
39
|
+
.parse();
|
|
40
|
+
|
|
41
|
+
main(options)
|
|
42
|
+
.then((newest) => {
|
|
43
|
+
if (newest) {
|
|
44
|
+
process.stdout.write('true\n', () => process.exit(0));
|
|
45
|
+
} else {
|
|
46
|
+
process.stderr.write('false\n', () => process.exit(1));
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
.catch((err) => {
|
|
50
|
+
process.stderr.write(`${err.stack}\n`, () => process.exit(1));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import esMain from 'es-main';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import path, {dirname} from 'path';
|
|
4
|
+
import {fileURLToPath} from 'url';
|
|
5
|
+
|
|
6
|
+
const baseDir = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const buildDir = path.resolve(baseDir, '../build/ol');
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
const pkg = await fse.readJSON(path.resolve(baseDir, '../package.json'));
|
|
11
|
+
|
|
12
|
+
// write out simplified package.json
|
|
13
|
+
pkg.main = 'index.js';
|
|
14
|
+
delete pkg.scripts;
|
|
15
|
+
delete pkg.devDependencies;
|
|
16
|
+
delete pkg.style;
|
|
17
|
+
delete pkg.eslintConfig;
|
|
18
|
+
delete pkg.private;
|
|
19
|
+
await fse.writeJSON(path.join(buildDir, 'package.json'), pkg, {spaces: 2});
|
|
20
|
+
|
|
21
|
+
// copy in readme and license files
|
|
22
|
+
await fse.copyFile(
|
|
23
|
+
path.resolve(baseDir, '../README.md'),
|
|
24
|
+
path.join(buildDir, 'README.md')
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
await fse.copyFile(
|
|
28
|
+
path.resolve(baseDir, '../LICENSE.md'),
|
|
29
|
+
path.join(buildDir, 'LICENSE.md')
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
await fse.copy(
|
|
33
|
+
path.resolve(baseDir, '../build/full/'),
|
|
34
|
+
path.join(buildDir, 'dist')
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If running this module directly, read the config file, call the main
|
|
40
|
+
* function, and write the output file.
|
|
41
|
+
*/
|
|
42
|
+
if (esMain(import.meta)) {
|
|
43
|
+
main().catch((err) => {
|
|
44
|
+
process.stderr.write(`${err.message}\n`, () => process.exit(1));
|
|
45
|
+
});
|
|
46
|
+
}
|
package/tasks/publish.sh
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Run this script to publish a new version of the library to npm. This requires
|
|
5
|
+
# that you have a clean working directory and have created a tag that matches
|
|
6
|
+
# the version number in package.json.
|
|
7
|
+
#
|
|
8
|
+
set -o errexit
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Destination directory for the package.
|
|
12
|
+
#
|
|
13
|
+
BUILT_PACKAGE=build/ol
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# URL for canonical repo.
|
|
17
|
+
#
|
|
18
|
+
REMOTE=https://github.com/m-mohr/ol-stac.git
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
# Display usage and exit.
|
|
22
|
+
#
|
|
23
|
+
display_usage() {
|
|
24
|
+
cat <<-EOF
|
|
25
|
+
|
|
26
|
+
Usage: ${1} <version> [options]
|
|
27
|
+
|
|
28
|
+
To publish a new release, update the version number in package.json and
|
|
29
|
+
create a tag for the release.
|
|
30
|
+
|
|
31
|
+
The tag name must match the version number prefixed by a "v" (for example,
|
|
32
|
+
version 3.2.1 would be tagged v3.2.1).
|
|
33
|
+
|
|
34
|
+
The tag must be pushed to ${REMOTE} before the release can be published.
|
|
35
|
+
|
|
36
|
+
Additional args after <version> will be passed to "npm publish" (e.g. "--tag beta").
|
|
37
|
+
|
|
38
|
+
EOF
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Exit if the current working tree is not clean.
|
|
43
|
+
#
|
|
44
|
+
assert_clean() {
|
|
45
|
+
source `git --exec-path`/git-sh-setup && \
|
|
46
|
+
require_clean_work_tree "publish" "Please commit or stash them."
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Exit if the requested version doesn't match package.json.
|
|
51
|
+
#
|
|
52
|
+
assert_version_match() {
|
|
53
|
+
v=`grep -o '"version":.*' package.json | sed 's/"version": *"\(.*\)",/\1/'`
|
|
54
|
+
if test "${1}" != "${v}"; then
|
|
55
|
+
echo "Version mismatch: requested '${1}', but package.json specifies '${v}'"
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#
|
|
61
|
+
# Check out the provided tag. This ensures that the tag has been pushed to
|
|
62
|
+
# the canonical remote.
|
|
63
|
+
#
|
|
64
|
+
checkout_tag() {
|
|
65
|
+
git fetch ${REMOTE} refs/tags/v${1}:refs/tags/v${1}
|
|
66
|
+
git checkout refs/tags/v${1}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#
|
|
70
|
+
# Build the package and publish.
|
|
71
|
+
#
|
|
72
|
+
main() {
|
|
73
|
+
root=$(cd -P -- "$(dirname -- "${0}")" && pwd -P)/..
|
|
74
|
+
cd ${root}
|
|
75
|
+
assert_clean
|
|
76
|
+
checkout_tag ${1}
|
|
77
|
+
assert_version_match ${1}
|
|
78
|
+
npm install
|
|
79
|
+
npm run build-package
|
|
80
|
+
cd ${BUILT_PACKAGE}
|
|
81
|
+
shift
|
|
82
|
+
npm publish ${@}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if test ${#} -lt 1; then
|
|
86
|
+
display_usage ${0}
|
|
87
|
+
exit 1
|
|
88
|
+
else
|
|
89
|
+
main ${@}
|
|
90
|
+
fi
|
package/test/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
## Included in this directory
|
|
2
|
+
|
|
3
|
+
- browser - Unit/integration tests run in a browser
|
|
4
|
+
- node - Unit tests run with Node.js
|
|
5
|
+
- rendering - Tests that make assertions about rendered map output
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Run the test suite
|
|
9
|
+
|
|
10
|
+
Install the test dependencies (from the root of the repository):
|
|
11
|
+
|
|
12
|
+
npm install
|
|
13
|
+
|
|
14
|
+
Run the tests once:
|
|
15
|
+
|
|
16
|
+
npm test
|
|
17
|
+
|
|
18
|
+
This will run tests in (headless) Chrome. If you do not have Chrome installed, you can run tests on Firefox instead:
|
|
19
|
+
|
|
20
|
+
npm test -- --browsers Firefox
|
|
21
|
+
|
|
22
|
+
To run tests in other browsers, you need to install [additional Karma launchers](https://karma-runner.github.io/1.0/config/browsers.html).
|
|
23
|
+
|
|
24
|
+
To run the tests continuously:
|
|
25
|
+
|
|
26
|
+
npm run karma
|
|
27
|
+
|
|
28
|
+
After this, you can attach any browser and debug the tests like this:
|
|
29
|
+
|
|
30
|
+
* open http://localhost:9876/debug.html
|
|
31
|
+
* open the developer tools
|
|
32
|
+
* add a breakpoint
|
|
33
|
+
* refresh the page
|
|
34
|
+
|
|
35
|
+
# Rendering tests
|
|
36
|
+
|
|
37
|
+
The `test/rendering` directory contains rendering tests which compare a rendered map with a
|
|
38
|
+
reference image using [pixelmatch](https://github.com/mapbox/pixelmatch).
|
|
39
|
+
|
|
40
|
+
To run the tests in the browser, make sure the development server is running
|
|
41
|
+
(`make serve`) and open the URL
|
|
42
|
+
[http://localhost:3000/test_rendering/index.html](http://localhost:3000/test_rendering/index.html).
|
|
43
|
+
|
|
44
|
+
From the command-line the tests can be run with the build target `make test-rendering`.
|
|
45
|
+
|
|
46
|
+
## Adding new tests
|
|
47
|
+
When creating a new test case, a reference image has to be created. By appending `?generate`
|
|
48
|
+
to the URL, a canvas with the rendered map will be shown on the page when calling
|
|
49
|
+
`expectResemble`. Then the reference image can simply be created with a right-click
|
|
50
|
+
and "Save image as".
|
|
51
|
+
|
|
52
|
+
It is recommended to only run a single test case when generating the reference image.
|
|
53
|
+
|
|
54
|
+
## Image difference
|
|
55
|
+
When a test fails, an image showing the difference between the reference image and the
|
|
56
|
+
rendered map can be displayed by appending `?showdiff` to the URL.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable import/no-commonjs */
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
module.exports = function (karma) {
|
|
6
|
+
karma.set({
|
|
7
|
+
browsers: ['ChromeHeadlessLauncher'],
|
|
8
|
+
customLaunchers: {
|
|
9
|
+
ChromeHeadlessLauncher: {
|
|
10
|
+
base: 'Chrome',
|
|
11
|
+
flags: ['--headless=new'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
browserDisconnectTolerance: 2,
|
|
15
|
+
frameworks: ['webpack', 'mocha', 'source-map-support'],
|
|
16
|
+
client: {
|
|
17
|
+
runInParent: true,
|
|
18
|
+
mocha: {
|
|
19
|
+
timeout: 2500,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
files: [
|
|
23
|
+
{
|
|
24
|
+
pattern: path.resolve(__dirname, require.resolve('expect.js/index.js')),
|
|
25
|
+
watched: false,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pattern: path.resolve(
|
|
29
|
+
__dirname,
|
|
30
|
+
require.resolve('../../node_modules/sinon/pkg/sinon.js')
|
|
31
|
+
),
|
|
32
|
+
watched: false,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
pattern: path.resolve(
|
|
36
|
+
__dirname,
|
|
37
|
+
require.resolve('ol/dist/ol.js')
|
|
38
|
+
),
|
|
39
|
+
watched: false,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
pattern: path.resolve(
|
|
43
|
+
__dirname,
|
|
44
|
+
require.resolve('proj4/dist/proj4.js')
|
|
45
|
+
),
|
|
46
|
+
watched: false,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: path.resolve(__dirname, './test-extensions.js'),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
pattern: 'spec/**/*.test.js',
|
|
53
|
+
watched: false,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
pattern: '**/*',
|
|
57
|
+
included: false,
|
|
58
|
+
watched: false,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
proxies: {
|
|
62
|
+
'/spec/': '/base/spec/'
|
|
63
|
+
},
|
|
64
|
+
preprocessors: {
|
|
65
|
+
'**/*.js': ['webpack'], //, 'sourcemap'],
|
|
66
|
+
},
|
|
67
|
+
reporters: ['dots'],
|
|
68
|
+
webpack: {
|
|
69
|
+
devtool: 'inline-source-map',
|
|
70
|
+
mode: 'development',
|
|
71
|
+
resolve: {
|
|
72
|
+
fallback: {
|
|
73
|
+
fs: false,
|
|
74
|
+
http: false,
|
|
75
|
+
https: false,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
module: {
|
|
79
|
+
rules: [
|
|
80
|
+
{
|
|
81
|
+
test: /\.js$/,
|
|
82
|
+
enforce: 'pre',
|
|
83
|
+
use: ['source-map-loader'],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
webpackMiddleware: {
|
|
89
|
+
noInfo: true,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
process.env.CHROME_BIN = require('puppeteer').executablePath();
|
|
94
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import STAC from '../../../../../src/ol/layer/STAC.js';
|
|
2
|
+
|
|
3
|
+
describe('ol/layer/STAC', function () {
|
|
4
|
+
describe('constructor (defaults)', function () {
|
|
5
|
+
/** @type {STAC} */
|
|
6
|
+
let group;
|
|
7
|
+
|
|
8
|
+
beforeEach(function () {
|
|
9
|
+
group = new STAC({
|
|
10
|
+
url: 'https://s3.us-west-2.amazonaws.com/sentinel-cogs/sentinel-s2-l2a-cogs/10/T/ES/2022/7/S2A_10TES_20220726_0_L2A/S2A_10TES_20220726_0_L2A.json',
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('creates an instance', function () {
|
|
15
|
+
expect(group).to.be.a(STAC);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|