Skip to content

Commit

Permalink
build: 🔧 use best practices for package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 14, 2024
1 parent fdef8dd commit 713d07e
Show file tree
Hide file tree
Showing 40 changed files with 82 additions and 110 deletions.
5 changes: 1 addition & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
"proseWrap": "always",
"htmlWhitespaceSensitivity": "ignore",
"endOfLine": "lf",
"embeddedLanguageFormatting": "off",
"plugins": [
"prettier-plugin-organize-imports"
]
"embeddedLanguageFormatting": "off"
}
8 changes: 2 additions & 6 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

Run the examples using tsx as below:

## TypeScript
npx tsx ./examples/tle.ts

npx tsx ./examples/typescript/satellite-js-migration.ts

## JavaScript

npx tsx ./examples/javascript/satellite-js-migration.mjs
npx tsx ./examples/satellite-js-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable multiline-comment-style */
/* eslint-disable no-console */

import { calcGmst, DEG2RAD, GroundPosition, Satellite, Sgp4 } from '../../dist/index.js';
import { calcGmst, DEG2RAD, GroundPosition, Satellite, Sgp4 } from '../dist/main.js';

// Example Date
const exampleDate = new Date(1705109326817);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Sgp4,
TleLine1,
TleLine2,
} from '../../lib/index';
} from '../dist/main';

// Example Date
const exampleDate = new Date(1705109326817);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "ootk-core",
"version": "1.0.0-3",
"type": "module",
"module": "dist/main.js",
"description": "Orbital Object Toolkit. A modern typed replacement for satellite.js including SGP4 propagation, TLE parsing, Sun and Moon calculations, and more.",
"scripts": {
"build": "node ./scripts/cleanup.mjs && npx tsc -p tsconfig.build.json -m esnext",
Expand All @@ -11,12 +12,8 @@
"test:coverage": "jest --coverage",
"version": "auto-changelog -p && git add CHANGELOG.md"
},
"main": "./lib/index.js",
"exports": {
"import": "./lib/index.js",
"require": "./commonjs/index.js"
},
"typings": "./lib/index.d.ts",
"main": "dist/main.js",
"typings": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/thkruz/ootk-core"
Expand Down Expand Up @@ -49,9 +46,8 @@
"eslint": "^8.56.0",
"jest": "^28.1.3",
"prettier": "^3.2.1",
"prettier-plugin-organize-imports": "^3.2.3",
"tsx": "^4.7.0",
"typescript": "^4.9.5"
},
"homepage": "https://github.com/thkruz/ootk"
}
"homepage": "https://github.com/thkruz/ootk-core"
}
4 changes: 2 additions & 2 deletions scripts/cleanup.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-console */
import { rmSync } from 'fs';

console.log('Removing ./lib...');
console.log('Removing ./dist...');
try {
rmSync('./lib', { recursive: true });
rmSync('./dist', { recursive: true });
} catch (error) {
// Intentionally left blank
}
2 changes: 1 addition & 1 deletion src/body/Celestial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sun, RAD2DEG, AzEl, Degrees, Kilometers, RaDec, Radians } from '..';
import { AzEl, Degrees, Kilometers, RAD2DEG, RaDec, Radians, Sun } from '../main';

/**
* Celestial is a static class that provides methods for calculating the position of celestial objects such
Expand Down
16 changes: 8 additions & 8 deletions src/body/Earth.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {
earthGravityParam,
angularDiameter,
evalPoly,
AngularDiameterMethod,
asec2rad,
DataHandler,
DEG2RAD,
earthGravityParam,
EpochUTC,
evalPoly,
Kilometers,
RAD2DEG,
Radians,
secondsPerDay,
secondsPerSiderealDay,
TAU,
ttasec2rad,
EpochUTC,
Vector3D,
DataHandler,
AngularDiameterMethod,
Kilometers,
Radians,
} from '..';
} from '../main';
import { NutationAngles } from './NutationAngles';
import { PrecessionAngles } from './PrecessionAngles';

Expand Down
2 changes: 1 addition & 1 deletion src/body/Moon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* DEALINGS IN THE SOFTWARE.
*/

import { AngularDiameterMethod, Celestial, Degrees, Kilometers, RaDec, Radians } from '..';
import { AngularDiameterMethod, Celestial, Degrees, Kilometers, RaDec, Radians } from '../main';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { DEG2RAD, MS_PER_DAY } from '../utils/constants';
Expand Down
2 changes: 1 addition & 1 deletion src/body/NutationAngles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Radians } from '..';
import { Radians } from '../main';

/**
* Represents the nutation angles.
Expand Down
2 changes: 1 addition & 1 deletion src/body/PrecessionAngles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Radians } from '..';
import { Radians } from '../main';

/**
* Represents the precession angles in radians.
Expand Down
20 changes: 10 additions & 10 deletions src/body/Sun.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
Earth,
Celestial,
angularDiameter,
AngularDiameterMethod,
astronomicalUnit,
AzEl,
Celestial,
cKmPerSec,
DEG2RAD,
MS_PER_DAY,
RAD2DEG,
TAU,
EpochUTC,
Vector3D,
AngularDiameterMethod,
AzEl,
Degrees,
Earth,
EpochUTC,
Kilometers,
Meters,
MS_PER_DAY,
RAD2DEG,
RaDec,
Radians,
SunTime,
} from '..';
TAU,
Vector3D,
} from '../main';

/**
* Sun metrics and operations.
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/Geodetic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AngularDistanceMethod } from '..';
import { Earth } from '../body/Earth';
import { AngularDistanceMethod } from '../main';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { DEG2RAD, RAD2DEG } from '../utils/constants';
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/Tle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

import { ClassicalElements, FormatTle, TEME } from '.';
import { Sgp4, Vector3D } from '..';
import { Sgp4OpsMode } from '../enums/Sgp4OpsMode';
import { Sgp4, Vector3D } from '../main';
import { Sgp4GravConstants } from '../sgp4/sgp4';
import { EpochUTC } from '../time/EpochUTC';
import {
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/objects/Star.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
* DEALINGS IN THE SOFTWARE.
*/

