@devvit/cli 0.11.16 → 0.11.17-next-2025-05-27-7cf402c0e.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/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +7 -4
- package/dist/templates/blocks-post/package.json +2 -2
- package/dist/templates/empty/package.json +2 -2
- package/dist/templates/payments/package.json +3 -3
- package/dist/templates/payments-web-view/package.json +3 -3
- package/dist/templates/pen/package.json +2 -2
- package/dist/templates/web-view-post/package.json +2 -2
- package/dist/util/AppVersionUploader.d.ts +2 -1
- package/dist/util/AppVersionUploader.d.ts.map +1 -1
- package/dist/util/Bundler.d.ts.map +1 -1
- package/dist/util/Bundler.js +6 -5
- package/package.json +10 -20
- package/dist/util/Git.d.ts +0 -19
- package/dist/util/Git.d.ts.map +0 -1
- package/dist/util/Git.js +0 -71
- package/dist/util/Git.spec.d.ts +0 -2
- package/dist/util/Git.spec.d.ts.map +0 -1
- package/dist/util/Git.spec.js +0 -106
- package/dist/util/templates/gitignore +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAOxE,OAAO,EAAE,aAAa,EAAwB,MAAM,mCAAmC,CAAC;AAmCxF,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,aAAa;;IAC5C,OAAgB,WAAW,SAAsB;IAEjD,OAAgB,QAAQ,WAAoB;IAE5C,OAAgB,KAAK;;;;;MA2BV;IAEX,OAAgB,IAAI;;MAOT;IA6BI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAuNpB,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAM1D"}
|
package/dist/commands/new.js
CHANGED
|
@@ -12,6 +12,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
12
12
|
var _New_instances, _New_createAppParams, _New_createAppFlags, _New_event, _New_eventSent, _New_projectPath_get, _New_gitInit, _New_initCreateAppParams, _New_promptAppName, _New_promptChooseTemplate, _New_copyProjectTemplate, _New_installAppDependencies, _New_syncDependenciesToCurrentCliVersion, _New_logWelcomeMessage, _New_sendEventIfNotSent;
|
|
13
13
|
import { exec as _exec } from 'node:child_process';
|
|
14
14
|
import { readdirSync } from 'node:fs';
|
|
15
|
+
import fs from 'node:fs';
|
|
15
16
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
16
17
|
import { createRequire } from 'node:module';
|
|
17
18
|
import path from 'node:path';
|
|
@@ -23,10 +24,10 @@ import { APP_SLUG_BASE_MAX_LENGTH, makeSlug, sluggable } from '@devvit/shared-ty
|
|
|
23
24
|
import { Args, Flags } from '@oclif/core';
|
|
24
25
|
import chalk from 'chalk';
|
|
25
26
|
import inquirer from 'inquirer';
|
|
27
|
+
import git from 'isomorphic-git';
|
|
26
28
|
import semver from 'semver';
|
|
27
29
|
import { DevvitCommand, toLowerCaseArgParser } from '../util/commands/DevvitCommand.js';
|
|
28
30
|
import Cutter from '../util/Cutter.js';
|
|
29
|
-
import { Git } from '../util/Git.js';
|
|
30
31
|
import { sendEvent } from '../util/metrics.js';
|
|
31
32
|
import { ProjectTemplateResolver } from '../util/template-resolvers/ProjectTemplateResolver.js';
|
|
32
33
|
import { logInBox } from '../util/ui.js';
|
|
@@ -118,9 +119,11 @@ _New_createAppParams = new WeakMap(), _New_createAppFlags = new WeakMap(), _New_
|
|
|
118
119
|
// else, we're using the app slug as the dir name
|
|
119
120
|
return path.join(process.cwd(), __classPrivateFieldGet(this, _New_createAppParams, "f").appName);
|
|
120
121
|
}, _New_gitInit = async function _New_gitInit() {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
await git.init({
|
|
123
|
+
fs,
|
|
124
|
+
dir: __classPrivateFieldGet(this, _New_instances, "a", _New_projectPath_get),
|
|
125
|
+
defaultBranch: 'main',
|
|
126
|
+
});
|
|
124
127
|
}, _New_initCreateAppParams = async function _New_initCreateAppParams(args, flags) {
|
|
125
128
|
// If the template is a URL, unpack it as a pen. This code does not throw.
|
|
126
129
|
let pen;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "experience-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.17-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.17-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.8.3"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "empty-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.17-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.17-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.8.3"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "payment-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.17-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/payments": "0.11.
|
|
9
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/payments": "0.11.17-dev",
|
|
9
|
+
"@devvit/public-api": "0.11.17-dev"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"typescript": "5.8.3"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "payments-web-view-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.17-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/payments": "0.11.
|
|
9
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/payments": "0.11.17-dev",
|
|
9
|
+
"@devvit/public-api": "0.11.17-dev"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"typescript": "5.8.3"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "pen-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.17-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.17-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.8.3"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "web-view-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.17-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.17-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.8.3"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type AppVersionInfo, type
|
|
1
|
+
import { type AppVersionInfo, type VersionVisibility } from '@devvit/protos/community.js';
|
|
2
|
+
import type { Bundle } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
2
3
|
import type { DevvitVersion } from '@devvit/shared-types/Version.js';
|
|
3
4
|
import type { DevvitCommand } from './commands/DevvitCommand.js';
|
|
4
5
|
export declare class AppVersionUploader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppVersionUploader.d.ts","sourceRoot":"","sources":["../../src/util/AppVersionUploader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"AppVersionUploader.d.ts","sourceRoot":"","sources":["../../src/util/AppVersionUploader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAG/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAMrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAKjE,qBAAa,kBAAkB;;gBAMjB,GAAG,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAK3D,aAAa,CACjB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,aAAa,CAAC;QACzB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,EACD,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,cAAc,CAAC;CA2H3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bundler.d.ts","sourceRoot":"","sources":["../../src/util/Bundler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAC/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,qBAAa,OAAO;;;IAUZ,MAAM,CACV,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,SAAS,EACpB,eAAe,GAAE,OAAe,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC;IAqBd,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,KAAK,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Bundler.d.ts","sourceRoot":"","sources":["../../src/util/Bundler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAC/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,qBAAa,OAAO;;;IAUZ,MAAM,CACV,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,SAAS,EACpB,eAAe,GAAE,OAAe,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC;IAqBd,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,KAAK,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC;CAgB7E"}
|
package/dist/util/Bundler.js
CHANGED
|
@@ -22,7 +22,9 @@ export class Bundler {
|
|
|
22
22
|
__classPrivateFieldSet(this, _Bundler_buildPack, new ESBuildPack({ hostname: LOCAL_HOSTNAME }, { disableExternDevvitProtos: DEVVIT_DISABLE_EXTERN_DEVVIT_PROTOS }), "f");
|
|
23
23
|
}
|
|
24
24
|
async bundle(root, actorSpec, includeMetafile = false) {
|
|
25
|
-
const compiledRes = await __classPrivateFieldGet(this, _Bundler_buildPack, "f").
|
|
25
|
+
const compiledRes = await __classPrivateFieldGet(this, _Bundler_buildPack, "f").compile(
|
|
26
|
+
// to-do: why no minify?
|
|
27
|
+
{ filename: root, info: actorSpec, minify: 'None', includeMetafile });
|
|
26
28
|
if (compiledRes.warnings.length > 0) {
|
|
27
29
|
console.warn(formatLogs(compiledRes.warnings));
|
|
28
30
|
}
|
|
@@ -39,13 +41,12 @@ export class Bundler {
|
|
|
39
41
|
}
|
|
40
42
|
watch(root, actorSpec) {
|
|
41
43
|
return __classPrivateFieldGet(this, _Bundler_buildPack, "f")
|
|
42
|
-
.
|
|
44
|
+
.watch({
|
|
43
45
|
filename: root,
|
|
44
46
|
info: actorSpec,
|
|
45
|
-
|
|
46
|
-
minify: 0,
|
|
47
|
+
minify: 'None',
|
|
47
48
|
includeMetafile: false,
|
|
48
|
-
}
|
|
49
|
+
})
|
|
49
50
|
.pipe(map((rsp) => {
|
|
50
51
|
if (rsp.warnings.length > 0)
|
|
51
52
|
console.warn(formatLogs(rsp.warnings));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
4
4
|
"description": "Reddit's Dev Platform CLI Tool",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"author": "@reddit/dev-platform",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rm -rf dist && tsc && yarn build:copy",
|
|
27
|
-
"build:copy": "
|
|
27
|
+
"build:copy": "rm -rf ./dist/templates; cp -a ./src/templates ./dist/templates",
|
|
28
28
|
"clean": "rm -rf .turbo coverage dist docs.json oclif.manifest.json",
|
|
29
29
|
"clobber": "yarn clean && rm -rf node_modules",
|
|
30
30
|
"dev": "tsc --watch",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"lint": "redlint .",
|
|
33
33
|
"lint:fix": "yarn lint --fix",
|
|
34
34
|
"prepack": "yarn build && oclif manifest",
|
|
35
|
-
"postpack": "
|
|
35
|
+
"postpack": "rm -f oclif.manifest.json",
|
|
36
36
|
"test": "concurrently -n 'unit,types,lint,oclif' 'yarn test:unit' 'yarn test:types' 'yarn test:lint' 'yarn test:oclif'",
|
|
37
37
|
"test:lint": "yarn lint",
|
|
38
38
|
"test:oclif": "oclif manifest",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@devvit/build-pack": "0.11.
|
|
45
|
+
"@devvit/build-pack": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
46
46
|
"@devvit/play": "0.0.45",
|
|
47
|
-
"@devvit/protos": "0.11.
|
|
48
|
-
"@devvit/public-api": "0.11.
|
|
49
|
-
"@devvit/shared-types": "0.11.
|
|
47
|
+
"@devvit/protos": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
48
|
+
"@devvit/public-api": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
49
|
+
"@devvit/shared-types": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
50
50
|
"@improbable-eng/grpc-web": "0.15.0",
|
|
51
51
|
"@improbable-eng/grpc-web-node-http-transport": "0.15.0",
|
|
52
52
|
"@oclif/core": "2.9.4",
|
|
@@ -59,42 +59,32 @@
|
|
|
59
59
|
"chokidar": "3.5.3",
|
|
60
60
|
"date-fns": "2.29.3",
|
|
61
61
|
"file-type": "18.2.1",
|
|
62
|
-
"get-port": "6.1.2",
|
|
63
62
|
"image-size": "1.2.1",
|
|
64
63
|
"inquirer": "9.1.4",
|
|
65
64
|
"isomorphic-git": "1.21.0",
|
|
66
65
|
"js-yaml": "4.1.0",
|
|
67
|
-
"listr": "0.14.3",
|
|
68
|
-
"lookpath": "1.2.2",
|
|
69
66
|
"mustache": "4.2.0",
|
|
70
67
|
"open": "10.1.0",
|
|
71
|
-
"ps-node": "^0.1.6",
|
|
72
68
|
"rxjs": "7.8.1",
|
|
73
69
|
"semver": "7.6.3",
|
|
74
70
|
"string-length": "5.0.1",
|
|
75
71
|
"tiny-glob": "0.2.9",
|
|
76
|
-
"tsv": "0.2.0",
|
|
77
72
|
"twirp-ts": "2.5.0",
|
|
78
73
|
"ws": "8.18.0"
|
|
79
74
|
},
|
|
80
75
|
"devDependencies": {
|
|
81
|
-
"@devvit/repo-tools": "0.11.
|
|
82
|
-
"@devvit/tsconfig": "0.11.
|
|
76
|
+
"@devvit/repo-tools": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
77
|
+
"@devvit/tsconfig": "0.11.17-next-2025-05-27-7cf402c0e.0",
|
|
83
78
|
"@types/file-type": "10.9.1",
|
|
84
79
|
"@types/inquirer": "9.0.3",
|
|
85
80
|
"@types/js-yaml": "4.0.5",
|
|
86
81
|
"@types/mustache": "4.2.2",
|
|
87
82
|
"@types/node": "20.14.12",
|
|
88
83
|
"@types/open": "6.2.1",
|
|
89
|
-
"@types/ps-node": "0.1.1",
|
|
90
84
|
"@types/semver": "7.5.8",
|
|
91
|
-
"@types/tsv": "0.2.1",
|
|
92
|
-
"chai": "4.3.7",
|
|
93
85
|
"concurrently": "7.5.0",
|
|
94
86
|
"eslint": "9.11.1",
|
|
95
87
|
"oclif": "3.17.2",
|
|
96
|
-
"shx": "0.3.4",
|
|
97
|
-
"tmp-promise": "3.0.3",
|
|
98
88
|
"typescript": "5.8.3",
|
|
99
89
|
"vitest": "1.6.1"
|
|
100
90
|
},
|
|
@@ -120,5 +110,5 @@
|
|
|
120
110
|
]
|
|
121
111
|
}
|
|
122
112
|
},
|
|
123
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "7bc975913d312efeda46745a4e18ea0448c578a7"
|
|
124
114
|
}
|
package/dist/util/Git.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type IGit = {
|
|
2
|
-
rootDir: string;
|
|
3
|
-
init(): Promise<void>;
|
|
4
|
-
assertIsInsideGitRepo(): Promise<void>;
|
|
5
|
-
assertWorktreeHasCommit(): Promise<void>;
|
|
6
|
-
listFiles(): Promise<string[]>;
|
|
7
|
-
initDotGitIgnore(): Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
export declare class Git implements IGit {
|
|
10
|
-
#private;
|
|
11
|
-
constructor(baseDir: string);
|
|
12
|
-
init(): Promise<void>;
|
|
13
|
-
get rootDir(): string;
|
|
14
|
-
assertIsInsideGitRepo(): Promise<void>;
|
|
15
|
-
assertWorktreeHasCommit(): Promise<void>;
|
|
16
|
-
listFiles(): Promise<string[]>;
|
|
17
|
-
initDotGitIgnore(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=Git.d.ts.map
|
package/dist/util/Git.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Git.d.ts","sourceRoot":"","sources":["../../src/util/Git.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,IAAI,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC,CAAC;AAGF,qBAAa,GAAI,YAAW,IAAI;;gBAGlB,OAAO,EAAE,MAAM;IAIrB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,IAAI,OAAO,IAAI,MAAM,CAEpB;IAEK,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAatC,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxC,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAS9B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAKxC"}
|
package/dist/util/Git.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _Git_baseDir;
|
|
13
|
-
import fs from 'node:fs';
|
|
14
|
-
import fsp from 'node:fs/promises';
|
|
15
|
-
import path from 'node:path';
|
|
16
|
-
import url from 'node:url';
|
|
17
|
-
import git, { Errors as GitErrors, TREE } from 'isomorphic-git';
|
|
18
|
-
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
19
|
-
// implementation using isomorphic-git
|
|
20
|
-
export class Git {
|
|
21
|
-
constructor(baseDir) {
|
|
22
|
-
_Git_baseDir.set(this, void 0);
|
|
23
|
-
__classPrivateFieldSet(this, _Git_baseDir, baseDir, "f");
|
|
24
|
-
}
|
|
25
|
-
async init() {
|
|
26
|
-
await git.init({
|
|
27
|
-
fs,
|
|
28
|
-
dir: __classPrivateFieldGet(this, _Git_baseDir, "f"),
|
|
29
|
-
defaultBranch: 'main',
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
get rootDir() {
|
|
33
|
-
return __classPrivateFieldGet(this, _Git_baseDir, "f");
|
|
34
|
-
}
|
|
35
|
-
async assertIsInsideGitRepo() {
|
|
36
|
-
try {
|
|
37
|
-
await git.findRoot({ fs, filepath: __classPrivateFieldGet(this, _Git_baseDir, "f") });
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (error instanceof GitErrors.NotFoundError) {
|
|
41
|
-
throw new Error(`Your current working directory is not in a git repo. Try running \`git init\` in the project root, or see https://git-scm.com/docs/git-init for instructions on initializing a git repo`);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async assertWorktreeHasCommit() {
|
|
47
|
-
try {
|
|
48
|
-
await git.log({ fs, dir: __classPrivateFieldGet(this, _Git_baseDir, "f") });
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (error instanceof GitErrors.NotFoundError) {
|
|
52
|
-
throw new Error('Devvit uses HEAD for publishing. Make sure that there is at least one commit in the project before publishing');
|
|
53
|
-
}
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async listFiles() {
|
|
58
|
-
return git.walk({
|
|
59
|
-
fs,
|
|
60
|
-
dir: __classPrivateFieldGet(this, _Git_baseDir, "f"),
|
|
61
|
-
trees: [TREE({ ref: 'HEAD' })],
|
|
62
|
-
map: async (filepath, _) => filepath, // some isomorphic-git magic here. See https://isomorphic-git.org/docs/en/walk#mapstring-array-walkerentry-null-promise-any
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async initDotGitIgnore() {
|
|
66
|
-
const src = path.join(__dirname, './templates/gitignore');
|
|
67
|
-
const dest = path.join(this.rootDir, '.gitignore');
|
|
68
|
-
await fsp.copyFile(src, dest);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
_Git_baseDir = new WeakMap();
|
package/dist/util/Git.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Git.spec.d.ts","sourceRoot":"","sources":["../../src/util/Git.spec.ts"],"names":[],"mappings":""}
|
package/dist/util/Git.spec.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { exec as _exec } from 'node:child_process';
|
|
2
|
-
import { readdir, writeFile } from 'node:fs/promises';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
import tmp from 'tmp-promise';
|
|
6
|
-
import { Git } from './Git.js';
|
|
7
|
-
const exec = promisify(_exec);
|
|
8
|
-
tmp.setGracefulCleanup();
|
|
9
|
-
let tmpRootDir;
|
|
10
|
-
let git;
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
tmpRootDir = await tmp.dir({ unsafeCleanup: true });
|
|
13
|
-
git = new Git(tmpRootDir.path);
|
|
14
|
-
await git.init();
|
|
15
|
-
});
|
|
16
|
-
afterEach(async () => {
|
|
17
|
-
await tmpRootDir.cleanup();
|
|
18
|
-
});
|
|
19
|
-
describe('Git', async () => {
|
|
20
|
-
describe('init', async () => {
|
|
21
|
-
it('creates .git directory', async () => {
|
|
22
|
-
const files = (await readdir(tmpRootDir.path, { withFileTypes: true }))
|
|
23
|
-
.filter((d) => d.isDirectory())
|
|
24
|
-
.map((f) => f.name);
|
|
25
|
-
expect(files).toContain('.git');
|
|
26
|
-
});
|
|
27
|
-
it(`uses "main" as default branch name`, async () => {
|
|
28
|
-
// make tmp file to stage & commit
|
|
29
|
-
await tmp.file({ dir: tmpRootDir.path });
|
|
30
|
-
// stage and commit
|
|
31
|
-
await exec('git add -A && git commit -m "initial commit"', {
|
|
32
|
-
cwd: tmpRootDir.path,
|
|
33
|
-
});
|
|
34
|
-
const res = await exec('git rev-parse --abbrev-ref HEAD', { cwd: tmpRootDir.path });
|
|
35
|
-
expect(res.stdout).toMatch(/main/);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe('get rootDir', async () => {
|
|
39
|
-
it('returns root dir of git project', async () => {
|
|
40
|
-
expect(git.rootDir).toBe(tmpRootDir.path);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe('assertIsInsideGitRepo', async () => {
|
|
44
|
-
it('Throws an error if not in git repo', async () => {
|
|
45
|
-
const nonGitRepoDir = await tmp.dir({ unsafeCleanup: true });
|
|
46
|
-
git = new Git(nonGitRepoDir.path);
|
|
47
|
-
await expect(git.assertIsInsideGitRepo()).rejects.toThrowError('not in a git repo');
|
|
48
|
-
await nonGitRepoDir.cleanup();
|
|
49
|
-
});
|
|
50
|
-
it('Does not throw an error if inside git repo', async () => {
|
|
51
|
-
await expect(git.assertIsInsideGitRepo()).resolves.toBeUndefined();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe('assertWorktreeHasCommit', async () => {
|
|
55
|
-
it('Throws an error is there are no commits', async () => {
|
|
56
|
-
await expect(git.assertWorktreeHasCommit()).rejects.toThrowError('at least one commit');
|
|
57
|
-
});
|
|
58
|
-
it("Doesn't throw an error when there is at least one commit", async () => {
|
|
59
|
-
await tmp.file({ dir: tmpRootDir.path });
|
|
60
|
-
await exec('git add -A && git commit -m "initial commit"', {
|
|
61
|
-
cwd: tmpRootDir.path,
|
|
62
|
-
});
|
|
63
|
-
await expect(git.assertWorktreeHasCommit()).resolves.toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
describe('listFiles', async () => {
|
|
67
|
-
it('Should have the same output as `git ls-tree HEAD -r -t --name-only --full-tree`', async () => {
|
|
68
|
-
// make some files
|
|
69
|
-
await tmp.file({ dir: tmpRootDir.path, name: 'file1.txt' });
|
|
70
|
-
await tmp.file({ dir: tmpRootDir.path, name: 'file2.txt' });
|
|
71
|
-
await tmp.file({ dir: tmpRootDir.path, name: 'file3.txt' });
|
|
72
|
-
// stage and commit
|
|
73
|
-
await exec('git add -A && git commit -m "initial commit"', {
|
|
74
|
-
cwd: tmpRootDir.path,
|
|
75
|
-
});
|
|
76
|
-
const cmdResult = (await exec(`git ls-tree HEAD -r -t --name-only --full-tree`, {
|
|
77
|
-
cwd: tmpRootDir.path,
|
|
78
|
-
})).stdout
|
|
79
|
-
.split(os.EOL)
|
|
80
|
-
.filter((f) => f !== '');
|
|
81
|
-
const result = (await git.listFiles()).filter((f) => f !== '.');
|
|
82
|
-
expect(result).toEqual(expect.arrayContaining(cmdResult));
|
|
83
|
-
expect(cmdResult).toEqual(expect.arrayContaining(result));
|
|
84
|
-
});
|
|
85
|
-
it('Should respect .gitignore', async () => {
|
|
86
|
-
await tmp.file({ dir: tmpRootDir.path, name: 'file1.txt' });
|
|
87
|
-
await tmp.file({ dir: tmpRootDir.path, name: 'file2.txt' });
|
|
88
|
-
const ignoredFile = await tmp.file({ dir: tmpRootDir.path, name: 'file3.txt' });
|
|
89
|
-
const gitignore = await tmp.file({ dir: tmpRootDir.path, name: '.gitignore' });
|
|
90
|
-
await writeFile(gitignore.path, 'file3.txt');
|
|
91
|
-
// stage and commit
|
|
92
|
-
await exec('git add -A && git commit -m "initial commit"', {
|
|
93
|
-
cwd: tmpRootDir.path,
|
|
94
|
-
});
|
|
95
|
-
const result = await git.listFiles();
|
|
96
|
-
expect(result).not.toContain(ignoredFile.path);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
describe('initDotGitIgnore', async () => {
|
|
100
|
-
it('Should make a .gitignore in project root', async () => {
|
|
101
|
-
await git.initDotGitIgnore();
|
|
102
|
-
const files = await readdir(tmpRootDir.path);
|
|
103
|
-
expect(files).toContain('.gitignore');
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|