adapt-migrations 1.3.0 → 1.4.1

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.
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
@@ -7,19 +7,24 @@ jobs:
7
7
  release:
8
8
  name: Release
9
9
  runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: write # to be able to publish a GitHub release
12
+ issues: write # to be able to comment on released issues
13
+ pull-requests: write # to be able to comment on released pull requests
14
+ id-token: write # to enable use of OIDC for trusted publishing and npm provenance
10
15
  steps:
11
16
  - name: Checkout
12
- uses: actions/checkout@v2
17
+ uses: actions/checkout@v4
13
18
  with:
14
19
  fetch-depth: 0
15
20
  - name: Setup Node.js
16
- uses: actions/setup-node@v2
21
+ uses: actions/setup-node@v4
17
22
  with:
18
23
  node-version: 'lts/*'
24
+ registry-url: https://registry.npmjs.org
19
25
  - name: Install dependencies
20
26
  run: npm ci
21
27
  - name: Release
22
28
  env:
23
29
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
25
30
  run: npx semantic-release
package/api/helpers.js CHANGED
@@ -5,7 +5,7 @@ function getContent() {
5
5
  }
6
6
 
7
7
  export function getConfig () {
8
- return getContent().find(({ _type, __path__ }) => _type === 'config' || __path__.endsWith('config.json'))
8
+ return getContent().find(({ _type, __path__ }) => _type === 'config' || __path__?.endsWith('config.json'))
9
9
  }
10
10
 
11
11
  export function getCourse() {
package/lib/Task.js CHANGED
@@ -5,6 +5,8 @@ import chalk from 'chalk'
5
5
  import TaskContext from './TaskContext.js'
6
6
  import Journal from '../lib/Journal.js'
7
7
  import { exec } from 'child_process'
8
+ import pkgUp from 'pkg-up'
9
+ import semver from 'semver'
8
10
 
9
11
  function makeTable(items, columnNames) {
10
12
  // calculate the max column widths for the items
@@ -277,9 +279,23 @@ export default class Task {
277
279
  toDelete.forEach(filePath => fs.rmSync(filePath))
278
280
  let i = 0
279
281
  for (const filePath of scripts) {
282
+ let fileContents = fs.readFileSync(filePath, 'utf8')
280
283
  const cachedPath = path.join(cachePath, `a${++i}.js`).replace(/\\/g, '/')
281
284
  Task.mapCacheToSource[cachedPath] = filePath.replace(/\\/g, '/')
282
- fs.copyFileSync(filePath, cachedPath)
285
+ const replacements = ['@@CURRENT_VERSION', '@@RELEASE_VERSION']
286
+ const shouldReplaceVersions = replacements.some(item => fileContents.includes(item))
287
+ if (shouldReplaceVersions) {
288
+ const packageJsonPath = await pkgUp({ cwd: filePath })
289
+ if (!packageJsonPath) return logger.error(`Task -- Unable to find package.json for ${filePath}`)
290
+ const packageJson = await fs.readJson(packageJsonPath)
291
+ const currentVersion = packageJson.version
292
+ const releaseVersion = semver.inc(currentVersion, 'patch')
293
+ fileContents = fileContents
294
+ .replace(/@@CURRENT_VERSION/g, currentVersion)
295
+ .replace(/@@RELEASE_VERSION/g, releaseVersion)
296
+ logger.info(`Task -- ${filePath} @@CURRENT_VERSION/@@RELEASE_VERSION replaced with ${currentVersion}/${releaseVersion}`)
297
+ }
298
+ fs.writeFileSync(cachedPath, fileContents, 'utf8')
283
299
  }
284
300
  fs.writeJsonSync(path.join(cachePath, 'package.json'), {
285
301
  name: 'migrations',
package/package.json CHANGED
@@ -2,11 +2,15 @@
2
2
  "name": "adapt-migrations",
3
3
  "type": "module",
4
4
  "main": "index.js",
5
- "version": "1.3.0",
6
- "repositoryUrl": "https://github.com/adaptlearning/adapt-migrations.git",
5
+ "version": "1.4.1",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/adaptlearning/adapt-migrations.git"
9
+ },
7
10
  "dependencies": {
8
11
  "fs-extra": "^11.1.1",
9
12
  "globs": "^0.1.4",
13
+ "pkg-up": "^3.1.0",
10
14
  "semver": "^7.5.4"
11
15
  },
12
16
  "devDependencies": {
@@ -15,13 +19,8 @@
15
19
  "eslint-plugin-import": "^2.27.5",
16
20
  "eslint-plugin-node": "^11.1.0",
17
21
  "eslint-plugin-promise": "^6.1.1",
18
- "@semantic-release/commit-analyzer": "^9.0.2",
19
22
  "@semantic-release/git": "^10.0.1",
20
- "@semantic-release/github": "^8.0.5",
21
- "@semantic-release/npm": "^9.0.1",
22
- "@semantic-release/release-notes-generator": "^10.0.3",
23
- "conventional-changelog-eslint": "^3.0.9",
24
- "semantic-release": "^21.0.1"
23
+ "semantic-release": "^25.0.2"
25
24
  },
26
25
  "release": {
27
26
  "plugins": [