import { BaseObject } from './BaseObject';
import {
StarObjectParams,
Celestial,
Degrees,
ecf2eci,
EciVec3,
GreenwichMeanSiderealTime,
jday,
Kilometers,
LlaVec3,
MILLISECONDS_TO_DAYS,
Radians,
rae2ecf,
RaeVec3,
SpaceObjectType,
MILLISECONDS_TO_DAYS,
Celestial,
Sgp4,
ecf2eci,
jday,
rae2ecf,
} from '../index';
SpaceObjectType,
StarObjectParams,
} from '../main';
import { BaseObject } from './BaseObject';

export class Star extends BaseObject {
ra: Radians;
Expand Down
2 changes: 1 addition & 1 deletion src/observation/RAE.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-undefined */
import { Radians } from '..';
import { ITRF } from '../coordinate/ITRF';
import { J2000 } from '../coordinate/J2000';
import { AngularDistanceMethod } from '../enums/AngularDistanceMethod';
import { Radians } from '../main';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { DEG2RAD, halfPi, RAD2DEG, TAU } from '../utils/constants';
Expand Down
8 changes: 6 additions & 2 deletions src/operations/Vector3D.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { linearDistance } from '..';
import { linearDistance } from '../main';
import { Matrix } from './Matrix';
import { Vector } from './Vector';

// / 3-dimensional vector.
export class Vector3D<T extends number = number> {
constructor(public x: T, public y: T, public z: T) {
constructor(
public x: T,
public y: T,
public z: T,
) {
// Nothing to do here.
}

Expand Down
2 changes: 1 addition & 1 deletion src/transforms/conversions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEG2RAD, PI, RAD2DEG, Degrees, Radians } from '..';
import { DEG2RAD, Degrees, PI, RAD2DEG, Radians } from '../main';

/**
* Converts radians to degrees.
Expand Down
18 changes: 9 additions & 9 deletions src/transforms/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@
*/

import {
DEG2RAD,
Degrees,
Earth,
EcefVec3,
EcfVec3,
EciVec3,
EnuVec3,
GreenwichMeanSiderealTime,
Kilometers,
LlaVec3,
MILLISECONDS_TO_DAYS,
PI,
RAD2DEG,
RadarSensor,
Radians,
RaeVec3,
RfVec3,
RuvVec3,
SezVec3,
DEG2RAD,
MILLISECONDS_TO_DAYS,
PI,
RAD2DEG,
TAU,
Earth,
Sensor,
SezVec3,
Sgp4,
RadarSensor,
} from '..';
TAU,
} from '../main';
import { TransformCache } from './TransformCache';

/**
Expand Down
2 changes: 1 addition & 1 deletion test/body/Earth.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Earth, EpochUTC, Vector3D } from '../../src/main';
import { exampleDate } from '../lib/mockData';
import { Earth, EpochUTC, Vector3D } from '../../src/index';

describe('Earth', () => {
// can calculate mean motion from semimajor axis
Expand Down
2 changes: 1 addition & 1 deletion test/body/Moon.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Degrees, EpochUTC, Moon, Vector3D } from '../../src/main';
import { exampleDate } from '../lib/mockData';
import { Degrees, EpochUTC, Moon, Vector3D } from '../../src';

describe('Moon', () => {
// The static property 'mu' should be accessible and have a value of 4902.799.
Expand Down
2 changes: 1 addition & 1 deletion test/body/Sun.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vector3D, Degrees, Meters, Sun, EpochUTC } from './../../src';
import { Degrees, EpochUTC, Meters, Sun, Vector3D } from '../../src/main';
import { exampleDate } from '../lib/mockData';

describe('Sun', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ootk from '../src/index';
import * as ootk from '../src/main';

describe('ootk-core', () => {
it('should export Celestial', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/compareVectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Helper from satellite.js to compare vectors
*/

import { Vec3 } from '../../src/index';
import { Vec3 } from '../../src/main';

export const compareVectors = (vector1: Vec3, vector2: Vec3, numDigits: number) => {
if (!numDigits) {
Expand Down
2 changes: 1 addition & 1 deletion test/objects/BaseObject.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseObject, BaseObjectParams, EciVec3, SpaceObjectType } from '../../src';
import { BaseObject, BaseObjectParams, EciVec3, SpaceObjectType } from '../../src/main';
const mockVelocity = {
x: 8000,
y: 0,
Expand Down
4 changes: 2 additions & 2 deletions test/objects/Satellite.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { exampleDate } from '../lib/mockData';
import {
Degrees,
GroundPosition,
Expand All @@ -8,7 +7,8 @@ import {
SatelliteParams,
TleLine1,
TleLine2,
} from '../../src';
} from '../../src/main';
import { exampleDate } from '../lib/mockData';

const dateObj = new Date(1661400000000);

Expand Down
Loading

0 comments on commit 713d07e

Please sign in to comment.