• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pustovitDmytro / semantic-release-bundle / 6e045375-c5a5-4c0e-9432-d534e4351dff

30 Nov 2023 09:07PM UTC coverage: 93.396%. Remained the same
6e045375-c5a5-4c0e-9432-d534e4351dff

push

circleci

pustovitDmytro
New: add initial version

21 of 26 branches covered (0.0%)

Branch coverage included in aggregate %.

78 of 80 new or added lines in 5 files covered. (97.5%)

78 of 80 relevant lines covered (97.5%)

3.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.02
/src/verifyConditions.js
1
import path from 'path';
1✔
2
import fs from 'fs-extra';
1✔
3
import { validate } from './utils';
1✔
4
import { NO_FILE } from './Error';
2✔
5

6
const basicRules = {
1✔
7
    type            : [ 'required',  { 'enum': [ 'q-manifest' ] } ],
8
    packageJSONPath : [ 'string', { default: 'package.json' } ]
9
};
10

11
const typeRules = {
1✔
12
    'q-manifest' : {
13
        buildDirectory : [ 'string', { default: 'build' } ]
14
    }
15
};
16

17
const genericRules = {
1✔
18
    directory         : [ 'string', { default: 'dist' } ],
19
    previousVersion   : [ 'required', 'string' ],
20
    updatePackageJSON : [ 'boolean', { default: false } ]
21
};
22

23
function getBundleNames(qManifest, packageName) {
24
    return Object.keys(qManifest.bundles).filter(bundleName => {
2✔
25
        const b = qManifest.bundles[bundleName];
78✔
26

27
        return b.origins.includes(packageName);
78✔
28
    });
29
}
30

31
async function checkFile(filePath) {
32
    const isExists = await fs.exists(filePath);
7✔
33

34
    if (!isExists) throw new NO_FILE(filePath);
7✔
35
}
36

37
export default async function verifyConditions(pluginConfig, { logger, cwd }) {
38
    const basicValid = validate(pluginConfig, basicRules);
4✔
39
    const typeValid = validate(pluginConfig, typeRules[basicValid.type]);
3✔
40

41
    const packageJSONPath = path.resolve(cwd, basicValid.packageJSONPath);
3✔
42

43
    await checkFile(packageJSONPath);
3✔
44

45
    const packageJSON = await fs.readJSON(packageJSONPath);
2✔
46

47
    const raw = {
2✔
48
        previousVersion : packageJSON.version,
49
        ...pluginConfig
50
    };
51

52
    const data = validate(raw, genericRules);
2✔
53

54
    logger.log(`Detected: ${basicValid.type} configuration. previous version: ${data.previousVersion}`);
2✔
55

56
    const valid = {
2✔
57
        distPath : path.resolve(cwd, data.directory)
58
    };
59

60
    if (basicValid.type === 'q-manifest') {
2!
61
        valid.qManifestPath = path.resolve(valid.distPath, 'q-manifest.json');
2✔
62
        await checkFile(valid.qManifestPath);
2✔
63

64
        const qManifest = await fs.readJSON(valid.qManifestPath);
2✔
65
        const bundleNames = await getBundleNames(qManifest, path.basename(packageJSONPath));
2✔
66

67
        // eslint-disable-next-line require-atomic-updates
68
        valid.bundles = await Promise.all(bundleNames.map(async name => {
2✔
69
            const bundlePath = path.resolve(valid.distPath, typeValid.buildDirectory, name);
2✔
70

71
            await checkFile(bundlePath);
2✔
72

73
            return bundlePath;
1✔
74
        }));
75

76
        if (bundleNames.length > 0) {
1!
77
            logger.log(`Replace version in: ${bundleNames.join(',')}`);
1✔
78
        } else {
NEW
79
            logger.warn(`No suitable bundles found in ${valid.qManifestPath}`);
×
80
        }
81
    }
82

83

84
    this.verified = {
1✔
85
        ...basicValid,
86
        ...data,
87
        ...typeValid,
88
        ...valid
89
    };
90

91
    return data;
1✔
92
}
93

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc